QEC
Detector sampling, detector error models and noise-arg shaping
14/14 passed in 2627ms
| Test | What it does | Result |
|---|---|---|
test_apply_data_noise_shapes | apply_data_noise emits one 1Q op per qubit for the single-qubit channels and one 2Q op per adjacent pair for DEPOLARIZE2, passing each its resolved arg. | ✅ pass |
test_cache_is_transparent | The structure cache memoizes fault propagation, so a warm build equals a cold one (after clear_structure_cache) mechanism for mechanism. | ✅ pass |
test_channel_arg_shapes | channel_arg leaves a bare scalar alone on every channel (the factory splits it), and a {label: rate} dict builds the channel with exactly those rates. | ✅ pass |
test_control_variate_is_finite_when_signs_cancel | The self-normalised ratio sum(s*w)/sum(s) diverges when a stratum's signs cancel. The control variate has no such denominator, so on that input it returns a finite contribution and variance. | ✅ pass |
test_every_family_every_channel_builds | Every code family builds and DEM-builds under all five Pauli channels: the regression for PAULI_CHANNEL_1 and DEPOLARIZE2 crashing the template builders. | ✅ pass |
test_flip_circuit_rates | One X_ERROR(p) between two measurements: arrays are (shots, 1), the detector and observable fire together at rate p, never at p = 0 and always at p = 1. | ✅ pass |
test_gauge_detector_rejected | A detector measuring a Pauli outside the stabiliser group is a coin flip every shot, so the error model and the sampler refuse it unless allow_gauge_detectors=True. | ✅ pass |
test_graphlike_edge_two_detectors | A data-qubit error flips two stabilizers, giving a matching edge. | ✅ pass |
test_graphlike_guard | Repetition codes (DEPOLARIZE2 included) and the rotated surface code give graphlike DEMs that MWPM accepts; DEPOLARIZE2 on a 2D code gives hyperedges, which MWPM refuses with a message saying so. | ✅ pass |
test_leave_one_out_beta_excludes_its_own_shot | The leave-one-out control-variate coefficient for shot i equals the plain Cov(s*w, s)/Var(s) over every OTHER shot, the independence that keeps the control variate unbiased. | ✅ pass |
test_masses_are_exact | The per-stratum signed quasiprobability masses are analytic and sum to 1 by trace preservation, for Pauli and non-Pauli noise alike. | ✅ pass |
test_multi_branch_channel_sums | A channel's branches are mutually exclusive, so two of them flipping the same detector SUM rather than combining as independent errors. DEPOLARIZE1's X and Y both flip a Z-basis measurement, so the mechanism is exactly 2p/3. | ✅ pass |
test_shipped_codes_deterministic | Every shipped family declares only deterministic detectors, so the gauge check must not fire on any of them. | ✅ pass |
test_single_mechanism | The flip circuit yields one mechanism flipping detector 0 and observable 0 at p = 0.1, and check_matrix returns it as aligned H / priors / observable arrays. | ✅ pass |