Skip to content

csdg roundtrip in OpenQASM 2 broken #9559

@ryanhill1

Description

@ryanhill1

Environment

  • Qiskit Terra version: 0.23.1
  • Python version: 3.9.15
  • Operating system: macOS Ventura

What is happening?

Qiskit supports the CSdgGate, but raises error when creating a circuit from a qasm file that includes a csdg gate. Issue may exist for other gates as well, but so far this is the only one I've identified.

How can we reproduce the issue?

import os
from qiskit import QuantumCircuit

workdir = os.path.dirname(__file__)
qasm_file = os.path.join(workdir, "test.qasm")

circuit = QuantumCircuit(2)
circuit.csdg(0, 1)

qasm_str = circuit.qasm()

with open(qasm_file, "w") as f:
    f.write(qasm_str)

new_circuit = QuantumCircuit().from_qasm_file(qasm_file)

print(new_circuit)
Traceback (most recent call last):
...
 ...
  File ".../lib/python3.9/site-packages/qiskit/qasm/qasmparser.py", line 138, in verify_as_gate
    raise QasmError(
qiskit.qasm.exceptions.QasmError: "Cannot find gate definition for 'csdg', line 4 file line 4 file test.qasm"

What should happen?

Program should print out new circuit without error

Screenshot 2023-02-08 at 11 09 51 PM

Any suggestions?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions