question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QuantumVolume QASM circuit error

See original GitHub issue

Information

  • Qiskit Terra version: qiskit-terra==0.18.1
  • Python version: 3.7.3
  • Operating system: macOS Mojave

What is the current behavior?

The method QuantumVolume at qiskit.circuit.library.quantum_volume can be used to generate quantum volume circuits. Some of the circuits generated by this method throw an error when they are saved as a QASM file, and then read in using QuantumCircuit.from_qasm_file(path)

Steps to reproduce the problem

This circuit:

was generated using the qiskit.circuit.library.quantum_volume method. When I run this code:

from qiskit import QuantumCircuit

qc = QuantumCircuit.from_qasm_file("qasm_error_circuit.txt")

I get the error

    qc = QuantumCircuit.from_qasm_file("qasm_error_circuit.txt")
  File "//anaconda3/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py", line 1900, in from_qasm_file
    return _circuit_from_qasm(qasm)
  File "//anaconda3/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py", line 2733, in _circuit_from_qasm
    ast = qasm.parse()
  File "//anaconda3/lib/python3.7/site-packages/qiskit/qasm/qasm.py", line 54, in parse
    return qasm_p.parse(self._data)
  File "//anaconda3/lib/python3.7/site-packages/qiskit/qasm/qasmparser.py", line 1070, in parse
    self.parser.parse(data, lexer=self.lexer, debug=self.parse_deb)
  File "//anaconda3/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "//anaconda3/lib/python3.7/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File "//anaconda3/lib/python3.7/site-packages/qiskit/qasm/qasmparser.py", line 525, in p_gate_decl_0
    self.update_symtab(program[0])
  File "//anaconda3/lib/python3.7/site-packages/qiskit/qasm/qasmparser.py", line 77, in update_symtab
    str(prev.line) + ', file', prev.file)
qiskit.qasm.exceptions.QasmError: "Duplicate declaration for gate 'su4_976' at line 88, file qasm_error_circuit.txt.\nPrevious occurrence at line 18, file qasm_error_circuit.txt"

What is the expected behavior?

Suggested solutions

Naming each su4 declaration with additional unique numbers so there are no duplicates.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
epelofske-LANLcommented, Sep 28, 2021

I suspect your environment might have gone wrong somewhere, and a Terra from the 0.17 series or earlier has ended up on the path by accident, which is before #5887 was merged to fix many of these problems.

@jakelishman Yes, that is the problem. According to pip I have qiskit-terra==0.18.1 installed, but the actual version I am using is 0.17.0:

>>> import qiskit
>>> print(qiskit.__file__)
//anaconda3/lib/python3.7/site-packages/qiskit/__init__.py
>>> print(qiskit.__version__)
0.17.0
0reactions
jakelishmancommented, Sep 28, 2021

Ah, that’s good to know! Thanks - bugs are always super scary when we can’t reproduce them, so good to know the cause in the end.

In general, conda and pip play a little weirdly together. When you’re using packages from both at once, conda list is typically a little more reliable than pip list, because conda knows how to read pip’s status, but it doesn’t really work the other way around.

Read more comments on GitHub >

github_iconTop Results From Across the Web

QasmError when parsing quantum volume qc.qasm() #3066
If you pass a quantum volume circuit's qc.qasm() into qc.from_qasm_str, which calls qiskit's qasm parser, throws a QasmError. The same error ...
Read more >
API error codes - IBM Quantum
Split the circuits in smaller jobs. 1002. Error in the ... Error during the validation process of a job. Retry the action. ......
Read more >
Re-examining the quantum volume test: Ideal distributions ...
The quantum volume test is a full- system benchmark for quantum comput- ers that is sensitive to qubit number, fi- delity, connectivity, and...
Read more >
qiskit - QV circuits fail to execute in real devices
IBMQBackend.run() method now takes one or more QuantumCircuit or Schedule . Use of QasmQobj and PulseQobj is now deprecated.
Read more >
What Is Quantum Volume, Anyway? - Medium
You use the qasm simulator to determine what the heavy outputs are. You run the circuit again on a quantum computer (or a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found