-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Environment
- Qiskit version: 1.1.0
- Python version: 3.10.0
- Operating system: MacOS
What is happening?
The expected behavior of transpile
when a custom dt
is specified (i.e. sth like transpile(qc, backend=b, scheduling_method="asap", dt=dt / 2)
is that the scheduling stage will use this custom dt
instead of the backend's one, but this behavior is not respected if the input backend contains a target
. I believe that the root of the issue is that dt
is encoded in the inst_durations
object that is passed around, but the TimeUnitConversion
transformation pass is designed to overwrite inst_durations
if a target is specified, so the custom dt never gets to be used:
# TimeUnitConversion init
self.inst_durations = inst_durations or InstructionDurations()
if target is not None:
self.inst_durations = target.durations()
In other words, the priorities are not consistent between the preset passmanager/transpile and the TimeUnitConversion
pass (one prioritizes the custom durations, the other prioritizes the target).
How can we reproduce the issue?
This snippet works for the V1 backend and doesn't for the V2 backend:
from qiskit import QuantumCircuit
from qiskit import transpile
from qiskit_ibm_runtime.fake_provider import FakeHanoi, FakeHanoiV2
backend_v1 = FakeHanoi()
backend_v2 = FakeHanoiV2()
dt = 2.2222222222222221e-10
# from test_change_dt_in_transpile
qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)
for b in [backend_v1, backend_v2]:
# default case
scheduled = transpile(qc, backend=b, scheduling_method="asap")
org_duration = scheduled.duration
# halve dt in sec = double duration in dt
scheduled = transpile(
qc, backend=b, scheduling_method="asap", dt=dt / 2
)
print(b, scheduled.duration == org_duration * 2)
What should happen?
The custom dt shouldn't be bypassed.
Any suggestions?
I think that this issue could be fixed if we establish a consistent priority of the custom inst_durations
over the target's. A PR with a fix proposal will follow.