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
The issue arises due to the way Qiskit handles control flow structures like for_loop when applying transpilation passes. Specifically, the for_loop construct internally stores a new QuantumCircuit object that does not retain the physical qubit mapping intended for the calibrated custom gate (as defined in the backend target object).
When the transpilation pipeline reaches the HighLevelSynthesis pass, the method _definitely_skip_node should return True if the gate already has a valid calibration. However, it does not because the physical qubits referenced in the circuit structure do not align with those recorded in the initial_layout during pass execution.
How can we reproduce the issue?
`from qiskit.circuit import QuantumCircuit, ParameterVector, Gate, Parameter
from qiskit import pulse, schedule, transpile
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler import InstructionProperties, generate_preset_pass_manager, CouplingMap
params = [Parameter(f'a_{i}') for i in range(2)]
qc = QuantumCircuit(2)
ecr_cal = Gate(name='ecr_cal', num_qubits=2, params=params)
qc_loop = QuantumCircuit(2)
qc.append(ecr_cal, [0, 1])
with qc_loop.for_loop([0, 3]) as i:
qc_loop.compose(qc, inplace=True)
The transpilation process should correctly recognize that the ecr_cal gate, mapped to physical qubits (3,4), already has a calibration, and avoid unnecessary synthesis steps.
Instead of skipping synthesis, the transpiler does not identify the calibration, likely due to the for_loop internally storing logical qubit indices instead of physical qubits.
Any suggestions?
A potential solution could involve ensuring that physical qubit mappings are correctly maintained within control flow constructs, or updating the handling of control flow operations within transpilation passes to correctly propagate the intended qubit mappings.
The text was updated successfully, but these errors were encountered:
Environment
What is happening?
The issue arises due to the way Qiskit handles control flow structures like for_loop when applying transpilation passes. Specifically, the for_loop construct internally stores a new QuantumCircuit object that does not retain the physical qubit mapping intended for the calibrated custom gate (as defined in the backend target object).
When the transpilation pipeline reaches the HighLevelSynthesis pass, the method _definitely_skip_node should return True if the gate already has a valid calibration. However, it does not because the physical qubits referenced in the circuit structure do not align with those recorded in the initial_layout during pass execution.
How can we reproduce the issue?
`from qiskit.circuit import QuantumCircuit, ParameterVector, Gate, Parameter
from qiskit import pulse, schedule, transpile
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler import InstructionProperties, generate_preset_pass_manager, CouplingMap
params = [Parameter(f'a_{i}') for i in range(2)]
qc = QuantumCircuit(2)
ecr_cal = Gate(name='ecr_cal', num_qubits=2, params=params)
qc_loop = QuantumCircuit(2)
qc.append(ecr_cal, [0, 1])
with qc_loop.for_loop([0, 3]) as i:
qc_loop.compose(qc, inplace=True)
backend = GenericBackendV2(num_qubits=4,
basis_gates=["x", "sx", "ecr", "rz", "measure", "reset"],
coupling_map=CouplingMap.from_full(4),
calibrate_instructions=True,
control_flow=True)
with pulse.build(backend, name="custom_sched") as custom_sched:
pulse.play(pulse.Constant(100, params[0]), pulse.DriveChannel(3))
pulse.play(pulse.Constant(100, params[1]), pulse.DriveChannel(4))
backend.target.add_instruction(ecr_cal, properties={(3,4): InstructionProperties(calibration=custom_sched)})
pm = generate_preset_pass_manager(optimization_level=1,
backend=backend,
initial_layout=(3,4))
transpiled_circ = pm.run(qc_loop)
transpiled_circ.draw('mpl')`
What should happen?
The transpilation process should correctly recognize that the ecr_cal gate, mapped to physical qubits (3,4), already has a calibration, and avoid unnecessary synthesis steps.
Instead of skipping synthesis, the transpiler does not identify the calibration, likely due to the for_loop internally storing logical qubit indices instead of physical qubits.
Any suggestions?
A potential solution could involve ensuring that physical qubit mappings are correctly maintained within control flow constructs, or updating the handling of control flow operations within transpilation passes to correctly propagate the intended qubit mappings.
The text was updated successfully, but these errors were encountered: