Skip to content

Noise ​

Noise channels and trajectory sampling

21/21 passed in 7528ms

TestWhat it doesResult
test_accepts_legal_ratesThe rate bounds are not over-tight: p = 0, p = 1 and the equal-thirds split are legal channels whose branch weights sum to 1.✅ pass
test_bitflip_rateX_ERROR(p) flips |0> with empirical frequency about p.✅ pass
test_certain_ratesX_ERROR(0) never flips |0> and X_ERROR(1) always does.✅ pass
test_expect_decaysDephasing at p = 0.5 drives <X> from +1 to 0.✅ pass
test_full_depolarize_randomizesDEPOLARIZE1(0.75) on |0> gives a ~50:50 Z outcome: X and Y flip it, I and Z do not.✅ pass
test_refusalsBad arguments raise ValueError naming the problem: rates outside [0, 1] or summing past 1, wrong vector lengths or labels, non-CP damping, bias on a 2-qubit channel, wrong target counts, a mis-sized observable, and record sampling of non-Pauli noise.✅ pass
test_clifford_rotation_is_exactRZ(pi/2) is the Clifford S (gamma = 1), so <Y> on |+> is exactly 1.✅ pass
test_half_turns_are_pauliA half turn is the axis Pauli and a full turn the identity, so both report is_pauli; a quarter turn (S) and a generic angle do not.✅ pass
test_reference_agreesH, RZ(pi), H, M reads |1>: the noiseless reference and the trajectories run the same deterministic Z, so the records match the dense amplitude and the detector rate matches the DEM.✅ pass
test_rotations_match_exactImportance sampling reproduces the exact <X>, <Y> of RZ(theta)|+> and <Z>, <Y> of RX(theta)|0>, at Clifford, generic and wasteful angles.✅ pass
test_amplitude_branchesAMPLITUDE_DAMP(p) branches are identity, Z and reset at q_I = ((1-p) + sqrt(1-p))/2, q_Z = ((1-p) - sqrt(1-p))/2 < 0 and q_R = p, with gamma = sqrt(1-p) + p.✅ pass
test_damping_matches_exactDamping estimates match the exact Bloch map, <Z> on |1> -> tau - mu and <X> on |+> -> lam, for amplitude damping and a positive-regime GeneralizedDamping.✅ pass
test_signed_fast_pathAn amplitude-damping memory lowers to the Rust signed sampler (reset is opcode 9), and its importance weights average to 1, as a trace-preserving mix must.✅ pass
test_beats_flat_varianceStratifying spreads less than flat sampling where the observable depends only on the fault count.✅ pass
test_matches_importance_coherentUnder a coherent RZ plus depolarizing, stratified and flat importance sampling agree (both unbiased).✅ pass
test_unbiased_dephasingStratified <X..X> matches the exact (1-2p)^n for independent dephasing.✅ pass
test_bias_axesbias_split puts the heavy rate on the axis it is told to, and eta = 0.5 is depolarizing on all three.✅ pass
test_bias_dualityA biased surface-code memory is self-dual: swapping bias_axis and memory together (X <-> Z) gives the same detector error model.✅ pass
test_correlated_pair_faultA ZZ-only PAULI_CHANNEL_2 reaches the DEM as ONE error flipping both qubits' detectors, which no product of single-qubit channels can express.✅ pass
test_isotropic_defaultA bare scalar is the isotropic channel: DEPOLARIZE1 and PAULI_CHANNEL_1 spread p evenly over X, Y, Z, and DEPOLARIZE2 and PAULI_CHANNEL_2 over the 15 pairs.✅ pass
test_pair_ratesA {label: rate} dict puts each rate on the Pauli it names, every unlisted one at zero, and its label width sets the arity.✅ pass