|
| 1 | +# Bosonic verification simulator |
| 2 | + |
| 3 | +`cv-verification` is a NumPy-based simulator for fidelity-witness protocols |
| 4 | +in four-mode bosonic experiments. It models finite-support pure input states, |
| 5 | +a passive interferometer, binary characteristic-function measurements, |
| 6 | +readout-error mitigation, and finite-sample witness estimation. |
| 7 | + |
| 8 | +The implemented protocols are: |
| 9 | + |
| 10 | +- `single_mode`: \(W^{(1)}=\sum_i F_i-3\); |
| 11 | +- `disjoint_two_mode`: \(F_{ij}+F_{kl}-1\) for a fixed pairing; |
| 12 | +- `max_two_mode`: the maximum of 16 intersection-corrected spanning-tree |
| 13 | + witnesses. |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Python 3.11 or later is required. |
| 18 | + |
| 19 | +```bash |
| 20 | +python -m venv .venv |
| 21 | +source .venv/bin/activate |
| 22 | +python -m pip install --upgrade pip |
| 23 | +python -m pip install -e . |
| 24 | +``` |
| 25 | + |
| 26 | +## Run one experiment |
| 27 | + |
| 28 | +```bash |
| 29 | +python -m cv_verification examples/fock_hadamard.json \ |
| 30 | + --output output/runs/fock_hadamard |
| 31 | +``` |
| 32 | + |
| 33 | +Equivalently, after installation: |
| 34 | + |
| 35 | +```bash |
| 36 | +cv-verify examples/fock_hadamard.json \ |
| 37 | + --output output/runs/fock_hadamard |
| 38 | +``` |
| 39 | + |
| 40 | +Each run writes a machine-readable summary, resolved configuration, |
| 41 | +per-trial data, and comparison plots. Generated files are placed under |
| 42 | +`output/`, which is excluded from version control. |
| 43 | + |
| 44 | +Ideal single-mode inputs may be specified as number states, normalized finite |
| 45 | +Fock vectors, or the included finite GKP-core preset. Complex coefficients and |
| 46 | +unitary entries accept real numbers, Python-style complex strings, `[real, |
| 47 | +imag]`, or `{\"real\": ..., \"imag\": ...}`. |
| 48 | + |
| 49 | +## Reproduce the Fock-input scaling study |
| 50 | + |
| 51 | +```bash |
| 52 | +python scripts/run_hadamard_demo.py \ |
| 53 | + --output output/demo/hadamard \ |
| 54 | + --repetitions 5000 |
| 55 | +``` |
| 56 | + |
| 57 | +This studies \({|1\rangle}^{\otimes4}\) followed by the normalized |
| 58 | +Sylvester-Hadamard interferometer, using sample counts from \(1\) to \(10^7\). |
| 59 | +The preparation, interferometer, and measurement fidelities may be changed |
| 60 | +with the corresponding command-line options. |
| 61 | + |
| 62 | +The \(0.5\)-target threshold and selected \(0.9/0.9\) operating point are |
| 63 | +reproduced with: |
| 64 | + |
| 65 | +```bash |
| 66 | +python scripts/find_hadamard_thresholds.py \ |
| 67 | + --output output/demo/hadamard_high_fidelity |
| 68 | + |
| 69 | +python scripts/run_hadamard_demo.py \ |
| 70 | + --output output/demo/hadamard_high_fidelity \ |
| 71 | + --repetitions 5000 \ |
| 72 | + --preparation-fidelity 0.9 \ |
| 73 | + --interferometer-fidelity 0.9 \ |
| 74 | + --measurement-fidelity 1.0 |
| 75 | +``` |
| 76 | + |
| 77 | +## Reproduce the truncated-GKP study |
| 78 | + |
| 79 | +The finite GKP preset is the normalized projection of the finite-energy |
| 80 | +square-GKP \(|0\rangle\) ansatz onto Fock levels \(0,\ldots,6\), with |
| 81 | +\(\Delta=0.5\). Run the baseline, selected operating point, sample-count |
| 82 | +sweeps, and balanced-threshold search with: |
| 83 | + |
| 84 | +```bash |
| 85 | +python scripts/run_gkp_hadamard_analysis.py \ |
| 86 | + --output-root output/demo \ |
| 87 | + --delta 0.5 \ |
| 88 | + --cutoff 6 \ |
| 89 | + --repetitions 5000 |
| 90 | +``` |
| 91 | + |
| 92 | +The exact four-mode GKP evolution is computationally heavier than the Fock |
| 93 | +example; the script reuses each exact state across all sample counts. |
| 94 | + |
| 95 | +## Statistical and physical conventions |
| 96 | + |
| 97 | +- States and shots are independent and identically distributed. |
| 98 | +- Preparation and interferometer imperfections remain fixed within a sweep; |
| 99 | + repeated trials vary only shot noise. |
| 100 | +- The interferometer is passive and photon-number conserving. |
| 101 | +- All ideal inputs have finite Fock support. |
| 102 | +- Scalar device fidelities select a canonical seeded pure-error model; they do |
| 103 | + not uniquely specify an experimental noise channel. |
| 104 | +- Measurement fidelity is the assignment fidelity of one joint binary |
| 105 | + characteristic-function readout. It is neither a product of four per-mode |
| 106 | + detector fidelities nor a global state fidelity. |
| 107 | +- Known symmetric assignment errors are mitigated using visibility |
| 108 | + \(v=2f_{\mathrm{meas}}-1\). Mitigation removes asymptotic bias and increases |
| 109 | + statistical uncertainty by \(1/v\). |
| 110 | +- Hoeffding bounds are distribution-free and include the 16-candidate union |
| 111 | + bound for `max_two_mode`. |
| 112 | + |
| 113 | +## Tests |
| 114 | + |
| 115 | +```bash |
| 116 | +python -m unittest discover -s tests -v |
| 117 | +``` |
| 118 | + |
| 119 | +The test suite covers Fock evolution, marginal fidelities, interferometer |
| 120 | +calibration, characteristic-function identities and norms, all witness |
| 121 | +formulas, readout mitigation, Hoeffding coverage, reproducibility, and output |
| 122 | +schemas. |
| 123 | + |
| 124 | +## Citation |
| 125 | + |
| 126 | +Please use the metadata in [`CITATION.cff`](CITATION.cff). A versioned Zenodo |
| 127 | +DOI can be added after the first GitHub release. |
| 128 | + |
| 129 | +## License |
| 130 | + |
| 131 | +This project is released under the [MIT License](LICENSE). |
0 commit comments