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

Support reset operation in QASM importer #6704

Open
natestemen opened this issue Aug 19, 2024 · 5 comments
Open

Support reset operation in QASM importer #6704

natestemen opened this issue Aug 19, 2024 · 5 comments
Assignees
Labels
area/interop area/qasm kind/feature-request Describes new functionality triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@natestemen
Copy link

Is your feature request related to a use case or problem? Please describe.

We’ve encountered at least two cases where Mitiq users were unable to apply an error mitigation technique because their Qiskit circuits could not be converted to Cirq. Mitiq internally represents circuits as cirq.Circuit objects and relies on Cirq’s QASM importer for this conversion.

While I recognize that this might not be directly the responsibility of Cirq developers, I wanted to raise this issue for consideration. The QASM importer (#1548) was developed before the reset operation was introduced (#1774), so it’s possible that the reset operation was unintentionally omitted from the importer. It would be helpful to understand whether this is an area Cirq plans to address or if we should explore alternative workarounds.

Describe the solution you’d like

When converting a QASM circuit containing a reset operation, the resulting cirq.Circuit should include an instance of cirq.R to represent the reset operation.

[Optional] Additional context

Here’s a minimal reproducible example:

from cirq.contrib.qasm_import import circuit_from_qasm

circuit_from_qasm("""OPENQASM 2.0;
include "qelib1.inc";

qreg q[1];

reset q[0];
""")
@NoureldinYosri
Copy link
Collaborator

@pavoljuhas please take a look

@NoureldinYosri NoureldinYosri added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Aug 21, 2024
@rscircus
Copy link

@natestemen - having interest to support it. Am building the equivalent thing for us planning to cover QASMv3.

@NoureldinYosri NoureldinYosri added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 21, 2024
@rscircus
Copy link

rscircus commented Aug 21, 2024

what type of reset do you support? wait, preselection, some dissipative gate? any pointers for a starter?

Given:

Describe the solution you’d like

When converting a QASM circuit containing a reset operation, the resulting cirq.Circuit should include an instance of cirq.R to represent the reset operation.

This should be quick. I add the operation to the QasmParser and document it here.

@rscircus
Copy link

To me it looks like that reset is already somewhat prepared in the code. See:

./cirq-core/cirq/ops/common_channels.py -> class ResetChannel ln 704. At least it looks like they can export ResetChannels to QASM.

@rscircus
Copy link

@natestemen - I think #6710 should solve your issue. It's been an interesting exercise to get into PLY. Further, so far it has been rather academic. It surely needs some more testing in the wild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/interop area/qasm kind/feature-request Describes new functionality triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

No branches or pull requests

4 participants