Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

InstructionDurations

qiskit.transpiler.InstructionDurations(instruction_durations=None, dt=None)

GitHub(opens in a new tab)

Bases: object(opens in a new tab)

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(). The duration of an instruction depends on the instruction (given by name), the qubits, and optionally the parameters of the instruction. Note that these fields are used as keys in dictionaries that are used to retrieve the instruction durations. Therefore, users must use the exact same parameter value to retrieve an instruction duration as the value with which it was added.


Methods

from_backend

classmethod from_backend(backend)

Construct an InstructionDurations object from the backend.

Parameters

backend (Backend) – backend from which durations (gate lengths) and dt are extracted.

Returns

The InstructionDurations constructed from backend.

Return type

InstructionDurations

Raises

TranspilerError – If dt and dtm is different in the backend.

get

get(inst, qubits, unit='dt', parameters=None)

Get the duration of the instruction with the name, qubits, and parameters.

Some instructions may have a parameter dependent duration.

Parameters

Returns

The duration of the instruction on the qubits.

Return type

float(opens in a new tab)|int(opens in a new tab)

Raises

TranspilerError – No duration is defined for the instruction.

units_used

units_used()

Get the set of all units used in this instruction durations.

Returns

Set of units used in this instruction durations.

Return type

set(opens in a new tab)[str(opens in a new tab)]

update

update(inst_durations, dt=None)

Update self with inst_durations (inst_durations overwrite self).

Parameters

  • inst_durations ('InstructionDurationsType' | None) – Instruction durations to be merged into self (overwriting self).
  • dt (float(opens in a new tab)) – Sampling duration in seconds of the target backend.

Returns

The updated InstructionDurations.

Return type

InstructionDurations

Raises

TranspilerError – If the format of instruction_durations is invalid.

Was this page helpful?
Report a bug or request content on GitHub.