Closed yhindy closed 4 years ago
Thanks @yhindy, interesting. Have you checked if the unitaries of the circuits are equal?
I think its possible to get the unitary using Qiskit but I forget how. You can convert to a Cirq circuit first though.
from mitiq.mitiq_qiskit.conversions import from_qiskit
cirq_circuit = from_qiskit(qiskit_circuit)
unitary = cirq_circuit.unitary()
Also cirq.equal_up_to_global_phase
is useful here.
Thanks Yousef! I am not sure if what you mentioned is actually a bug. The moment structure is such that gates are added as early as possible to minimize the total number of moments, taking into account that the order of non-commuting gates cannot be exchanged. In your circuits, the Ry(2.2245)
gate acts on qubit 2, while the CNOT gate acts on qubits (1, 3). So it is fine if some of the folded gates of Ry(2.2245)
end up being applied after the CNOT gate. Doing in a different way would increase the number of moments.
Hmm, so it turns out that the two circuits are equivalent in their unitaries, so there must be some other problem going on. Will investigate further.
Sounds good @yhindy let me know if there's still something mysterious going on and I'd be happy to have a look at the code. Will close this now but please reopen if its buggy.
Also in case its useful we have a VQE example (using Cirq not Qiskit) at https://github.com/unitaryfund/mitiq-examples which I think you have access to, if not let me know.
Hey everyone,
I've been working on using mitiq to mitigate errors in a Qiskit VQE implementation, and have found that there are some issues with folding. Attached is an image of the scaled QP (on top) and the original QP. If you take a look at the RY(2.2245) gate in the original, it happens before the controlled X on (3,0). When it is scaled, however, the RY(-2.2245) happens before the controlled X and the RY(2.2245) to undo that comes after the controlled X.
In other words, the moments are being violated. I think this can be fixed with qiskits
.barrier()
function.In any case, the bug leads to the wrong ansatz being computed, and the mitigated value cannot be used to do optimization.