//! Measure the rotated surface code's logical error rate per round, and fit //! the code model `P(d) = a·(p/p*)^((d+1)/2)` that resource estimates assume. //! //! ```text //! cargo run --release --example qec_threshold --features quantum_frame -- [SHOTS] [SEED] //! ``` use wai_quantum::quantum_match::{fit_code_model, memory_experiment}; fn main() { let a: Vec = std::env::args().collect(); let shots: usize = a.get(1).map_or(200_000, |s| s.parse().unwrap()); let seed: u64 = a.get(2).map_or(1, |s| s.parse().unwrap()); let mut pts = Vec::new(); println!("{:>3} {:>7} {:>9} {:>9} {:>12}", "d", "p", "shots", "failures", "per round"); for d in [3u32, 5, 7] { for p in [0.002, 0.003, 0.004, 0.005] { // Fewer shots where decoding costs more and failures are plentiful. let n = if d == 7 { shots / 4 } else { shots }; let t = memory_experiment(d, d, p, n, seed).expect("decode"); println!("{:>3} {:>7} {:>9} {:>9} {:>12.4e}", d, p, t.shots, t.failures, t.per_round()); pts.push(t); } } let f = fit_code_model(&pts).expect("fit"); println!("fit: a = {:.4}, p* = {:.5}", f.prefactor, f.threshold); }