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

Incorrect Numeric Expression Syntax in QASM Export #6550

Open
p51lee opened this issue Apr 5, 2024 · 2 comments
Open

Incorrect Numeric Expression Syntax in QASM Export #6550

p51lee opened this issue Apr 5, 2024 · 2 comments
Labels
kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@p51lee
Copy link

p51lee commented Apr 5, 2024

Description of the issue

image

The to_qasm method exports numeric expressions in a format not fully compliant with the OpenQASM 2.0 specification. Expressions like 1e-10 are outputted without a leading digit or dot, which could lead to syntax errors in strict OpenQASM parsers.

How to reproduce the issue

import math

cirq_circuit = cirq.Circuit()
a = cirq.NamedQubit("a")
cirq_circuit.append([cirq.Rz(rads=math.pi * 1e-10)(a)])
print(cirq_circuit.to_qasm())

Result

// Generated from Cirq v1.3.0

OPENQASM 2.0;
include "qelib1.inc";


// Qubits: [a]
qreg q[1];


rz(pi*1e-10) q[0];  // invalid syntax (expected: 1.e-10 or 1.0e-10)

Cirq version
1.3.0

@p51lee p51lee added the kind/bug-report Something doesn't seem to work. label Apr 5, 2024
@pavoljuhas pavoljuhas added the triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add label Apr 24, 2024
@verult
Copy link
Collaborator

verult commented Apr 24, 2024

From the Cirq Cync: we're planning to drop support for OpenQASM 2 and move to OpenQASM 3. Does the same issue apply in the new version?

@p51lee
Copy link
Author

p51lee commented Apr 25, 2024

I'm working with the latest version and to_qasm method gives OpenQASM 2 code. Is there a parameter or a different method available that I should use to obtain OpenQASM 3 code instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-report Something doesn't seem to work. 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

3 participants