Closed Aaron-Robertson closed 1 year ago
Assigned to @Rahul-Mistri !
Can someone who has a bit more context here please provide what the expected output is? @Aaron-Robertson @andreamari @Rahul-Mistri
I think the expected result is the following:
┌───┐
q_0: ┤ X ├────────────────────
├───┤
q_1: ┤ X ├────────────────────
├───┤
q_2: ┤ X ├────────────────────
├───┤┌───┐┌───┐┌───┐┌───┐
q_3: ┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘└───┘
┌───┐┌───┐┌───┐┌───┐┌───┐
q_0: ┤ X ├┤ X ├┤ Y ├┤ X ├┤ Y ├
├───┤├───┤├───┤├───┤├───┤
q_1: ┤ X ├┤ X ├┤ Y ├┤ X ├┤ Y ├
├───┤├───┤├───┤├───┤├───┤
q_2: ┤ X ├┤ X ├┤ Y ├┤ X ├┤ Y ├
├───┤├───┤├───┤├───┤├───┤
q_3: ┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘└───┘
hi @Rahul-Mistri, wanted to check if you're planning to work on this issue in the current milestone (0.21, closes Nov 30). If not, no worries, someone on the UF team can pick this up.
Happy to help clear any roadblocks!
I took a look at this today and it seems to be a bit thorny. The problem goes away if one defines their circuit using a single register:
qreg = qiskit.QuantumRegister(4)
circuit_qiskit_one = qiskit.QuantumCircuit(qreg)
...
I'm not familiar enough with Qiskit to know if both are widely used, but it would be good to have these functions work regardless of how a user defined their circuit.
The problem arises because we use the index
attribute of Qubit
objects, which is register dependent, and hence how one defines their circuit affects the results of both https://github.com/unitaryfund/mitiq/blob/6af27485859e1b284d2607d5ef901078a303931b/mitiq/interface/mitiq_qiskit/conversions.py#L121-L123 and https://github.com/unitaryfund/mitiq/blob/6af27485859e1b284d2607d5ef901078a303931b/mitiq/interface/mitiq_qiskit/conversions.py#L150-L153
This issue, should probably be address in tandem with https://github.com/unitaryfund/mitiq/issues/1422. In fact they may be the same issue, really.
@Rahul-Mistri do you have any notes on this that differ/agree with my understanding?
Pre-Report Checklist
Issue Description
Qiskit circuits built on registers like
qiskit.QuantumRegister(1) for _ in range(4)
insert (and remove) idle identities poorly, in particular when combined with DDD. Qubit index returns0
for registers of the given type (and so other qubits are altered).How to Reproduce
Code Snippet
Error Output