---
title: QiskitGate (latest version)
description: API reference for qiskit_noise_learning.gate_sets.QiskitGate in the latest version of qiskit-noise-learning
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate
---

# qiskit\_noise\_learning.gate\_sets.QiskitGate

*class* `qiskit_noise_learning.gate_sets.QiskitGate(name: str, circuit: QuantumCircuit, qubit_idxs: Iterable[int], prep_idxs: Iterable[int] = (), annotations: Sequence[Annotation] | None = None, latex_str: str | None = None)`

[GitHub](https://github.com/Qiskit/qiskit-noise-learning/tree/stable/0.1/qiskit_noise_learning/gate_sets/qiskit_gate.py)

Bases: [`Gate`](/docs/api/qiskit-noise-learning/generated/gate-sets-gate "qiskit_noise_learning.gate_sets.gate.Gate")

Represents a single gate in a [`QiskitGateSet`](/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set "qiskit_noise_learning.gate_sets.QiskitGateSet").

It is assumed that the gate consists of a sequence of unitary operations, followed by measurements, with no qubit being measured more than once, and finally preparations or resets. This is not currently validated.

In many ways, this class is similar to a [`CircuitInstruction`](/docs/api/qiskit/qiskit.circuit.CircuitInstruction) containing a [`BoxOp`](/docs/api/qiskit/qiskit.circuit.BoxOp) in that it represents the action on some subset of qubits, and possibly with some of those qubits idling. It differs in that the physical qubits are represented as integers rather than [`Qubit`](/docs/api/qiskit/circuit#qiskit.circuit.Qubit) objects, and that we explicitly store which physical qubit indices perform preparation (or reset) operations.

This class also implements the equality operation, where two [`QiskitGate`](#qiskit_noise_learning.gate_sets.QiskitGate "qiskit_noise_learning.gate_sets.QiskitGate") instances are equal whenever their physical indices are equal, and their circuits are equal taking into account permutations of the lists `qubit_idxs` and `circuit.qubits`.

**Parameters**

- **name** – The name for the gate.
- **circuit** – The quantum circuit.
- **qubit\_idxs** – The physical qubit indices that `circuit.qubits` act on.
- **prep\_idxs** – The physical qubit indices that this gate prepares, or resets. This is included because explicitly using the `Reset` instruction is not common.
- **annotations** – The annotations that describe how to implement the gate. If `None`, this defaults to Pauli twirling. If no `samplomatic.Tag` annotation is provided, then one is added automatically whose tag name is equal to `name`.
- **latex\_str** – An optional LaTeX string for this gate.

### \_\_init\_\_

`__init__(name: str, circuit: QuantumCircuit, qubit_idxs: Iterable[int], prep_idxs: Iterable[int] = (), annotations: Sequence[Annotation] | None = None, latex_str: str | None = None)`

## Methods

|                                                                                                                                                              |                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
| [`__init__`](#qiskit_noise_learning.gate_sets.QiskitGate.__init__ "qiskit_noise_learning.gate_sets.QiskitGate.__init__")(name, circuit, qubit\_idxs\[, ...]) |                                                                         |
| [`draw`](#qiskit_noise_learning.gate_sets.QiskitGate.draw "qiskit_noise_learning.gate_sets.QiskitGate.draw")(\*args, \*\*kwargs)                             | Draw this gate as a circuit diagram.                                    |
| [`iter_ops`](#qiskit_noise_learning.gate_sets.QiskitGate.iter_ops "qiskit_noise_learning.gate_sets.QiskitGate.iter_ops")()                                   | Iterate through the operations that compose this gate in circuit order. |

## Attributes

|                                                                                                                                                                 |                                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [`annotations`](#qiskit_noise_learning.gate_sets.QiskitGate.annotations "qiskit_noise_learning.gate_sets.QiskitGate.annotations")                               | The annotations to use with this gate.                                             |
| [`circuit`](#qiskit_noise_learning.gate_sets.QiskitGate.circuit "qiskit_noise_learning.gate_sets.QiskitGate.circuit")                                           | A circuit representation of this gate.                                             |
| [`constituent_gate_idxs`](#qiskit_noise_learning.gate_sets.QiskitGate.constituent_gate_idxs "qiskit_noise_learning.gate_sets.QiskitGate.constituent_gate_idxs") | Iterator over tuples of physical indices that specify where constituent gates act. |
| `gate_idxs`                                                                                                                                                     | The physical indices where this gate undergoes unitary action.                     |
| `idling_idxs`                                                                                                                                                   | The physical qubit indices that this gate is idling on.                            |
| `label`                                                                                                                                                         | A string label for use in plotter legends.                                         |
| `latex_str`                                                                                                                                                     | A LaTeX string for this gate.                                                      |
| `math_label`                                                                                                                                                    | A string label for use within latex math mode.                                     |
| `meas_idxs`                                                                                                                                                     | The physical qubit indices that this gate measures.                                |
| [`model_gate`](#qiskit_noise_learning.gate_sets.QiskitGate.model_gate "qiskit_noise_learning.gate_sets.QiskitGate.model_gate")                                  | The model for this gate.                                                           |
| `name`                                                                                                                                                          | The gate name.                                                                     |
| `num_qubits`                                                                                                                                                    | The number of qubits this gate acts on.                                            |
| `prep_idxs`                                                                                                                                                     | The physical qubit indices that this gate prepares (or resets).                    |
| `qubit_idxs`                                                                                                                                                    | The physical qubit indices this gate acts on.                                      |
| `sorted_meas_idxs`                                                                                                                                              | The indices of the measured qubits in increasing order.                            |
| `sorted_prep_idxs`                                                                                                                                              | The indices of the reset qubits in increasing order.                               |

### circuit

Type: [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit)

A circuit representation of this gate.

> **Note**
>
> The `circuit.qubits` are completely irrelevant and do not, for example, represent physical qubits. Instead, the mappnig `dict(zip(circuit.qubits, qubit_idxs))` provides the recipe for which physical qubits each qubit in the circuit corresponds to. See also [`iter_ops()`](#qiskit_noise_learning.gate_sets.QiskitGate.iter_ops "qiskit_noise_learning.gate_sets.QiskitGate.iter_ops").

### annotations

Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`Annotation`](/docs/api/qiskit/qiskit.circuit.Annotation)]

The annotations to use with this gate.

### constituent\_gate\_idxs

Type: [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...]]

Iterator over tuples of physical indices that specify where constituent gates act.

Some subclasses may not have a meaningful notion of what a “constituent gate” is, because they don’t choose to represent unitary action by some seperable representation. The only contract they need to obey is that the union of all yielded integers is equal to [`gate_idxs`](/docs/api/qiskit-noise-learning/generated/gate-sets-gate#gate_idxs "qiskit_noise_learning.gate_sets.Gate.gate_idxs").

### iter\_ops

`iter_ops() → Iterable[tuple[tuple[int, ...], Operation]]`

Iterate through the operations that compose this gate in circuit order.

**Yields**

Tuples `(physical_qubits, operation)` for each instruction in [`circuit`](#qiskit_noise_learning.gate_sets.QiskitGate.circuit "qiskit_noise_learning.gate_sets.QiskitGate.circuit").

### model\_gate

Type: [`ModelGate`](/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate "qiskit_noise_learning.gate_sets.model_gate.ModelGate")

The model for this gate.

### draw

`draw(*args, **kwargs)`

Draw this gate as a circuit diagram.

Wire labels display the mapping from virtual qubit indices (the circuit’s qubit ordering) to physical qubit indices, using the Qiskit `TranspileLayout` convention, e.g. `v_0 -> 5`.

**Parameters**

- **\*args** – Positional keyword arguments forwarded to [`draw()`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit#draw).
- **\*\*kwargs** – Keyword arguments forwarded to [`draw()`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit#draw).

**Returns**

Text, matplotlib figure, or latex depending on the `output` kwarg.
