You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RUN pip install --no-cache-dir qiskit==1.2.1
RUN pip install bqskit==1.2.0
Expected behavior
The circuit constructed with Qiskit should be successfully exported to a QASM file and then imported into Bqskit without any issues. The import process should recognize the delay gate and create a corresponding Bqskit circuit.
Actual behavior
The circuit constructed with Qiskit is successfully exported to a QASM file, but when trying to import it into Bqskit, a LangException is raised, indicating that the delay gate is not recognized.
Additional information
This issue is reproducible every time the code is run. The error occurs because Bqskit does not recognize the delay gate used in the Qiskit circuit. The QASM file generated by Qiskit contains the delay gate, which is not a standard gate in QASM.
Source code
Here a minimal example to reproduce the issue:
fromqiskitimportQuantumCircuitfromqiskitimportqasm2frombqskitimportCircuitfrompathlibimportPath# Section: Circuitcirc=QuantumCircuit(6, 6)
circ.delay(1, 4, 's')
# Export to QASM with Qiskitfile_path_qiskit='example_qiskit.qasm'qasm2.dump(circ, file_path_qiskit)
print(f'Saved the Qiskit circuit to {file_path_qiskit}')
# print file contentprint('File content:')
print(Path(file_path_qiskit).read_text())
# Import from QASM with Bqskitbqskit_circuit=Circuit.from_file(file_path_qiskit)
print(f'Circuit (bqskit) imported correctly: {file_path_qiskit}')
# Output:# Saved the Qiskit circuit to example_qiskit.qasm# File content:# OPENQASM 2.0;# include "qelib1.inc";# opaque delay(param0) q0;# qreg q[6];# creg c[6];# delay(1.0) q[4];
Tracebacks
Please include the error tracebacks related to the issue here. This will be automatically formatted into code, so no need for backticks.
---------------------------------------------------------------------------LangExceptionTraceback (mostrecentcalllast)
CellIn[2], line2017print(Path(file_path_qiskit).read_text())
19# Import from QASM with Bqskit--->20bqskit_circuit=Circuit.from_file(file_path_qiskit)
21print(f'Circuit (bqskit) imported correctly: {file_path_qiskit}')
File~//python3.10/site-packages/bqskit/ir/circuit.py:3258, inCircuit.from_file(filename)
3255language=get_language(filename.split('.')[-1])
3257withopen(filename) asf:
->3258returnlanguage.decode(f.read())
File~//python3.10/site-packages/bqskit/ir/lang/qasm2/qasm2.py:37, inOPENQASM2Language.decode(self, source)
35tree=parse(source)
36visitor=OPENQASMVisitor()
--->37visitor.visit_topdown(tree)
38returnvisitor.get_circuit()
File~//python3.10/site-packages/lark/visitors.py:375, inVisitor.visit_topdown(self, tree)
373"Visit the tree, starting at the root, and ending at the leaves (top-down)"374forsubtreeintree.iter_subtrees_topdown():
-->375self._call_userfunc(subtree)
376returntreeFile~//python3.10/site-packages/lark/visitors.py:347, inVisitorBase._call_userfunc(self, tree)
346def_call_userfunc(self, tree):
-->347returngetattr(self, tree.data, self.__default__)(tree)
File~//python3.10/site-packages/bqskit/ir/lang/qasm2/visitor.py:303, inOPENQASMVisitor.gate(self, tree)
301gate_def=self.custom_gate_defs[gate_name]
302else:
-->303raiseLangException('Unrecognized gate: %s.'%gate_name
Thanks in advance. Let me know if you need more information.
The text was updated successfully, but these errors were encountered:
Thank you for the bug report! We should look to support the delay gate in compilation and qasm reading and writing. However, I don't know exactly how that support would look. If anyone has potential use cases involving them and BQSKit, I would love to hear them.
System Information
Expected behavior
The circuit constructed with Qiskit should be successfully exported to a QASM file and then imported into Bqskit without any issues. The import process should recognize the delay gate and create a corresponding Bqskit circuit.
Actual behavior
The circuit constructed with Qiskit is successfully exported to a QASM file, but when trying to import it into Bqskit, a
LangException
is raised, indicating that thedelay
gate is not recognized.Additional information
This issue is reproducible every time the code is run. The error occurs because Bqskit does not recognize the
delay
gate used in the Qiskit circuit. The QASM file generated by Qiskit contains thedelay
gate, which is not a standard gate in QASM.Source code
Here a minimal example to reproduce the issue:
Tracebacks
Please include the error tracebacks related to the issue here. This will be automatically formatted into code, so no need for backticks.
Thanks in advance. Let me know if you need more information.
The text was updated successfully, but these errors were encountered: