Skip to content

noise/kraus.py

class GAD

Generalized amplitude damping (GAD) Kraus operators for a d-level system.

Provides Kraus operators {Ak,Rk} parameterized by environment excitation probability p and damping parameter Y.

A

Construct the GAD lowering Kraus operator Ak.

This operator maps population from |r to |rk with weights determined by (Y,p).

py
def A(order: int, d: int, Y: float, p: float) -> pt.Tensor [static]
Implementation
python
def A(order: int, d: int, Y: float, p: float=0.0) -> pt.Tensor:
    k = order
    assert isinstance(k, int) and k >= 0, 'k must be int>=0'
    assert isinstance(d, int) and d > 0, 'd must be int>0'
    obj = pt.zeros((d, d), dtype=C128)
    if k < d:
        rs = pt.arange(k, d, dtype=pt.float64)
        binom = pt.tensor([float(nCr(int(r), k)) for r in range(k, d)], dtype=pt.float64)
        vals = binom.sqrt() * (1 - Y) ** ((rs - k) / 2) * Y ** (k / 2)
        obj[(rs - k).long(), rs.long()] = vals.to(C128)
    return (1 - p) ** 0.5 * obj

R

Construct the GAD raising Kraus operator Rk.

This operator maps population from |r to |r+k with weights determined by (Y,p).

py
def R(k: int, d: int, Y: float, p: float) -> pt.Tensor [static]
Implementation
python
def R(k: int, d: int, Y: float, p: float=0.0) -> pt.Tensor:
    obj = pt.zeros((d, d), dtype=C128)
    if k < d:
        rs = pt.arange(0, d - k, dtype=pt.float64)
        binom = pt.tensor([float(nCr(int(d - r - 1), k)) for r in range(d - k)], dtype=pt.float64)
        vals = binom * (1 - Y) ** ((d - rs - k - 1) / 2) * Y ** (k / 2)
        obj[(rs + k).long(), rs.long()] = vals.to(C128)
    return p ** 0.5 * obj

class Pauli

Single-qubit Pauli error operators as Kraus operators.

Each method returns pσ for σ{X,Y,Z} and an identity term 1piI.

X

Return the bit-flip Kraus operator pX.

py
def X(p: float) -> pt.Tensor [static]
Implementation
python
def X(p: float) -> pt.Tensor:
    return p ** 0.5 * pt.tensor([[0, 1], [1, 0]], dtype=C128)

Y

Return the phase+bit-flip Kraus operator pY.

py
def Y(p: float) -> pt.Tensor [static]
Implementation
python
def Y(p: float) -> pt.Tensor:
    return p ** 0.5 * pt.tensor([[0, -1j], [1j, 0]], dtype=C128)

Z

Return the phase-flip Kraus operator pZ.

py
def Z(p: float) -> pt.Tensor [static]
Implementation
python
def Z(p: float) -> pt.Tensor:
    return p ** 0.5 * pt.tensor([[1, 0], [0, -1]], dtype=C128)

I

Return the identity Kraus operator 1ipiI.

py
def I(ps: List[float]) -> pt.Tensor [static]
Implementation
python
def I(ps: List[float]) -> pt.Tensor:
    return (1 - sum(ps)) ** 0.5 * pt.tensor([[1, 0], [0, 1]], dtype=C128)

class Depolarising

Depolarising channel Kraus operators for a d-level system.

The channel acts as Φ(ρ)=(1p)ρ+pd2j,kWjkρWjk where Wjk are the d2 Weyl-Heisenberg operators.

ops

Return all d2 Weyl-Heisenberg Kraus operators weighted for the depolarising channel.

The identity term carries weight 1p(d21)/d2 and each non-identity Weyl operator Wjk carries weight p/d2.

py
def ops(d: int, p: float) -> List[pt.Tensor] [static]
Implementation
python
def ops(d: int, p: float) -> List[pt.Tensor]:
    import cmath
    w = cmath.exp(2j * cmath.pi / d)
    shift = pt.roll(pt.eye(d, dtype=C128), shifts=-1, dims=1)
    clock = pt.diag(pt.tensor([w ** k for k in range(d)], dtype=C128))
    weyl = []
    for j in range(d):
        for k in range(d):
            W = pt.linalg.matrix_power(shift, j) @ pt.linalg.matrix_power(clock, k)
            weyl.append(W)
    result = []
    for i, W in enumerate(weyl):
        if i == 0:
            weight = (1 - p * (d * d - 1) / (d * d)) ** 0.5
        else:
            weight = (p / (d * d)) ** 0.5
        result.append(weight * W)
    return result

class PhaseDamp

Phase damping (dephasing) Kraus operators for a d-level system.

Kills off-diagonal coherences without energy exchange. For d=2: K0=diag(1,1p), K1=diag(0,p). For d>2: d Kraus operators, each projecting onto one basis state scaled appropriately.

ops

Return Kraus operators for phase damping on a d-level system.

K0=diag(1,1p,,1p) and Kj=p|jj| for j=1,,d1.

py
def ops(d: int, p: float) -> List[pt.Tensor] [static]
Implementation
python
def ops(d: int, p: float) -> List[pt.Tensor]:
    K0 = pt.zeros((d, d), dtype=C128)
    K0[0, 0] = 1.0
    for j in range(1, d):
        K0[j, j] = (1 - p) ** 0.5
    result = [K0]
    for j in range(1, d):
        Kj = pt.zeros((d, d), dtype=C128)
        Kj[j, j] = p ** 0.5
        result.append(Kj)
    return result

class Reset

Reset channel Kraus operators for a d-level system.

Collapses the qudit to |0 with probability p: Φ(ρ)=(1p)ρ+p|00|Tr(ρ).

ops

Return Kraus operators for the reset channel.

Kj=p|0j| for j=0,,d1 and Kd=1pI.

py
def ops(d: int, p: float) -> List[pt.Tensor] [static]
Implementation
python
def ops(d: int, p: float) -> List[pt.Tensor]:
    result = []
    for j in range(d):
        Kj = pt.zeros((d, d), dtype=C128)
        Kj[0, j] = p ** 0.5
        result.append(Kj)
    result.append((1 - p) ** 0.5 * pt.eye(d, dtype=C128))
    return result

class ThermalRelax

Thermal relaxation channel Kraus operators for a qubit (d=2 only).

Two-parameter model combining T1 energy decay and T2 dephasing. T1 is the relaxation time, T2 is the dephasing time, t is the gate time. Requires T22T1.

ops

Return 4 Kraus operators for thermal relaxation on a qubit.

Decomposes combined T1/T2 dynamics into amplitude decay (p1) and pure dephasing (pϕ) components: p1=1et/T1, pϕ=(1et/T2/et/(2T1))/2.

py
def ops(T1: float, T2: float, t: float) -> List[pt.Tensor] [static]
Implementation
python
def ops(T1: float, T2: float, t: float) -> List[pt.Tensor]:
    import math
    e1 = math.exp(-t / T1)
    e2 = math.exp(-t / T2)
    p1 = 1 - e1
    lam = e2 / math.sqrt(e1)
    p_phi = (1 - lam) / 2
    K0 = pt.tensor([[math.sqrt(1 - p_phi), 0.0], [0.0, math.sqrt((1 - p1) * (1 - p_phi))]], dtype=C128)
    K1 = pt.tensor([[0.0, math.sqrt(p1 * (1 - p_phi))], [0.0, 0.0]], dtype=C128)
    K2 = pt.tensor([[math.sqrt(p_phi), 0.0], [0.0, -math.sqrt((1 - p1) * p_phi)]], dtype=C128)
    K3 = pt.tensor([[0.0, math.sqrt(p1 * p_phi)], [0.0, 0.0]], dtype=C128)
    return [K0, K1, K2, K3]