Skip to content

Noise

A channel is a gate that is not unitary: it describes noise and takes a pure state to a mixed one. vqubit defines channels with their Kraus operators, the matrices $K_i$ such that the state evolves as $\rho \to \sum_i K_i \rho K_i^\dagger$.

The channels that ship

Channel Constructor What it models
Bit flip vq.bit_flip(p) Flips the qubit with probability p.
Phase flip vq.phase_flip(p) Applies Z with probability p.
Bit-phase flip vq.bit_phase_flip(p) Applies Y with probability p.
Depolarizing vq.depolarize(p, n=1) Applies a random Pauli with probability p.
Amplitude damping vq.amplitude_damp(gamma) Energy loss (|1> → |0>).
Phase damping vq.phase_damp(gamma) Loss of coherence.
Reset vq.reset(n=1) Drives the qubits to |0>.

Using them in a circuit

Channels are placed like any other operation:

import vqubit as vq

q0, q1 = vq.LineQubit.range(2)
circuit = vq.Circuit(
    vq.H(q0),
    vq.depolarize(0.05)(q0),     # single-qubit noise
    vq.CNOT(q0, q1),
    vq.bit_flip(0.02)(q1),
)

# Only the density-matrix simulator runs channels
result = vq.DensityMatrixSimulator().simulate(circuit)
print(result.density_matrix()[0][0])   # population of |00>

Inspecting the operators

import vqubit as vq

operators = vq.kraus(vq.depolarize(0.1))
print(len(operators))            # 4: I, X, Y, Z
print(vq.has_unitary(vq.depolarize(0.1)))   # False: a channel is not unitary

An ordinary unitary gate has exactly one Kraus operator, its own unitary:

print(len(vq.kraus(vq.X)))        # 1

Next steps