119 lines
5.3 KiB
Plaintext
119 lines
5.3 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/stable/0.24/qiskit/transpiler/instruction_durations.py" signature="InstructionDurations(instruction_durations=None, dt=None)" modifiers="class">
|
||
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()`. 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
|
||
|
||
<span id="qiskit-transpiler-instructiondurations-from-backend" />
|
||
|
||
### from\_backend
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.from_backend" signature="InstructionDurations.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**](qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If dt and dtm is different in the backend.
|
||
</Function>
|
||
|
||
<span id="qiskit-transpiler-instructiondurations-get" />
|
||
|
||
### get
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.get" signature="InstructionDurations.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.
|
||
|
||
<Admonition title="Deprecated since version 0.19.0" type="danger">
|
||
Using a Qubit or List\[Qubit] for the `qubits` argument to InstructionDurations.get() is deprecated as of qiskit-terra 0.19.0. It will be removed no earlier than 3 months after the release date. Instead, use an integer for the qubit index.
|
||
</Admonition>
|
||
|
||
**Parameters**
|
||
|
||
* **inst** (*str |* [*Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) – An instruction or its name to be queried.
|
||
* **qubits** (*int | List\[int] |* [*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit") *| List\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.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’.
|
||
* **parameters** (*List\[float] | None*) – The value of the parameters of the desired instruction.
|
||
|
||
**Returns**
|
||
|
||
The duration of the instruction on the qubits.
|
||
|
||
**Return type**
|
||
|
||
float|int
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – No duration is defined for the instruction.
|
||
</Function>
|
||
|
||
<span id="qiskit-transpiler-instructiondurations-units-used" />
|
||
|
||
### units\_used
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.units_used" signature="InstructionDurations.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*\[str]
|
||
</Function>
|
||
|
||
<span id="qiskit-transpiler-instructiondurations-update" />
|
||
|
||
### update
|
||
|
||
<Function id="qiskit.transpiler.InstructionDurations.update" signature="InstructionDurations.update(inst_durations, dt=None)">
|
||
Update self with inst\_durations (inst\_durations overwrite self).
|
||
|
||
**Parameters**
|
||
|
||
* **inst\_durations** (*List\[Tuple\[str, Iterable\[int] | None, float, Iterable\[float] | None, str]] | List\[Tuple\[str, Iterable\[int] | None, float, Iterable\[float] | None]] | List\[Tuple\[str, Iterable\[int] | None, float, str]] | List\[Tuple\[str, Iterable\[int] | None, float]] |* [*InstructionDurations*](qiskit.transpiler.InstructionDurations "qiskit.transpiler.instruction_durations.InstructionDurations") *| None*) – Instruction durations to be merged into self (overwriting self).
|
||
* **dt** (*float | None*) – Sampling duration in seconds of the target backend.
|
||
|
||
**Returns**
|
||
|
||
The updated InstructionDurations.
|
||
|
||
**Return type**
|
||
|
||
[InstructionDurations](qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If the format of instruction\_durations is invalid.
|
||
</Function>
|
||
</Class>
|
||
|