InstructionDurations
InstructionDurations(instruction_durations=None, dt=None)
Bases: object
Helper class to provide durations of instructions for scheduling.
It stores durations (gate lengths) and dt to be used at the scheduling stage of transpiling. It can be constructed from backend
or instruction_durations
, which is an argument of transpile()
.
Methods
from_backend
classmethod InstructionDurations.from_backend(backend)
Construct an InstructionDurations
object from the backend.
Parameters
backend (BaseBackend
) – backend from which durations (gate lengths) and dt are extracted.
Returns
The InstructionDurations constructed from backend.
Return type
Raises
TranspilerError – If dt and dtm is different in the backend.
get
InstructionDurations.get(inst, qubits, unit='dt')
Get the duration of the instruction with the name and the qubits.
Parameters
- inst (
Union
[str
,Instruction
]) – An instruction or its name to be queried. - qubits (
Union
[int
,List
[int
],Qubit
,List
[Qubit
]]) – Qubits or its indices that the instruction acts on. - unit (
str
) – The unit of duration to be returned. It must be ‘s’ or ‘dt’.
Returns
The duration of the instruction on the qubits.
Return type
float|int
Raises
TranspilerError – No duration is defined for the instruction.
units_used
InstructionDurations.units_used()
Get the set of all units used in this instruction durations.
Return type
Set
[str
]
Returns
Set of units used in this instruction durations.
update
InstructionDurations.update(inst_durations, dt=None)
Update self with inst_durations (inst_durations overwrite self).
Parameters
- inst_durations (
Optional
[Union
[List
[Tuple
[str
,Optional
[Iterable
[int
]],float
,str
]],List
[Tuple
[str
,Optional
[Iterable
[int
]],float
]],InstructionDurations
]]) – Instruction durations to be merged into self (overwriting self). - dt (
Optional
[float
]) – Sampling duration in seconds of the target backend.
Returns
The updated InstructionDurations.
Return type
Raises
TranspilerError – If the format of instruction_durations is invalid.