|
6 | 6 | //! |
7 | 7 | //! The benchmark itself only times `trotter_func` — it never reads the |
8 | 8 | //! propagated observable back, so nothing there guards the *result*. These |
9 | | -//! tests run the same gate sequence (`rx` + `rzz` + `pauli_error`, truncating |
10 | | -//! after every gate as the bench does) on a small chain and check: |
| 9 | +//! tests run the same noisy gate sequence as the bench (physical gate then |
| 10 | +//! noise, propagated as noise then gate in Heisenberg order, truncating after |
| 11 | +//! every operation) on a small chain and check: |
11 | 12 | //! |
12 | 13 | //! 1. **Math regression** — the exact (untruncated, `NoStrategy`) expectation |
13 | 14 | //! value matches a frozen golden constant. |
@@ -35,17 +36,17 @@ macro_rules! trotter_evolve { |
35 | 36 | ($state:expr) => {{ |
36 | 37 | for _ in 0..STEPS { |
37 | 38 | for i in 0..N { |
38 | | - $state.rx(i, THETA_X); |
39 | | - $state.truncate(); |
40 | 39 | $state.pauli_error(i, NOISE); |
41 | 40 | $state.truncate(); |
| 41 | + $state.rx(i, THETA_X); |
| 42 | + $state.truncate(); |
42 | 43 | } |
43 | 44 | for i in 0..N - 1 { |
44 | | - $state.rzz(i, i + 1, THETA_ZZ); |
| 45 | + $state.pauli_error(i + 1, NOISE); |
45 | 46 | $state.truncate(); |
46 | 47 | $state.pauli_error(i, NOISE); |
47 | 48 | $state.truncate(); |
48 | | - $state.pauli_error(i + 1, NOISE); |
| 49 | + $state.rzz(i, i + 1, THETA_ZZ); |
49 | 50 | $state.truncate(); |
50 | 51 | } |
51 | 52 | } |
@@ -97,10 +98,10 @@ fn trotter_result_is_stable_and_truncation_is_faithful() { |
97 | 98 | let approx_val = expect_on_zero!(approx); |
98 | 99 |
|
99 | 100 | // (1) Math-regression guard: frozen golden for the exact circuit. Any |
100 | | - // change to the gate math (a wrong sign, bit-flip, or addressing bug in |
101 | | - // rx/rzz/pauli_error) moves this by O(1e-3) or more; the bound is far |
| 101 | + // change to the gate math (a wrong sign, bit-flip, addressing bug, or |
| 102 | + // gate/noise ordering mistake) moves this by O(1e-3) or more; the bound is far |
102 | 103 | // tighter than that yet far looser than cross-platform trig last-bit noise. |
103 | | - const GOLDEN: f64 = 2.161056303575631; |
| 104 | + const GOLDEN: f64 = 2.1610566562692544; |
104 | 105 | assert!( |
105 | 106 | (exact_val - GOLDEN).abs() < 1e-9, |
106 | 107 | "exact Trotter expectation {exact_val} drifted from golden {GOLDEN}" |
|
0 commit comments