Closed kevinsung closed 7 months ago
Can you assign me to this?
I was playing around with generate_preset_pass_manager
and couldn't find a way to do unitary synthesis this way. For example:
from qiskit.providers.fake_provider import FakeBelem
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
backend = FakeBelem()
pass_manager = generate_preset_pass_manager(
optimization_level=3, backend=backend, unitary_synthesis_method="aqc"
)
pass_manager.run(matrix)
Throws errors complaining that basically say matrix
is not a QuantumCircuit
. It queries methods like name
, global_phase
, and calibrations
. How to use a pass manager or essentially qiskit.transpile
to do unitary synthesis?
The input to .run()
is a QuantumCircuit
object, so you'll need to put the matrix on a circuit for the transpiler to work with it. The easiest way is to do something like:
qc = QuantumCircuit(num_qubits)
qc.unitary(matrix, range(num_qubits))
and then pass qc to .run()
.
The other option is to manually call the aqc synthesis directly. There is a code sample on how to do this here: https://docs.quantum.ibm.com/api/qiskit/synthesis_aqc but it's much more manual.
To solve the original issue we just need to add a check to UnitarySynthesis
's __init__
method that the user specified plugin is valid. Right now it only gets checked during UnitarySynthesis.run
which is why it doesn't error until the passmanager is run.
Environment
What is happening?
generate_preset_pass_manager
does not raise an error for a nonexistent synthesis plugin, even though it does for a nonexistent stage plugin.How can we reproduce the issue?
What should happen?
This does not raise an error. Instead, an error is raised when the pass manager is run. This is inconsistent with the transpiler stage plugins. For example, this raises an error:
Any suggestions?
The error should be raised when the pass manager is created, not when it is run.