Skip to main content
IBM Quantum Platform

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

Bases: Gate

Represents a single gate in a 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 containing a 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 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 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

Column 1
Column 2
__init__(name, circuit, qubit_idxs[, ...])
draw(*args, **kwargs)Draw this gate as a circuit diagram.
iter_ops()Iterate through the operations that compose this gate in circuit order.

Attributes

Column 1
Column 2
annotationsThe annotations to use with this gate.
circuitA circuit representation of this gate.
constituent_gate_idxsIterator over tuples of physical indices that specify where constituent gates act.
gate_idxsThe physical indices where this gate undergoes unitary action.
idling_idxsThe physical qubit indices that this gate is idling on.
labelA string label for use in plotter legends.
latex_strA LaTeX string for this gate.
math_labelA string label for use within latex math mode.
meas_idxsThe physical qubit indices that this gate measures.
model_gateThe model for this gate.
nameThe gate name.
num_qubitsThe number of qubits this gate acts on.
prep_idxsThe physical qubit indices that this gate prepares (or resets).
qubit_idxsThe physical qubit indices this gate acts on.
sorted_meas_idxsThe indices of the measured qubits in increasing order.
sorted_prep_idxsThe indices of the reset qubits in increasing order.

circuit

Type: 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().

annotations

Type: list[Annotation]

The annotations to use with this gate.

constituent_gate_idxs

Type: Iterator[tuple[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.

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.

model_gate

Type: 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().
  • **kwargs – Keyword arguments forwarded to draw().

Returns

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

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