107 lines
5.5 KiB
Plaintext
107 lines
5.5 KiB
Plaintext
---
|
||
title: InstructionDurations
|
||
description: API reference for qiskit.transpiler.InstructionDurations
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.transpiler.InstructionDurations
|
||
---
|
||
|
||
# InstructionDurations
|
||
|
||
<Class id="qiskit.transpiler.InstructionDurations" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/main/qiskit/transpiler/instruction_durations.py#L26-L268" signature="qiskit.transpiler.InstructionDurations(instruction_durations=None, dt=None)" modifiers="class">
|
||
Bases: [`object`](https://docs.python.org/3/library/functions.html#object "(in Python v3.12)")
|
||
|
||
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
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.from_backend" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/transpiler/instruction_durations.py#L65-L97" signature="from_backend(backend)" modifiers="classmethod">
|
||
Construct an [`InstructionDurations`](#qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations") object from the backend.
|
||
|
||
**Parameters**
|
||
|
||
**backend** ([*Backend*](qiskit.providers.Backend "qiskit.providers.backend.Backend")) – backend from which durations (gate lengths) and dt are extracted.
|
||
|
||
**Returns**
|
||
|
||
The InstructionDurations constructed from backend.
|
||
|
||
**Return type**
|
||
|
||
[InstructionDurations](#qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If dt and dtm is different in the backend.
|
||
</Function>
|
||
|
||
### get
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.get" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/transpiler/instruction_durations.py#L165-L206" signature="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**
|
||
|
||
* **inst** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)") *|*[*qiskit.circuit.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.Instruction")) – An instruction or its name to be queried.
|
||
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)") *|*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")*]*) – Qubit indices that the instruction acts on.
|
||
* **unit** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) – The unit of duration to be returned. It must be ‘s’ or ‘dt’.
|
||
* **parameters** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")*\[*[*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")*] | None*) – The value of the parameters of the desired instruction.
|
||
|
||
**Returns**
|
||
|
||
The duration of the instruction on the qubits.
|
||
|
||
**Return type**
|
||
|
||
[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")|[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – No duration is defined for the instruction.
|
||
</Function>
|
||
|
||
### units\_used
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.units_used" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/transpiler/instruction_durations.py#L257-L268" signature="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](https://docs.python.org/3/library/stdtypes.html#set "(in Python v3.12)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")]
|
||
</Function>
|
||
|
||
### update
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.update" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/transpiler/instruction_durations.py#L99-L163" signature="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*](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")) – Sampling duration in seconds of the target backend.
|
||
|
||
**Returns**
|
||
|
||
The updated InstructionDurations.
|
||
|
||
**Return type**
|
||
|
||
[InstructionDurations](#qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If the format of instruction\_durations is invalid.
|
||
</Function>
|
||
</Class>
|
||
|