Skip to content

🐛 save_circuit (QASM3) generates invalid gate: parameter declared but not passed at call site #903

@J4MMlE

Description

@J4MMlE

System and Environment Information

  • OS: Linux (NixOS) - kernel 6.19.10-cachyos, x86_64
  • Python: 3.13.12
  • uv: 0.11.7
  • mqt-bench: 2.2.2
  • qiskit: 2.4.1

Bug Description

When using save_circuit(..., output_format=OutputFormat.QASM3) for the grover benchmark, the emitted QASM3 file contains a malformed gate definition that causes Qiskit to fail when loading the file.

  • Defined (line 1139): gate mcphase_0(_gate_p_0) _gate_q_0, _gate_q_1, ...
  • Called without parameter (line 1955): mcphase_0 _gate_q_0, _gate_q_1, ...

Steps to Reproduce

minimal script to reproduce:

from pathlib import Path
from mqt.bench import BenchmarkLevel, get_benchmark
from mqt.bench.output import OutputFormat, save_circuit
from qiskit.qasm3 import load

OUT = Path("grover_10.qasm")

# Step 1: generate the benchmark and export to QASM3
qc = get_benchmark(benchmark="grover", level=BenchmarkLevel.ALG, circuit_size=10)
save_circuit(
    qc, str(OUT.with_suffix("")), BenchmarkLevel.ALG, output_format=OutputFormat.QASM3
)

# Step 2: attempt to load - this fails
try:
    load(OUT)
except Exception as e:
    print(f"Qiskit load fails:\n  {type(e).__name__}: {e}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions