Channels

Mixed States and Quantum Channels

class quantumflow.Density(tensor: ArrayLike, qubits: Sequence[Qubit] | None = None, memory: Mapping | None = None)

A density matrix representation of a mixed quantum state

asoperator() ndarray

Return the density matrix as a square array

normalize() Density

Normalize state

probabilities() ndarray

Returns: The state probabilities

trace() float

Return the trace of this density operator

class quantumflow.Channel(tensor: ArrayLike, qubits: Sequence[Qubit], params: Sequence[float | Expr] | None = None, name: str | None = None)

A quantum channel

property H: Channel

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)

Raises:

ValueError – If this operation does not support Hermitian conjugate

aschannel() Channel

Convert this quantum operation to a channel (if possible).

Raises:

ValueError – If this operation cannot be converted to a Channel

asgate() Gate

Convert this quantum operation to a gate (if possible).

Raises:

ValueError – If this operation cannot be converted to a Gate

chi() ndarray

Return the chi (or process) matrix representation of this superoperator

choi() ndarray

Return the Choi matrix representation of this super operator

evolve(rho: Density) Density

Apply the action of this channel upon a density

classmethod from_choi(tensor: ArrayLike, qubits: Sequence[Qubit]) Channel

Return a Channel from a Choi matrix

property name: str

Return the name of this Operation

permute(qubits: Sequence[Qubit]) Channel

Return a copy of this channel with qubits in new order

run(ket: State) State

Apply the action of this operation upon a pure state

property sharp: Channel

Return the ‘sharp’ transpose of the superoperator.

The transpose \(S^\#\) switches the two covariant (bra) indices of the superoperator. (Which in our representation are the 2nd and 3rd super-indices)

If \(S^\#\) is Hermitian, then \(S\) is a Hermitian-map (i.e. transforms Hermitian operators to Hermitian operators)

Flattening the \(S^\#\) superoperator to a matrix gives the Choi matrix representation. (See channel.choi())

property tensor: ndarray

Return the tensor representation of the channel’s superoperator

trace() float

Return the trace of this super operator

class quantumflow.Kraus(operators: Sequence[Gate], weights: Sequence[float] | None = None)

A Kraus representation of a quantum channel

property H: Kraus

Return the complex conjugate of this Kraus operation

aschannel() Channel

Returns: Action of Kraus operators as a superoperator Channel

asgate() Gate

Not possible in general. (But see UnitaryMixture)

Raises: TypeError

evolve(rho: Density) Density

Apply the action of this Kraus quantum operation upon a density

property qubits: Sequence[Qubit]

List of qubits acted upon by this Kraus operation

The list of qubits is ordered if the qubits labels can be sorted, else the the order is indeterminate.

Raises:

TypeError – If qubits cannot be sorted into unique order.

Type:

Returns

run(ket: State) State

Apply the action of this Kraus quantum operation upon a state

class quantumflow.UnitaryMixture(operators: Sequence[Gate], weights: Sequence[float] | None = None)

A Kraus channel which is a convex mixture of unitary dynamics.

This Channel is unital, but not all unital channels are unitary mixtures.

asgate() Gate

Return one of the composite Kraus operators at random with the appropriate weights

run(ket: State) State

Apply the action of this Kraus quantum operation upon a state

Actions on Densities

quantumflow.mixed_density(qubits: int | Sequence[Qubit]) Density

Returns the completely mixed density matrix

quantumflow.random_density(qubits: int | Sequence[Qubit], rank: int | None = None, ensemble: str = 'Hilbert–Schmidt') Density

Returns: A randomly sampled Density

Parameters:
  • qubits – A list or number of qubits.

  • rank – Rank of density matrix. (Defaults to full rank)

  • ensemble – Either ‘Hilbert–Schmidt’ (default) or ‘Burr’

Ref:
  • “Induced.info in the space of mixed quantum states” Karol Zyczkowski, Hans-Juergen Sommers, J. Phys. A34, 7111-7125 (2001) arXiv:quant-ph/0012101

  • “Random Bures mixed states and the distribution of their purity”, Osipov, Sommers, and Zyczkowski, J. Phys. A: Math. Theor. 43, 055302 (2010). arXiv:0909.5094

quantumflow.join_densities(rho0: Density, rho1: Density) Density

Join two mixed states into a larger qubit state

Actions on Channels

quantumflow.join_channels(chan0: Channel, chan1: Channel) Channel

Join two channels acting on different qubits into a single channel acting on all qubits

quantumflow.channel_to_kraus(chan: Channel) Kraus

Convert a channel superoperator into a Kraus operator representation of the same channel.

quantumflow.kraus_iscomplete(kraus: Kraus) bool

Returns True if the collection of (weighted) Kraus operators are complete. (Which is necessary for a CPTP map to preserve trace)

Standard channels

class quantumflow.Dephasing(prob: float, q0: Qubit)

A Kraus representation of a phase-damping quantum channel

Parameters:
  • prob – The one-step damping probability.

  • q0 – The qubit on which to act.

class quantumflow.Damping(prob: float, q0: Qubit)

A Kraus representation of an amplitude-damping (spontaneous emission) channel on one qubit

Parameters:
  • prob – The one-step damping probability.

  • q0 – The qubit on which to act.

class quantumflow.Depolarizing(prob: float, q0: Qubit)

A Kraus representation of a depolarizing channel on 1-qubit.

Parameters:
  • prob – The one-step depolarizing probability.

  • q0 – The qubit on which to act.

quantumflow.random_channel(qubits: Sequence[Qubit], rank: int | None = None, unital: bool = False) Channel

Returns: A randomly sampled Channel drawn from the BCSZ ensemble with the specified Kraus rank.

Parameters:
  • qubits – A list, or number, of qubits.

  • rank – Kraus rank of channel. (Defaults to full rank)

Ref:

“Random quantum operations”, Bruzda, Cappellini, Sommers, and Zyczkowski, Physics Letters A 373, 320 (2009). arXiv:0804.2361