//! The tracker's 120-qubit SU(2) lattice-gauge instance by sparse Pauli //! dynamics, against the device value and the classical values published for //! it. //! //! `cargo run --release --example tracker_su2 --features quantum_engine,quantum_receipt,quantum_spd_receipt -- [meson | scv] [threshold ...]` //! //! The instance is 20 Trotter steps of a 60-site chain, two qubits a site; the //! value the tracker holds is the global charge `Q = Σ_q (1 − Z_q)/2` after the //! last step, which the dynamics conserve exactly (`Q = 60` in both initial //! states). Every two-qubit block of the circuit conserves the number of ones, //! so `Σ Z_q` is carried through each block unchanged, and the bound on what //! truncation dropped is at the level of rounding. (A threshold of 0 keeps the //! rounding residue of every block, about 10⁻¹⁷ a term, and those terms then //! multiply: give a threshold above rounding.) //! //! Each run writes a signed receipt to `RECEIPTS_DIR` (default `receipts`). #[path = "tracker/common.rs"] mod common; use serde_json::json; use wai_quantum::quantum_spd::{Pauli, SpdConfig, expectation}; /// (what produced it, Q after 20 steps, the tracker submission it is from) const PUBLISHED: &[(&str, f64, u32)] = &[ ("device, readout-error mitigated (± 0.005710650099)", 59.99402699, 149), ("Pauli propagation on a workstation CPU", 60.00538161, 202), ("matrix-product-state simulation on a laptop", 59.9985, 227), ("Pauli propagation on a laptop CPU", 60.00129, 250), ]; fn main() { let mut args = std::env::args().skip(1); let root = common::tracker_root(args.next()); let which = args.next().unwrap_or_else(|| "meson".into()); let thresholds: Vec = args.map(|a| a.parse().expect("a threshold")).collect(); let thresholds = if thresholds.is_empty() { vec![1e-3, 1e-6, 1e-9] } else { thresholds }; let path = match which.as_str() { "meson" => "data/observable-estimations/circuit-models/su2_hadron_dynamics_lsh/x_100_meson.qasm", "scv" => "data/observable-estimations/circuit-models/su2_hadron_dynamics_lsh/x_100_SCV.qasm", other => panic!("meson or scv, not {other}"), }; let src = String::from_utf8(common::read_pinned(&root, path)).expect("UTF-8"); let (circuit, map) = common::compact(&common::rotations(&src)); assert_eq!(map, (0..120).collect::>(), "every qubit of the register is used"); let n = circuit.n; // Q = n/2 − ½ Σ Z_q. let observable: Vec<(f64, Vec<(u32, Pauli)>)> = (0..n).map(|q| (-0.5, vec![(q, Pauli::Z)])).collect(); let circuit_hash = common::hex( &wai_quantum::quantum_spd_receipt::SpdJob { circuit: circuit.clone(), observable: vec![], ones: vec![], config: SpdConfig::default() }.circuit_hash(), ); println!("instance su2_hadron_dynamics_lsh_x_100_{which}"); println!("qubits {n}, {} gates", circuit.ops.len()); println!("circuit hash {circuit_hash}"); for (label, value, issue) in PUBLISHED { println!("published {value:<12} {label} (submission {issue})"); } for threshold in thresholds { let cfg = SpdConfig { threshold, max_weight: None }; let (r, secs, energy) = common::metered(|| expectation(&circuit, &observable, &[], &cfg).expect("a valid circuit")); let q = f64::from(n) / 2.0 + r.value; println!( "threshold {threshold:<8e} Q = {q:.12} bound {:.3e} peak {} final {} updates {} {secs:.2} s {}", r.truncation_bound, r.peak_terms, r.final_terms, r.term_updates, energy.get("joules_micro").map_or("unmetered".to_string(), |j| format!("{:.2} J", j.as_u64().unwrap_or(0) as f64 / 1e6)), ); let request = json!({ "instance": format!("su2_hadron_dynamics_lsh_x_100_{which}"), "source": common::source(path), "method": "sparse Pauli dynamics (quantum_spd::expectation) of −½ Σ Z_q; Q = n/2 plus it", "circuit_hash": circuit_hash, "threshold": threshold, "threshold_bits": common::bits(threshold), "published": PUBLISHED.iter().map(|(label, value, issue)| json!({ "label": label, "value": value, "submission": issue })).collect::>(), }); let result = json!({ "charge": q, "charge_bits": common::bits(q), "truncation_bound": r.truncation_bound, "peak_terms": r.peak_terms, "final_terms": r.final_terms, "term_updates": r.term_updates, "wall_seconds": secs, "energy_figure": energy, }); let out = common::receipt_path(&format!("su2_{which}_t{threshold:e}.json")); let doc = common::seal(request, result, Some(&out)); assert!(common::verifies(&doc)); println!("receipt {}", out.display()); } }