QuantumFlow supports several different quantum operations that act upon either pure or mixed states (or both). The four main types are Gate, which represents the action of an operator (typically unitary) on a state; Channel, which represents the action of a superoperator on a state (used for mixed quantum-classical dynamics); Kruas, which represents a Channel as a collection of operators; and Circuit, which is a list of other operations that act in sequence. Circuits can contain any instance of the abstract quantum operation superclass, Operation, including other circuits.

We consider the elemental quantum operations, such as Gate, Channel, and Kraus, as immutable. (Although immutability is not enforced in general.) Transformations of these operations return new copies. On the other hand the composite operation Circuit is mutable.

class quantumflow.Operation

An operation on a qubit state. An element of a quantum circuit.

Abstract Base Class for Gate, Circuit, Channel, and Kraus.


Return the Hermitian conjugate of this quantum operation.

For unitary Gates (and Circuits composed of the same) the Hermitian conjugate returns the inverse Gate (or Circuit)

aschannel() → qf.Channel

Convert this quantum operation to a channel (if possible)

asgate() → qf.Gate

Convert this quantum operation to a gate (if possible)

evolve(rho: qf.Density) → qf.Density

Apply the action of this operation upon a mixed state


Return the name of this operation


Return the total number of qubits


Return the qubits that this operation acts upon

run(ket: qf.State) → qf.State

Apply the action of this operation upon a pure state