Closed nkanazawa1989 closed 2 years ago
Just to add motivation to this old issue, I think I'm hitting the same problem when trying to simulate a noisy circuit by adding a multiqubit quantum channel to a circuit. For my use case this is simpler than building the error into a NoiseModel
.
I'm using Aer's pauli_error()
to define a 3+ qubit error instruction, and including that in a circuit, and later want to transpile the circuit. But AFAICT you can't transpile any circuit to which you've added a 3+ qubit quantum channel, even if that channel is added as a basis gate, which is pretty limiting for noise simulations. This is true even for optimization_level=0
. I can limp by without transpiling, but it complicates other parts of the code.
So I think fixing this issue could facilitate a range of noisy simulations.
Thanks for finding this. Indeed current design of pass manager is against the spirit of backend agnostic. Perhaps analyzing basis gates and conditionally inserting the unroll3Q pass is reasonable solution?
Yeah unroll3q or more should be basis and target aware. We shouldn't be unrolling gates in the target even if they're > 2q. The caveat here is we'll have to make sure that layout and routing can handle a 3q gate in the circuit. The reason that pass runs first by default is because layout and routing only works with 1q and 2q operations. This connects with https://github.com/Qiskit/qiskit-terra/issues/7812 for making sure the transpiler can work with multiqubit gates
What is the expected enhancement?
Because Qiskit is backend agnostic, we should be able to define custom multi qubit gate. What I want to do here is
But current transpiler passes don't allow to have 3q basis gates. I think this limits capability of Qiskit.
https://github.com/Qiskit/qiskit-terra/blob/6646e681501deb8aac55cdc69a8a351ec058e989/qiskit/transpiler/preset_passmanagers/level0.py#L107