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

delay not recognized by qasm parser #188

Closed
Zhaoyilunnn opened this issue Aug 20, 2024 · 0 comments
Closed

delay not recognized by qasm parser #188

Zhaoyilunnn opened this issue Aug 20, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Zhaoyilunnn
Copy link
Collaborator

Zhaoyilunnn commented Aug 20, 2024

Test file

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
ry(0.6283185307179586) q[2];
delay(300) q[2];
ry(-0.6283185307179586) q[2];
measure q[2]->meas[0];

Test code

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
ry(0.6283185307179586) q[2];
delay(300) q[2];
ry(-0.6283185307179586) q[2];
measure q[2]->c[0]
(quafu-dev) root@dell:~/projects/forks/pyquafu# cat test.py
from quafu import QuantumCircuit

qc = QuantumCircuit(1)

with open("./test.qasm", "r") as f:
    qc.from_openqasm(f.read())

Error

Traceback (most recent call last):
  File "/root/projects/forks/pyquafu/test.py", line 6, in <module>
    qc.from_openqasm(f.read())
  File "/root/projects/forks/pyquafu/quafu/circuits/quantum_circuit.py", line 499, in from_openqasm
    return qasm2_to_quafu_qc(self, openqasm)
  File "/root/projects/forks/pyquafu/quafu/qfasm/qfasm_convertor.py", line 47, in qasm2_to_quafu_qc
    newqc = qparser.parse(openqasm)
  File "/root/projects/forks/pyquafu/quafu/qfasm/qfasm_parser.py", line 114, in parse
    self.parser.parse(data, lexer=self.lexer, debug=debug)
  File "/root/anaconda3/envs/quafu-dev/lib/python3.10/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/root/anaconda3/envs/quafu-dev/lib/python3.10/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File "/root/projects/forks/pyquafu/quafu/qfasm/qfasm_parser.py", line 701, in p_unitaryop
    self.check_qargs(p[0])
  File "/root/projects/forks/pyquafu/quafu/qfasm/qfasm_parser.py", line 396, in check_qargs
    raise ParserError(
quafu.qfasm.exceptions.ParserError: The gate delay is undefined at line 6 file None
@Zhaoyilunnn Zhaoyilunnn added the bug Something isn't working label Aug 20, 2024
@Zhaoyilunnn Zhaoyilunnn self-assigned this Aug 20, 2024
ScQ-Cloud added a commit that referenced this issue Aug 25, 2024
fix(qfasm): parse delay close #188
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

1 participant