qiskit-documentation/docs/api/qiskit/1.2/qiskit.pulse.InstructionSch...

220 lines
14 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: InstructionScheduleMap (v1.2)
description: API reference for qiskit.pulse.InstructionScheduleMap in qiskit v1.2
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.pulse.InstructionScheduleMap
---
# InstructionScheduleMap
<Class id="qiskit.pulse.InstructionScheduleMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L51-L382" signature="qiskit.pulse.InstructionScheduleMap" modifiers="class">
Bases: [`object`](https://docs.python.org/3/library/functions.html#object "(in Python v3.13)")
Mapping from [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") [`qiskit.circuit.Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") names and qubits to [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") s. In particular, the mapping is formatted as type:
```python
Dict[str, Dict[Tuple[int], Schedule]]
```
where the first key is the name of a circuit instruction (e.g. `'u1'`, `'measure'`), the second key is a tuple of qubit indices, and the final value is a Schedule implementing the requested instruction.
These can usually be seen as gate calibrations.
Initialize a circuit instruction to schedule mapper instance.
## Attributes
### instructions
<Attribute id="qiskit.pulse.InstructionScheduleMap.instructions">
Return all instructions which have definitions.
By default, these are typically the basis gates along with other instructions such as measure and reset.
**Returns**
The names of all the circuit instructions which have Schedule definitions in this.
</Attribute>
## Methods
### add
<Function id="qiskit.pulse.InstructionScheduleMap.add" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L226-L271" signature="add(instruction, qubits, schedule, arguments=None)">
Add a new known instruction for the given qubits and its mapping to a pulse schedule.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) The name of the instruction to add.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubits which the instruction applies to.
* **schedule** ([*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule") *|*[*ScheduleBlock*](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock") *| Callable\[...,*[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule") *|*[*ScheduleBlock*](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock")*]*) The Schedule that implements the given instruction.
* **arguments** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")*] | None*) List of parameter names to create a parameter-bound schedule from the associated gate instruction. If [`get()`](#qiskit.pulse.InstructionScheduleMap.get "qiskit.pulse.InstructionScheduleMap.get") is called with arguments rather than keyword arguments, this parameter list is used to map the input arguments to parameter objects stored in the target schedule.
**Raises**
[**PulseError**](pulse#qiskit.pulse.PulseError "qiskit.pulse.PulseError") If the qubits are provided as an empty iterable.
</Function>
### assert\_has
<Function id="qiskit.pulse.InstructionScheduleMap.assert_has" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L156-L175" signature="assert_has(instruction, qubits)">
Error if the given instruction is not defined.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) The instruction for which to look.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The specific qubits for the instruction.
**Raises**
[**PulseError**](pulse#qiskit.pulse.PulseError "qiskit.pulse.PulseError") If the instruction is not defined on the qubits.
</Function>
### get
<Function id="qiskit.pulse.InstructionScheduleMap.get" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L177-L198" signature="get(instruction, qubits, *params, **kwparams)">
Return the defined [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") or [`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock") for the given instruction on the given qubits.
If all keys are not specified this method returns schedule with unbound parameters.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) Name of the instruction or the instruction itself.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubits for the instruction.
* **\*params** ([*complex*](https://docs.python.org/3/library/functions.html#complex "(in Python v3.13)") *|*[*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")) Command parameters for generating the output schedule.
* **\*\*kwparams** ([*complex*](https://docs.python.org/3/library/functions.html#complex "(in Python v3.13)") *|*[*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")) Keyworded command parameters for generating the schedule.
**Returns**
The Schedule defined for the input.
**Return type**
[Schedule](qiskit.pulse.Schedule "qiskit.pulse.Schedule") | [ScheduleBlock](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock")
</Function>
### get\_parameters
<Function id="qiskit.pulse.InstructionScheduleMap.get_parameters" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L342-L358" signature="get_parameters(instruction, qubits)">
Return the list of parameters taken by the given instruction on the given qubits.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) Name of the instruction.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubits for the instruction.
**Returns**
The names of the parameters required by the instruction.
**Return type**
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)"), …]
</Function>
### has
<Function id="qiskit.pulse.InstructionScheduleMap.has" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L141-L154" signature="has(instruction, qubits)">
Is the instruction defined for the given qubits?
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) The instruction for which to look.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The specific qubits for the instruction.
**Returns**
True iff the instruction is defined.
**Return type**
[bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")
</Function>
### has\_custom\_gate
<Function id="qiskit.pulse.InstructionScheduleMap.has_custom_gate" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L79-L85" signature="has_custom_gate()">
Return `True` if the map has user provided instruction.
**Return type**
[bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")
</Function>
### pop
<Function id="qiskit.pulse.InstructionScheduleMap.pop" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L318-L340" signature="pop(instruction, qubits, *params, **kwparams)">
Remove and return the defined schedule for the given instruction on the given qubits.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) Name of the instruction.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubits for the instruction.
* **\*params** ([*complex*](https://docs.python.org/3/library/functions.html#complex "(in Python v3.13)") *|*[*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")) Command parameters for generating the output schedule.
* **\*\*kwparams** ([*complex*](https://docs.python.org/3/library/functions.html#complex "(in Python v3.13)") *|*[*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")) Keyworded command parameters for generating the schedule.
**Returns**
The Schedule defined for the input.
**Return type**
[Schedule](qiskit.pulse.Schedule "qiskit.pulse.Schedule") | [ScheduleBlock](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock")
</Function>
### qubit\_instructions
<Function id="qiskit.pulse.InstructionScheduleMap.qubit_instructions" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L124-L139" signature="qubit_instructions(qubits)">
Return a list of the instruction names that are defined by the backend for the given qubit or qubits.
**Parameters**
**qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) A qubit index, or a list or tuple of indices.
**Returns**
All the instructions which are defined on the qubits.
For 1 qubit, all the 1Q instructions defined. For multiple qubits, all the instructions which apply to that whole set of qubits (e.g. `qubits=[0, 1]` may return `['cx']`).
**Return type**
[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")]
</Function>
### qubits\_with\_instruction
<Function id="qiskit.pulse.InstructionScheduleMap.qubits_with_instruction" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L99-L122" signature="qubits_with_instruction(instruction)">
Return a list of the qubits for which the given instruction is defined. Single qubit instructions return a flat list, and multiqubit instructions return a list of ordered tuples.
**Parameters**
**instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) The name of the circuit instruction.
**Returns**
Qubit indices which have the given instruction defined. This is a list of tuples if the instruction has an arity greater than 1, or a flat list of ints otherwise.
**Raises**
[**PulseError**](pulse#qiskit.pulse.PulseError "qiskit.pulse.PulseError") If the instruction is not found.
**Return type**
[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")\[[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)"), …]]
</Function>
### remove
<Function id="qiskit.pulse.InstructionScheduleMap.remove" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/pulse/instruction_schedule_map.py#L297-L316" signature="remove(instruction, qubits)">
Remove the given instruction from the listing of instructions defined in self.
**Parameters**
* **instruction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*circuit.instruction.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")) The name of the instruction to add.
* **qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| Iterable\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubits which the instruction applies to.
</Function>
</Class>