Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Home Page:https://www.ibm.com/quantum/qiskit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

measure_active returns register called "measure" which breaks round tripping in QASM

nonhermitian opened this issue · comments

Environment

  • Qiskit version: latest
  • Python version:
  • Operating system:

What is happening?

qc = qiskit.QuantumCircuit(1)
qc.reset(0)
qc.measure_active()

qc.cregs

[ClassicalRegister(1, 'measure')]

from qiskit.qasm3 import dumps, loads
qstr = dumps(qc)
new_qc = loads(qstr)
new_qc.cregs

[ClassicalRegister(1, 'esc__measure')]

How can we reproduce the issue?

run above

What should happen?

should be able to round trip a circuit

Any suggestions?

Unify the register name of measure_active and measure_all perhaps?

The suggestion seems related to #12192

We can certainly change the default here, but just to be really clear: neither OpenQASM 2 nor OpenQASM 3 will ever be lossless serialisation formats for Qiskit, and to large part, cannot be without severely limiting the Qiskit data model, or requiring us to make huge amount of fragile guesses on re-import. We'll interoperate with them, but export to OpenQASM 3 is very much an export, and there's all sorts of things we have to do to map Qiskit's data model to OpenQASM's and back again. For example, the request in #12014, if it were implemented, could not be roundtripped through OQ because it's a naming conflict.

(The point being: "should be able to [losslessly] roundtrip a circuit" is not something the OQ import/export will ever be able to fully achieve.)

But can we agree on register names not changing at least? Especially since retrieving results now requires knowing the names.

commented

What is the python version and the operating system?

commented

We can certainly change the default here, but just to be really clear: neither OpenQASM 2 nor OpenQASM 3 will ever be lossless serialisation formats for Qiskit, and to large part, cannot be without severely limiting the Qiskit data model, or requiring us to make huge amount of fragile guesses on re-import. We'll interoperate with them, but export to OpenQASM 3 is very much an export, and there's all sorts of things we have to do to map Qiskit's data model to OpenQASM's and back again. For example, the request in #12014, if it were implemented, could not be roundtripped through OQ because it's a naming conflict.

(The point being: "should be able to [losslessly] roundtrip a circuit" is not something the OQ import/export will ever be able to fully achieve.)

I am not sure about the reasons for Open QASM2 and OPEN QASM3 being lossless serialisation formats for qiskit
It is difficult to losslessly roundtrip a circuit seems not necessarily plausible