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

Loading a circuit from a QASM file created from a QuantumVolume circuit fails. #6466

Closed
adekusar-drl opened this issue May 26, 2021 · 3 comments · Fixed by #9953
Closed

Loading a circuit from a QASM file created from a QuantumVolume circuit fails. #6466

adekusar-drl opened this issue May 26, 2021 · 3 comments · Fixed by #9953
Labels
bug Something isn't working

Comments

@adekusar-drl
Copy link
Contributor

Information

  • Qiskit Terra version: latest sources
  • Python version: 3.7
  • Operating system: all

What is the current behavior?

There's an exception when an instance of QuantumVolume circuit is saved as a qasm file and then loaded from this file.

Steps to reproduce the problem

Run the script:

from qiskit import QuantumCircuit
from qiskit.circuit.library import QuantumVolume

if __name__ == '__main__':
    qc = QuantumVolume(num_qubits=3)
    qc.qasm(filename="qv.qasm")
    loaded_qc = QuantumCircuit.from_qasm_file("qv.qasm")

There's an exception:

.../envs/dev-terra/python.exe .../qiskit-terra/_sandbox/qv.py
Traceback (most recent call last):
  File ".../qiskit-terra/_sandbox/qv.py", line 12, in <module>
    loaded_qc = QuantumCircuit.from_qasm_file("qv.qasm")
  File ".../qiskit-terra/qiskit/circuit/quantumcircuit.py", line 2056, in from_qasm_file
Error near line 3 Column 15
    return _circuit_from_qasm(qasm)
  File ".../qiskit-terra/qiskit/circuit/quantumcircuit.py", line 3003, in _circuit_from_qasm
    ast = qasm.parse()
  File ".../qiskit-terra/qiskit/qasm/qasm.py", line 53, in parse
    return qasm_p.parse(self._data)
  File ".../qiskit-terra/qiskit/qasm/qasmparser.py", line 1141, in parse
    self.parser.parse(data, lexer=self.lexer, debug=self.parse_deb)
  File ".../envs/dev-terra/lib/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File ".../envs/dev-terra/lib/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File ".../qiskit-terra/qiskit/qasm/qasmparser.py", line 400, in p_id_e
    raise QasmError("Expected an ID, received '" + str(program[1].value) + "'")
qiskit.qasm.exceptions.QasmError: "Expected an ID, received '['"

What is the expected behavior?

No exceptions to be raisen.

@adekusar-drl adekusar-drl added the bug Something isn't working label May 26, 2021
@singhmeet11
Copy link
Contributor

Hi, can I work on this issue?

@adekusar-drl
Copy link
Contributor Author

I don't mind, but I'm not in the development team :)

@singhmeet11
Copy link
Contributor

I took a look at the issue and I am having a hard time and something came up, so if anyone is up to the task go ahead.

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

Successfully merging a pull request may close this issue.

2 participants