logging.getLogger('bqskit.compiler').setLevel(logging.DEBUG) # Let's create a 3-qubit toffoi unitary to synthesize and add it to a circuit. toffoli = np.array( [ [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0], ], dtype='complex128', ) circuit = Circuit.from_unitary(toffoli) # We will now define the CompilationTask we want to run. task = CompilationTask(circuit, [QSearchSynthesisPass(success_threshold=1e-9)]) # Finally let's create create the compiler and execute the CompilationTask. compiler = Compiler() compiled_circuit = compiler.compile(task) for op in compiled_circuit: print(op) # Close our connection to the compiler backend del compiler
"""This script is contains a simple use case of the QFAST synthesis method.""" from __future__ import annotations import logging from scipy.stats import unitary_group from bqskit.compiler import CompilationTask from bqskit.compiler import Compiler from bqskit.compiler.passes.synthesis import QFASTDecompositionPass from bqskit.ir import Circuit if __name__ == '__main__': # Enable logging logging.getLogger('bqskit').setLevel(logging.DEBUG) # Let's create a random 3-qubit unitary to synthesize and add it to a # circuit. circuit = Circuit.from_unitary(unitary_group.rvs(8)) # We will now define the CompilationTask we want to run. task = CompilationTask(circuit, [QFASTDecompositionPass()]) # Finally let's create create the compiler and execute the CompilationTask. with Compiler() as compiler: compiled_circuit = compiler.compile(task) for op in compiled_circuit: print(op)
"""This script is contains a simple use case of the QFAST synthesis method.""" from __future__ import annotations import logging from bqskit.compiler import CompilationTask from bqskit.compiler import Compiler from bqskit.compiler.passes.synthesis.qpredict import QPredictDecompositionPass from bqskit.ir import Circuit from bqskit.qis.unitary.unitarymatrix import UnitaryMatrix # Enable logging logging.getLogger('bqskit').setLevel(logging.DEBUG) # Let's create a random 3-qubit unitary to synthesize and add it to a circuit. circuit = Circuit.from_unitary(UnitaryMatrix.random(3)) # We will now define the CompilationTask we want to run. task = CompilationTask(circuit, [QPredictDecompositionPass()]) # Finally let's create create the compiler and execute the CompilationTask. compiler = Compiler() compiled_circuit = compiler.compile(task) for op in compiled_circuit: print(op) # Close our connection to the compiler backend del compiler