Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions qiskit_ibm_runtime/qpy/binary_io/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ def _parse_custom_operation( # type: ignore[no-untyped-def]
base_gate = _read_instruction(
base_gate_obj, None, registers, custom_operations, version, vectors
)
if ctrl_state < 2**num_ctrl_qubits - 1:
# If open controls, we need to discard the control suffix when setting the name.
gate_name = gate_name.rsplit("_", 1)[0]
inst_obj = ControlledGate(
gate_name,
num_qubits,
Expand Down Expand Up @@ -549,7 +552,7 @@ def _write_instruction( # type: ignore[no-untyped-def]
has_condition = False
condition_register = b""
condition_value = 0
if instruction.operation.condition:
if getattr(instruction.operation, "condition", None):
has_condition = True
if isinstance(instruction.operation.condition[0], Clbit):
bit_index = index_map["c"][instruction.operation.condition[0]]
Expand Down Expand Up @@ -667,14 +670,21 @@ def _write_custom_operation( # type: ignore[no-untyped-def]
has_definition = True
data = common.data_to_binary(operation, _write_pauli_evolution_gate)
size = len(data)
elif operation.definition is not None:
elif type_key == type_keys.CircuitInstruction.CONTROLLED_GATE:
# For ControlledGate, we have to access and store the private `_definition` rather than the
# public one, because the public one is mutated to include additional logic if the control
# state is open, and the definition setter (during a subsequent read) uses the "fully
# excited" control definition only.
has_definition = True
data = common.data_to_binary(operation.definition, write_circuit)
data = common.data_to_binary(operation._definition, write_circuit)
size = len(data)
if type_key == type_keys.CircuitInstruction.CONTROLLED_GATE:
num_ctrl_qubits = operation.num_ctrl_qubits
ctrl_state = operation.ctrl_state
base_gate = operation.base_gate
elif operation.definition is not None:
has_definition = True
data = common.data_to_binary(operation.definition, write_circuit)
size = len(data)
if base_gate is None:
base_gate_raw = b""
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qiskit-terra>=0.21.1
qiskit-terra>=0.21.2
requests>=2.19
requests_ntlm>=1.1.0
numpy>=1.13
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import setuptools

REQUIREMENTS = [
"qiskit-terra>=0.21.1",
"qiskit-terra>=0.21.2",
"requests>=2.19",
"requests-ntlm>=1.1.0",
"numpy>=1.13",
Expand Down