-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Qiskit version: 1.4.0
- Python version: 3.12.9
- Operating system: Mac M1
What is happening?
I saved a quantum circuit containing qiskit.circuit.library.MCMTGate
using qpy
. The following error happened when I had attempted to load the saved quantum circuit.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[9], line 2
1 with open(circuit_path, "rb") as circuit_file:
----> 2 qc = qpy.load(circuit_file)
3 qc
File /opt/homebrew/Caskroom/miniforge/base/envs/qsvm/lib/python3.12/site-packages/qiskit/qpy/interface.py:370, in load(file_obj, metadata_deserializer)
367 programs = []
368 for _ in range(data.num_programs):
369 programs.append(
--> 370 loader(
371 file_obj,
372 data.qpy_version,
373 metadata_deserializer=metadata_deserializer,
374 use_symengine=use_symengine,
375 )
376 )
377 return programs
File /opt/homebrew/Caskroom/miniforge/base/envs/qsvm/lib/python3.12/site-packages/qiskit/qpy/binary_io/circuits.py:1443, in read_circuit(file_obj, version, metadata_deserializer, use_symengine)
1441 custom_operations = _read_custom_operations(file_obj, version, vectors)
1442 for _instruction in range(num_instructions):
-> 1443 _read_instruction(
1444 file_obj,
1445 circ,
1446 out_registers,
1447 custom_operations,
1448 version,
1449 vectors,
1450 use_symengine,
1451 standalone_var_indices,
1452 )
1454 # Read calibrations
1455 if version >= 5:
File /opt/homebrew/Caskroom/miniforge/base/envs/qsvm/lib/python3.12/site-packages/qiskit/qpy/binary_io/circuits.py:379, in _read_instruction(file_obj, circuit, registers, custom_operations, version, vectors, use_symengine, standalone_vars)
377 gate = gate_class(*params, instruction.num_ctrl_qubits, label=label)
378 else:
--> 379 gate = gate_class(*params, label=label)
380 if (
381 gate.num_ctrl_qubits != instruction.num_ctrl_qubits
382 or gate.ctrl_state != instruction.ctrl_state
383 ):
384 gate = gate.to_mutable()
TypeError: MCMTGate.__init__() missing 3 required positional arguments: 'gate', 'num_ctrl_qubits', and 'num_target_qubits'
How can we reproduce the issue?
qc = qiskit.QuantumCircuit(3)
qc.compose(qiskit.circuit.library.MCMTGate(qiskit.circuit.library.ZGate(), 2, 1), inplace=True)
circuit_path = "circuit.qpy"
with open(circuit_path, "wb") as circuit_file:
qpy.dump(qc, circuit_file)
with open(circuit_path, "rb") as circuit_file:
qc = qpy.load(circuit_file)
What should happen?
The saved quantum circuit should be loaded without any error.
Any suggestions?
It seems like this issue relates to #9390 for me?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working