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

QASM2.0 is not preserved #1445

Open
pranavm1502 opened this issue May 27, 2022 · 2 comments
Open

QASM2.0 is not preserved #1445

pranavm1502 opened this issue May 27, 2022 · 2 comments
Labels
bug 🐛 An issue that needs fixing.

Comments

@pranavm1502
Copy link

pranavm1502 commented May 27, 2022

Pre-Report Checklist

  • [Yes] I am running the latest versions of pyQuil and the Forest SDK
  • [Yes] I checked to make sure that this bug has not already been reported

Issue Description

Converting a QASM2.0 circuit to native_quil does the not preserve the circuit. There are two obvious errors-

  1. It adds extraneous single qubit and multi-qubit gates
  2. It removed the Barrier on the three qubits before measuring.

How to Reproduce

If useful, provide a numbered list of the steps that result in the error.

Otherwise, just fill out the "Code Snippet" and "Error Output" sections below.

Code Snippet

new_qasm = """OPENQASM 2.0;
include "qelib1.inc";
qreg q[80];
creg c[2];
cz q[25],q[24];
cz q[23],q[24];
barrier q[25],q[23],q[24];
measure q[25] -> c[0];
measure q[23] -> c[1];
"""
program = pyquil.Program(RawInstr(new_qasm)).wrap_in_numshots_loop(shots)
qc.compiler.quil_to_native_quil(program).instructions

Error Output

[<DECLARE c>,
 <Gate CZ 25 24>,
 <Gate RZ(pi/2) 23>,
 <Gate RZ(pi) 24>,
 <Gate RX(pi/2) 24>,
 <Gate RZ(pi/2) 24>,
 <Gate RX(-pi/2) 24>,
 <Gate RZ(-pi) 24>,
 <Gate XY(pi) 23 24>,
 <Gate RX(pi/2) 23>,
 <Gate RZ(-pi/2) 23>,
 <Gate RX(-pi/2) 23>,
 <Gate XY(pi) 23 24>,
 <Gate RZ(-pi) 24>,
 <Gate RX(pi/2) 24>,
 <Gate RZ(pi/2) 24>,
 <Gate RX(-pi/2) 24>,
 <Gate RZ(-pi/2) 24>,
 <pyquil.quilbase.Measurement at 0x7f3ab82be650>,
 <pyquil.quilbase.Measurement at 0x7f3ab82be770>]

Environment Context

I am running this code on the QCS server.

Operating System:

Python Version (python -V):

Quilc Version (quilc --version):

QVM Version (qvm --version):

Python Environment Details (pip freeze or conda list):

Copy and paste the output of `pip freeze` or `conda list` here.
@dbanty
Copy link
Contributor

dbanty commented Jun 1, 2022

Just a note that since the conversion of QASM2.0 to Quil happens in quilc, that any fix is likely to be in quil-lang/quilc#823 . If there is anything specific you end up needing out of pyquil definitely let us know!

@pranavm1502
Copy link
Author

Hi @dbanty, the fix won't come from quilc. Looks like we need to modify the ISA in the QuantumComputer object generated by pyquil. qc.to_compiler_isa() gives the backend ISA but there is no method for changing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue that needs fixing.
Projects
None yet
Development

No branches or pull requests

2 participants