Closed weucode closed 5 days ago
These are both expected behaviours - when you transpile your circuit to hardware, it becomes a physical circuit, which means it must account for all the qubits on the device. These are the extra ancillas you're seeing.
The call Statevector(qc1)
gets the statevector of all qubits in the circuit. After ancilla expansion, it's correct that it includes all hardware qubits; there are various swap-mapping and gate syntheses passes that could cause mid-circuit ancilla use, or even the ancillas to end in a dirty state at the end of the circuit. If you want to reduce it to the qubits you care about at the end, you'll need to use something like qiskit.quantum_info.partial_trace
, and you can find the qubits arguments by inspecting qc.layout.final_index_layout
.
Thank you for your quick response. I also found that using qc1.draw(idle_wires=False)
is helpful for observing the key parts of the circuit.
Environment
What is happening?
When running
program1
, two wrong behaviors were found: (1) Some fake backends declare duplicated ancilla qubits. The number of duplicated ancilla qubits varies between different fake backends. (2) The Statevector simulator treats ancilla qubits as common qubits and measures all of them. This issue can also be reproduced by runningprogram2
. These issues appear to persist across multiple versions ofqiskit
(e.g., 1.0.2), not just the latest ones. Do you have any suggestions or workarounds for these behaviors?How can we reproduce the issue?
program1:
output1:
The openqasm code:
program2:
output2:
What should happen?
(1) The fake backends should not declare duplicated ancilla qubits. (2) Statevector should identify the correct number of declared qubits.
Any suggestions?
No response