Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.11k stars 2.34k forks source link

`Clifford.to_circuit()` returns a circuit with emtpy `qregs` #13041

Closed matteoacrossi closed 3 weeks ago

matteoacrossi commented 1 month ago

Environment

What is happening?

Clifford.to_circuit() returns a QuantumCircuit with empty qregs. I don't know if this is an expected behaviour, but it has changed since qiskit 1.1.2.

How can we reproduce the issue?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Clifford

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
cli = Clifford(qc)
cli.to_circuit().qregs

What should happen?

I would expect the QuantumCircuit to contain one QuantumRegister with the correct size, as it was the case in qiskit 1.1.2

>>> cli.to_circuit().qregs
[QuantumRegister(2, 'q')]

Any suggestions?

No response

matteoacrossi commented 1 month ago

With git bisect I found out that the regression was introduced in #12714

jakelishman commented 1 month ago

This change was unintentional and we will backport to fix it, but as a follow up: what are you doing that requires the QuantumRegister? The quantum register type is very close to meaningless in Qiskit, and I'm not sure how other libraries might be using it.

(Fwiw, registers are neither necessary for a circuit nor required to contain only unique bits, so the output of the function is still a valid circuit object, it's only a bug that we deviated from the prior behaviour without meaning to.)