Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nonhermitian opened this issue May 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@nonhermitian
Copy link
Contributor

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?

@nonhermitian nonhermitian added the bug Something isn't working label May 5, 2024
@nonhermitian nonhermitian changed the title measure_active returns register called "measure" which breaks round trippinmg in QASM measure_active returns register called "measure" which breaks round tripping in QASM May 5, 2024
@1ucian0
Copy link
Member

1ucian0 commented May 7, 2024

The suggestion seems related to #12192

@jakelishman
Copy link
Member

jakelishman commented May 7, 2024

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.)

@nonhermitian
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants