qdsr-audit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qdsr_audit-0.1.0/.gitignore +15 -0
- qdsr_audit-0.1.0/CHANGELOG.md +28 -0
- qdsr_audit-0.1.0/CITATION.cff +50 -0
- qdsr_audit-0.1.0/LICENSE +21 -0
- qdsr_audit-0.1.0/PKG-INFO +210 -0
- qdsr_audit-0.1.0/README.md +167 -0
- qdsr_audit-0.1.0/examples/demo_qml_and_loophole_audit.py +45 -0
- qdsr_audit-0.1.0/examples/quickstart_qdsr_and_grover.py +46 -0
- qdsr_audit-0.1.0/examples/sample_backtest_returns.csv +253 -0
- qdsr_audit-0.1.0/pyproject.toml +103 -0
- qdsr_audit-0.1.0/src/qdsr_audit/__init__.py +151 -0
- qdsr_audit-0.1.0/src/qdsr_audit/_constants.py +44 -0
- qdsr_audit-0.1.0/src/qdsr_audit/cli.py +308 -0
- qdsr_audit-0.1.0/src/qdsr_audit/loophole.py +374 -0
- qdsr_audit-0.1.0/src/qdsr_audit/py.typed +0 -0
- qdsr_audit-0.1.0/src/qdsr_audit/qdsr.py +769 -0
- qdsr_audit-0.1.0/src/qdsr_audit/qml.py +540 -0
- qdsr_audit-0.1.0/src/qdsr_audit/sips.py +483 -0
- qdsr_audit-0.1.0/tests/test_cli.py +64 -0
- qdsr_audit-0.1.0/tests/test_loophole.py +85 -0
- qdsr_audit-0.1.0/tests/test_qdsr.py +121 -0
- qdsr_audit-0.1.0/tests/test_qml.py +72 -0
- qdsr_audit-0.1.0/tests/test_sips.py +103 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `qdsr-audit` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-11-27
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Heavy-Tail $\mathrm{Q\text{-}DSR}_\nu$ Engine (`qdsr_audit.qdsr`)**:
|
|
9
|
+
- Exact tail-matched $\mathrm{Q\text{-}DSR}_\nu = [F_\nu(x)]^{M_{\mathrm{eff}}}$ across Gaussian ($\alpha=2$), Laplace ($\alpha=1$), and heavy-tail Student-$t_\nu$ ($\nu > 1$) regimes.
|
|
10
|
+
- Quantum Overfitting Amplification Law ($2^{1/\alpha}$ sub-Weibull vs. $\kappa^{2/\nu} C^{1/\nu}$ Fréchet explosion).
|
|
11
|
+
- Exact unitary statevector Grover search simulator verifying unitarity and $\sin^2((2r+1)\theta)$ dynamics on score tables.
|
|
12
|
+
- Slepian correlated-catalog multiplicity guarantees vs. Participation Ratio anti-conservative trap diagnostics.
|
|
13
|
+
- Landauer thermodynamic selection erasure bounds ($Q_{\min} = k_B T \ln M_{\mathrm{eff}}$).
|
|
14
|
+
- Multi-strategy CSV & NumPy returns-matrix auditor (`audit_returns_matrix`, `audit_csv`).
|
|
15
|
+
- **Minimax $\mathrm{SIPS}_\infty$, Manski–Rosenbaum & Welch–MIA Engine (`qdsr_audit.sips`)**:
|
|
16
|
+
- Minimax-optimal $\ell_\infty$ post-selection auditor with linear-aggregator blindness detection.
|
|
17
|
+
- Closed-form Hajek IPSW Manski–Rosenbaum sensitivity intervals and breakdown point $\Gamma^*$ (verified to $<10^{-12}$ against Charnes–Cooper LP).
|
|
18
|
+
- Analytical Welch-bound neural superposition to Membership Inference Attack duality ($V_{\mathrm{AI}}^2 + D_{\mathrm{MIA}}^2 \le 1$) and exact Sherman–Morrison dictionary diagnostics.
|
|
19
|
+
- **Detection Loophole, CbD & Spectral Multiplicity Engine (`qdsr_audit.loophole`)**:
|
|
20
|
+
- Symmetric LHV detection-loophole benchmark ($\eta^* = 2/(1+\sqrt{2}) \approx 82.84\%$, $\eta_{\mathrm{Eb}} = 2/3$) and loophole-free deterministic imputation ($\emptyset \mapsto +1$) auditor for Bell experiments and LLM/AI benchmarks.
|
|
21
|
+
- Rank-4 Contextuality-by-Default (CbD) cycle evaluator ($s_{\mathrm{odd}}$, signaling $\Delta_0$, $C_{\mathrm{CbD}}$).
|
|
22
|
+
- Spectral effective multiplicity hierarchy ($1 \le M_{\mathrm{PR}} \le M_{\mathrm{Galwey}} \le M_{\mathrm{Nyholt}} \le M$).
|
|
23
|
+
- **QML Diagnostics Engine (`qdsr_audit.qml`)**:
|
|
24
|
+
- Randomized Pauli Classical Shadows simulator and median-of-means estimator for entangled states.
|
|
25
|
+
- Exact $O(n \cdot 4^n)$ 4-ary Bell-Walsh-Hadamard transform and noisy depolarizing memory crossover diagnostics.
|
|
26
|
+
- Hardware-Efficient Ansatz (HEA) exact parameter-shift Barren Plateaus auditor ($2^{-n}$ local vs. $4^{-n}$ global shot complexity) and exact Haar 2-design variance baselines.
|
|
27
|
+
- Regularized geometric difference $g_{CQ}$ and kernel effective spectral rank diagnostics.
|
|
28
|
+
- **Command-Line Interface (`qdsr-audit`)** with `check`, `csv`, `grover`, `sips`, `loophole`, `shadows`, `barren`, and `cite` subcommands + JSON output mode.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: "qdsr-audit: Quantum Overfitting, Post-Selection & QML Statistical Auditing Library"
|
|
3
|
+
message: "If you use qdsr-audit in research, quantum software benchmarking, or AI evaluation audits, please cite the software archive and relevant preprints below."
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: "Pierret"
|
|
7
|
+
given-names: "Fabien"
|
|
8
|
+
orcid: "https://orcid.org/0009-0001-1223-2170"
|
|
9
|
+
affiliation: "Independent Researcher"
|
|
10
|
+
version: "0.1.0"
|
|
11
|
+
date-released: "2026-11-27"
|
|
12
|
+
license: "MIT"
|
|
13
|
+
url: "https://audit.wallstreetdebug.com"
|
|
14
|
+
repository-code: "https://github.com/fabien-pierret/qdsr-audit"
|
|
15
|
+
doi: "10.5281/zenodo.24591062"
|
|
16
|
+
keywords:
|
|
17
|
+
- quantum-overfitting
|
|
18
|
+
- deflated-sharpe-ratio
|
|
19
|
+
- grover-search
|
|
20
|
+
- post-selection
|
|
21
|
+
- barren-plateaus
|
|
22
|
+
- classical-shadows
|
|
23
|
+
- detection-loophole
|
|
24
|
+
- contextuality-by-default
|
|
25
|
+
- membership-inference
|
|
26
|
+
references:
|
|
27
|
+
- type: article
|
|
28
|
+
authors:
|
|
29
|
+
- family-names: "Pierret"
|
|
30
|
+
given-names: "Fabien"
|
|
31
|
+
orcid: "https://orcid.org/0009-0001-1223-2170"
|
|
32
|
+
title: "The Quantum Overfitting Amplification Theorem and Heavy-Tail Quantum-Adjusted Deflated Sharpe Ratio (Q-DSR_nu)"
|
|
33
|
+
year: 2026
|
|
34
|
+
doi: "10.5281/zenodo.24591340"
|
|
35
|
+
- type: article
|
|
36
|
+
authors:
|
|
37
|
+
- family-names: "Pierret"
|
|
38
|
+
given-names: "Fabien"
|
|
39
|
+
orcid: "https://orcid.org/0009-0001-1223-2170"
|
|
40
|
+
title: "The Contextuality-Signaling Dichotomy in Autoregressive Large Language Models"
|
|
41
|
+
year: 2026
|
|
42
|
+
doi: "10.5281/zenodo.24591378"
|
|
43
|
+
- type: article
|
|
44
|
+
authors:
|
|
45
|
+
- family-names: "Pierret"
|
|
46
|
+
given-names: "Fabien"
|
|
47
|
+
orcid: "https://orcid.org/0009-0001-1223-2170"
|
|
48
|
+
title: "Minimax Impossibility of Linear Post-Selection Auditors (SIPS_infty) and Analytical Welch-Superposition Coupling to Membership Inference Attacks"
|
|
49
|
+
year: 2026
|
|
50
|
+
doi: "10.5281/zenodo.24591422"
|
qdsr_audit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fabien Pierret
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: qdsr-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open-source statistical, quantum-search, and QML post-selection auditing library: Heavy-Tail Q-DSR_nu, Minimax SIPS_infinity, Manski-Rosenbaum bounds, Welch-MIA duality, Detection Loophole/CbD, Classical Shadows, and Barren Plateau diagnostics.
|
|
5
|
+
Project-URL: Homepage, https://audit.wallstreetdebug.com
|
|
6
|
+
Project-URL: Repository, https://github.com/fabien-pierret/qdsr-audit
|
|
7
|
+
Project-URL: Research Suite, https://github.com/fabien-pierret/dcqe-postselection-ai
|
|
8
|
+
Project-URL: Paper 1 (Q-DSR_nu), https://doi.org/10.5281/zenodo.24591340
|
|
9
|
+
Project-URL: Paper 2 (Loopholes & CbD), https://doi.org/10.5281/zenodo.24591378
|
|
10
|
+
Project-URL: Paper 3 (SIPS_infty & MIA), https://doi.org/10.5281/zenodo.24591422
|
|
11
|
+
Project-URL: Zenodo Software DOI, https://doi.org/10.5281/zenodo.24591062
|
|
12
|
+
Author: Fabien Pierret
|
|
13
|
+
Maintainer: Fabien Pierret
|
|
14
|
+
License: MIT
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Keywords: ai-safety,barren-plateaus,classical-shadows,contextuality-by-default,deflated-sharpe-ratio,detection-loophole,grover-search,heavy-tails,membership-inference,multiple-testing,post-selection,quantum-computing,quantum-machine-learning
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
20
|
+
Classifier: Intended Audience :: Science/Research
|
|
21
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
30
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
31
|
+
Classifier: Typing :: Typed
|
|
32
|
+
Requires-Python: >=3.10
|
|
33
|
+
Requires-Dist: numpy>=1.24.0
|
|
34
|
+
Requires-Dist: scipy>=1.10.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: build>=1.2.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.6.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: twine>=5.1.0; extra == 'dev'
|
|
40
|
+
Provides-Extra: plots
|
|
41
|
+
Requires-Dist: matplotlib>=3.7.0; extra == 'plots'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# `qdsr-audit` — Quantum Overfitting, Post-Selection & QML Statistical Auditing Library
|
|
45
|
+
|
|
46
|
+
[](./LICENSE)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](https://doi.org/10.5281/zenodo.24591062)
|
|
49
|
+
[](https://doi.org/10.5281/zenodo.24591340)
|
|
50
|
+
[](https://doi.org/10.5281/zenodo.24591378)
|
|
51
|
+
[](https://doi.org/10.5281/zenodo.24591422)
|
|
52
|
+
[](https://orcid.org/0009-0001-1223-2170)
|
|
53
|
+
|
|
54
|
+
**Live Web Demo:** [https://audit.wallstreetdebug.com](https://audit.wallstreetdebug.com) · **Research Suite:** [fabien-pierret/dcqe-postselection-ai](https://github.com/fabien-pierret/dcqe-postselection-ai)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Why `qdsr-audit`?
|
|
59
|
+
|
|
60
|
+
Quadratic quantum search (Grover / Dürr–Høyer / amplitude amplification), variational Quantum Machine Learning (QML), and selective AI evaluation pipelines share a silent statistical hazard: **post-selection overfitting**.
|
|
61
|
+
|
|
62
|
+
- At a fixed oracle query budget $C$, Grover search probes $M_{\mathrm{quant}}(C) = \lfloor (4C/\pi)^2 \rfloor$ hypotheses. On null heavy-tailed Student-$t_3$ data, it amplifies false in-sample discoveries by **$11.76\times$** at $C=1{,}000$ while out-of-sample expectation stays identically **$0$** — causing $C$-indexed Bonferroni and classical Gaussian Deflated Sharpe Ratios (DSR) to suffer **$53.4\%\text{--}100\%$ False Positive Rates**.
|
|
63
|
+
- Deep variational circuits trigger **$2^{-n}$ (local) and $4^{-n}$ (global) barren plateaus** and exponential kernel concentration, while noisy two-copy quantum memory loses its exponential advantage above depolarizing threshold $p_{\mathrm{cross}} = 1 - 1/\sqrt{2} \approx 29.29\%$.
|
|
64
|
+
- Selective abstention or rejection sampling ($\eta < 1$) opens a **detection loophole** ($\eta^* = 2/(1+\sqrt{2}) \approx 82.84\%$) creating spurious CHSH $> 2$ artifacts in both quantum optics and LLM benchmarks.
|
|
65
|
+
- Any linear post-selection audit score $\sum_k w_k I_k$ has **minimax risk $R_{\max} = 1$** against single-mode failure manifolds.
|
|
66
|
+
|
|
67
|
+
`qdsr-audit` turns these peer-verifiable theorems (**4 CERN Zenodo DOIs**) into a lightweight, zero-bloat (`numpy` + `scipy` only), strictly classical/unitary Python library and CLI — **zero quantum woo**.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install qdsr-audit
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
From source (editable install with dev tools):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/fabien-pierret/qdsr-audit.git
|
|
81
|
+
cd qdsr-audit
|
|
82
|
+
pip install -e ".[dev]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Quickstart (Python API)
|
|
88
|
+
|
|
89
|
+
### 1. Heavy-Tail $\mathrm{Q\text{-}DSR}_\nu$ & Quantum Overfitting Audit (Paper 1)
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from qdsr_audit import compute_qdsr_audit, simulate_grover_search
|
|
93
|
+
|
|
94
|
+
# Audit a 4-year daily strategy (Sharpe = 3.2, T = 1,000) found via C = 1,000 Grover queries on Student-t_3 data
|
|
95
|
+
res = compute_qdsr_audit(
|
|
96
|
+
sharpe_observed=3.2,
|
|
97
|
+
query_budget_c=1000,
|
|
98
|
+
sample_size_t=1000,
|
|
99
|
+
search_mode="quantum_grover",
|
|
100
|
+
tail_regime="student_t",
|
|
101
|
+
student_nu=3.0,
|
|
102
|
+
)
|
|
103
|
+
print(res.verdict_code) # POST_SELECTION_MIRAGE
|
|
104
|
+
print(f"Exact Q-DSR_nu: {res.qdsr_exact:.4f} (FWER p = {res.p_value_fwer_exact:.4f})")
|
|
105
|
+
print(f"Naive DSR(C): {res.naive_dsr_c:.4f} (False green light: {res.false_green_light_trap})")
|
|
106
|
+
print(f"Amplification: {res.amplification_ratio_at_c:.2f}x")
|
|
107
|
+
|
|
108
|
+
# Run an exact 10-qubit (M = 1,024) unitary statevector Grover overfitting check
|
|
109
|
+
grover = simulate_grover_search(q_qubits=10, tail_regime="student_t", student_nu=3.0, seed=42)
|
|
110
|
+
print(f"Unitarity err: {grover.unitarity_norm_err:.2e}, P_succ: {grover.p_succ_exact:.6f}")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 2. Minimax $\mathrm{SIPS}_\infty$, Manski–Rosenbaum Bounds & Welch–MIA Duality (Paper 3)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from qdsr_audit import compute_sips_audit, compute_welch_mia_duality
|
|
117
|
+
|
|
118
|
+
# Single-mode multiplicity failure: linear average = 0.235 (FALSE PASS), SIPS_infty = 0.85 (VETO)
|
|
119
|
+
sips = compute_sips_audit(i_mul=0.85, i_ood=0.04, i_inv=0.03, i_col=0.02)
|
|
120
|
+
print(sips.verdict_code, "| linear blindness exposed:", sips.linear_blindness_exposed)
|
|
121
|
+
|
|
122
|
+
# Welch-bound neural superposition <-> white-box MIA privacy duality (V_AI^2 + D_MIA^2 <= 1)
|
|
123
|
+
mia = compute_welch_mia_duality(bottleneck_dim_d=16, num_features_m=64)
|
|
124
|
+
print(f"rho={mia.rho:.1f} -> D_MIA={mia.d_mia_whitebox_opt:.3f}, V_AI^2+D_MIA^2={mia.duality_sum:.3f} <= 1")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 3. QML Barren Plateaus, Pauli Classical Shadows & Detection Loopholes (Exp 5, 6, 7 & Paper 2)
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from qdsr_audit import (
|
|
131
|
+
barren_plateau_audit,
|
|
132
|
+
run_pauli_shadows_benchmark,
|
|
133
|
+
simulate_lhv_loophole_point,
|
|
134
|
+
compute_cbd_cycle,
|
|
135
|
+
spectral_effective_multiplicity,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
bp = barren_plateau_audit(n_qubits=6, depth=12, n_samples=200, seed=42)
|
|
139
|
+
print(f"Local shots: {bp.shots_required_local_snr1:.1f} vs Global shots: {bp.shots_required_global_snr1:.1f}")
|
|
140
|
+
|
|
141
|
+
sh = run_pauli_shadows_benchmark(n_qubits=4, n_shots=6000, weight=2, seed=42)
|
|
142
|
+
print(f"Classical Shadows max err: {sh.shadow_max_error:.4f} vs Dedicated: {sh.dedicated_max_error:.4f}")
|
|
143
|
+
|
|
144
|
+
lhv = simulate_lhv_loophole_point(eta=0.828427, n_pairs=80_000, seed=42)
|
|
145
|
+
print(f"Post-selected S={lhv['s_post_mc']:.3f} -> Loophole-free S={lhv['s_filled_mc']:.3f}")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Command-Line Interface (`qdsr-audit`)
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Audit a 4-year Sharpe 3.2 strategy under Grover search + heavy tails
|
|
154
|
+
qdsr-audit check --sharpe 3.2 --trials 1000 --t-obs 1000 --mode quantum --tail student_t --nu 3
|
|
155
|
+
|
|
156
|
+
# Audit a multi-strategy backtest CSV
|
|
157
|
+
qdsr-audit csv examples/sample_backtest_returns.csv --tail student_t --nu 3
|
|
158
|
+
|
|
159
|
+
# Exact unitary Grover simulation
|
|
160
|
+
qdsr-audit grover --qubits 10 --nu 3
|
|
161
|
+
|
|
162
|
+
# Minimax SIPS_infinity four-pillar audit
|
|
163
|
+
qdsr-audit sips --mul 0.85 --ood 0.04 --inv 0.03 --col 0.02
|
|
164
|
+
|
|
165
|
+
# Welch-Superposition <-> MIA privacy duality
|
|
166
|
+
qdsr-audit mia --dim 16 --features 64
|
|
167
|
+
|
|
168
|
+
# Bell-CHSH / LLM detection loophole check
|
|
169
|
+
qdsr-audit loophole --eta 0.80
|
|
170
|
+
|
|
171
|
+
# Pauli Classical Shadows & HEA Barren Plateaus diagnostics
|
|
172
|
+
qdsr-audit shadows --qubits 4 --shots 6000 --weight 2
|
|
173
|
+
qdsr-audit barren --qubits 6 --depth 12
|
|
174
|
+
|
|
175
|
+
# Print BibTeX citation & Zenodo CERN DOIs
|
|
176
|
+
qdsr-audit cite
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Add `--json` to any analytical subcommand for machine-readable CI/CD and agent integration.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Module Overview
|
|
184
|
+
|
|
185
|
+
| Module | Scientific Basis | Key Functions |
|
|
186
|
+
| :--- | :--- | :--- |
|
|
187
|
+
| `qdsr_audit.qdsr` | Paper 1 (`10.5281/zenodo.24591340`) | `compute_qdsr_audit`, `exact_evt_scores`, `exact_evt_threshold`, `theoretical_amplification_ratio`, `landauer_selection_bounds`, `simulate_grover_search`, `audit_returns_matrix`, `audit_csv` |
|
|
188
|
+
| `qdsr_audit.sips` | Paper 3 (`10.5281/zenodo.24591422`) | `compute_sips_audit`, `compute_manski_rosenbaum_point`, `compute_welch_mia_duality`, `build_welch_tight_frame`, `audit_dictionary_superposition` |
|
|
189
|
+
| `qdsr_audit.loophole` | Paper 2 (`10.5281/zenodo.24591378`) & Exp 7 | `simulate_lhv_loophole_point`, `audit_bipartite_chsh`, `compute_cbd_cycle`, `spectral_effective_multiplicity` |
|
|
190
|
+
| `qdsr_audit.qml` | Software Suite (`10.5281/zenodo.24591062`) Exp 5–6 | `run_pauli_shadows_benchmark`, `bell_fwht_4ary`, `noisy_bell_memory_threshold`, `barren_plateau_audit`, `haar_2design_gradient_variance`, `compute_geometric_difference` |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Citation
|
|
195
|
+
|
|
196
|
+
If you use `qdsr-audit` in academic research, QML benchmarking, or AI safety evaluations, please cite:
|
|
197
|
+
|
|
198
|
+
```bibtex
|
|
199
|
+
@software{pierret2026qdsr_audit,
|
|
200
|
+
author = {Pierret, Fabien},
|
|
201
|
+
title = {qdsr-audit: Open-Source Quantum Overfitting, Post-Selection, and QML Auditing Library},
|
|
202
|
+
year = {2026},
|
|
203
|
+
version = {0.1.0},
|
|
204
|
+
publisher = {Zenodo},
|
|
205
|
+
doi = {10.5281/zenodo.24591062},
|
|
206
|
+
url = {https://doi.org/10.5281/zenodo.24591062},
|
|
207
|
+
license = {MIT},
|
|
208
|
+
note = {ORCID: 0009-0001-1223-2170}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# `qdsr-audit` — Quantum Overfitting, Post-Selection & QML Statistical Auditing Library
|
|
2
|
+
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://doi.org/10.5281/zenodo.24591062)
|
|
6
|
+
[](https://doi.org/10.5281/zenodo.24591340)
|
|
7
|
+
[](https://doi.org/10.5281/zenodo.24591378)
|
|
8
|
+
[](https://doi.org/10.5281/zenodo.24591422)
|
|
9
|
+
[](https://orcid.org/0009-0001-1223-2170)
|
|
10
|
+
|
|
11
|
+
**Live Web Demo:** [https://audit.wallstreetdebug.com](https://audit.wallstreetdebug.com) · **Research Suite:** [fabien-pierret/dcqe-postselection-ai](https://github.com/fabien-pierret/dcqe-postselection-ai)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why `qdsr-audit`?
|
|
16
|
+
|
|
17
|
+
Quadratic quantum search (Grover / Dürr–Høyer / amplitude amplification), variational Quantum Machine Learning (QML), and selective AI evaluation pipelines share a silent statistical hazard: **post-selection overfitting**.
|
|
18
|
+
|
|
19
|
+
- At a fixed oracle query budget $C$, Grover search probes $M_{\mathrm{quant}}(C) = \lfloor (4C/\pi)^2 \rfloor$ hypotheses. On null heavy-tailed Student-$t_3$ data, it amplifies false in-sample discoveries by **$11.76\times$** at $C=1{,}000$ while out-of-sample expectation stays identically **$0$** — causing $C$-indexed Bonferroni and classical Gaussian Deflated Sharpe Ratios (DSR) to suffer **$53.4\%\text{--}100\%$ False Positive Rates**.
|
|
20
|
+
- Deep variational circuits trigger **$2^{-n}$ (local) and $4^{-n}$ (global) barren plateaus** and exponential kernel concentration, while noisy two-copy quantum memory loses its exponential advantage above depolarizing threshold $p_{\mathrm{cross}} = 1 - 1/\sqrt{2} \approx 29.29\%$.
|
|
21
|
+
- Selective abstention or rejection sampling ($\eta < 1$) opens a **detection loophole** ($\eta^* = 2/(1+\sqrt{2}) \approx 82.84\%$) creating spurious CHSH $> 2$ artifacts in both quantum optics and LLM benchmarks.
|
|
22
|
+
- Any linear post-selection audit score $\sum_k w_k I_k$ has **minimax risk $R_{\max} = 1$** against single-mode failure manifolds.
|
|
23
|
+
|
|
24
|
+
`qdsr-audit` turns these peer-verifiable theorems (**4 CERN Zenodo DOIs**) into a lightweight, zero-bloat (`numpy` + `scipy` only), strictly classical/unitary Python library and CLI — **zero quantum woo**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install qdsr-audit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
From source (editable install with dev tools):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/fabien-pierret/qdsr-audit.git
|
|
38
|
+
cd qdsr-audit
|
|
39
|
+
pip install -e ".[dev]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quickstart (Python API)
|
|
45
|
+
|
|
46
|
+
### 1. Heavy-Tail $\mathrm{Q\text{-}DSR}_\nu$ & Quantum Overfitting Audit (Paper 1)
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from qdsr_audit import compute_qdsr_audit, simulate_grover_search
|
|
50
|
+
|
|
51
|
+
# Audit a 4-year daily strategy (Sharpe = 3.2, T = 1,000) found via C = 1,000 Grover queries on Student-t_3 data
|
|
52
|
+
res = compute_qdsr_audit(
|
|
53
|
+
sharpe_observed=3.2,
|
|
54
|
+
query_budget_c=1000,
|
|
55
|
+
sample_size_t=1000,
|
|
56
|
+
search_mode="quantum_grover",
|
|
57
|
+
tail_regime="student_t",
|
|
58
|
+
student_nu=3.0,
|
|
59
|
+
)
|
|
60
|
+
print(res.verdict_code) # POST_SELECTION_MIRAGE
|
|
61
|
+
print(f"Exact Q-DSR_nu: {res.qdsr_exact:.4f} (FWER p = {res.p_value_fwer_exact:.4f})")
|
|
62
|
+
print(f"Naive DSR(C): {res.naive_dsr_c:.4f} (False green light: {res.false_green_light_trap})")
|
|
63
|
+
print(f"Amplification: {res.amplification_ratio_at_c:.2f}x")
|
|
64
|
+
|
|
65
|
+
# Run an exact 10-qubit (M = 1,024) unitary statevector Grover overfitting check
|
|
66
|
+
grover = simulate_grover_search(q_qubits=10, tail_regime="student_t", student_nu=3.0, seed=42)
|
|
67
|
+
print(f"Unitarity err: {grover.unitarity_norm_err:.2e}, P_succ: {grover.p_succ_exact:.6f}")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. Minimax $\mathrm{SIPS}_\infty$, Manski–Rosenbaum Bounds & Welch–MIA Duality (Paper 3)
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from qdsr_audit import compute_sips_audit, compute_welch_mia_duality
|
|
74
|
+
|
|
75
|
+
# Single-mode multiplicity failure: linear average = 0.235 (FALSE PASS), SIPS_infty = 0.85 (VETO)
|
|
76
|
+
sips = compute_sips_audit(i_mul=0.85, i_ood=0.04, i_inv=0.03, i_col=0.02)
|
|
77
|
+
print(sips.verdict_code, "| linear blindness exposed:", sips.linear_blindness_exposed)
|
|
78
|
+
|
|
79
|
+
# Welch-bound neural superposition <-> white-box MIA privacy duality (V_AI^2 + D_MIA^2 <= 1)
|
|
80
|
+
mia = compute_welch_mia_duality(bottleneck_dim_d=16, num_features_m=64)
|
|
81
|
+
print(f"rho={mia.rho:.1f} -> D_MIA={mia.d_mia_whitebox_opt:.3f}, V_AI^2+D_MIA^2={mia.duality_sum:.3f} <= 1")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. QML Barren Plateaus, Pauli Classical Shadows & Detection Loopholes (Exp 5, 6, 7 & Paper 2)
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from qdsr_audit import (
|
|
88
|
+
barren_plateau_audit,
|
|
89
|
+
run_pauli_shadows_benchmark,
|
|
90
|
+
simulate_lhv_loophole_point,
|
|
91
|
+
compute_cbd_cycle,
|
|
92
|
+
spectral_effective_multiplicity,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
bp = barren_plateau_audit(n_qubits=6, depth=12, n_samples=200, seed=42)
|
|
96
|
+
print(f"Local shots: {bp.shots_required_local_snr1:.1f} vs Global shots: {bp.shots_required_global_snr1:.1f}")
|
|
97
|
+
|
|
98
|
+
sh = run_pauli_shadows_benchmark(n_qubits=4, n_shots=6000, weight=2, seed=42)
|
|
99
|
+
print(f"Classical Shadows max err: {sh.shadow_max_error:.4f} vs Dedicated: {sh.dedicated_max_error:.4f}")
|
|
100
|
+
|
|
101
|
+
lhv = simulate_lhv_loophole_point(eta=0.828427, n_pairs=80_000, seed=42)
|
|
102
|
+
print(f"Post-selected S={lhv['s_post_mc']:.3f} -> Loophole-free S={lhv['s_filled_mc']:.3f}")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Command-Line Interface (`qdsr-audit`)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Audit a 4-year Sharpe 3.2 strategy under Grover search + heavy tails
|
|
111
|
+
qdsr-audit check --sharpe 3.2 --trials 1000 --t-obs 1000 --mode quantum --tail student_t --nu 3
|
|
112
|
+
|
|
113
|
+
# Audit a multi-strategy backtest CSV
|
|
114
|
+
qdsr-audit csv examples/sample_backtest_returns.csv --tail student_t --nu 3
|
|
115
|
+
|
|
116
|
+
# Exact unitary Grover simulation
|
|
117
|
+
qdsr-audit grover --qubits 10 --nu 3
|
|
118
|
+
|
|
119
|
+
# Minimax SIPS_infinity four-pillar audit
|
|
120
|
+
qdsr-audit sips --mul 0.85 --ood 0.04 --inv 0.03 --col 0.02
|
|
121
|
+
|
|
122
|
+
# Welch-Superposition <-> MIA privacy duality
|
|
123
|
+
qdsr-audit mia --dim 16 --features 64
|
|
124
|
+
|
|
125
|
+
# Bell-CHSH / LLM detection loophole check
|
|
126
|
+
qdsr-audit loophole --eta 0.80
|
|
127
|
+
|
|
128
|
+
# Pauli Classical Shadows & HEA Barren Plateaus diagnostics
|
|
129
|
+
qdsr-audit shadows --qubits 4 --shots 6000 --weight 2
|
|
130
|
+
qdsr-audit barren --qubits 6 --depth 12
|
|
131
|
+
|
|
132
|
+
# Print BibTeX citation & Zenodo CERN DOIs
|
|
133
|
+
qdsr-audit cite
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Add `--json` to any analytical subcommand for machine-readable CI/CD and agent integration.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Module Overview
|
|
141
|
+
|
|
142
|
+
| Module | Scientific Basis | Key Functions |
|
|
143
|
+
| :--- | :--- | :--- |
|
|
144
|
+
| `qdsr_audit.qdsr` | Paper 1 (`10.5281/zenodo.24591340`) | `compute_qdsr_audit`, `exact_evt_scores`, `exact_evt_threshold`, `theoretical_amplification_ratio`, `landauer_selection_bounds`, `simulate_grover_search`, `audit_returns_matrix`, `audit_csv` |
|
|
145
|
+
| `qdsr_audit.sips` | Paper 3 (`10.5281/zenodo.24591422`) | `compute_sips_audit`, `compute_manski_rosenbaum_point`, `compute_welch_mia_duality`, `build_welch_tight_frame`, `audit_dictionary_superposition` |
|
|
146
|
+
| `qdsr_audit.loophole` | Paper 2 (`10.5281/zenodo.24591378`) & Exp 7 | `simulate_lhv_loophole_point`, `audit_bipartite_chsh`, `compute_cbd_cycle`, `spectral_effective_multiplicity` |
|
|
147
|
+
| `qdsr_audit.qml` | Software Suite (`10.5281/zenodo.24591062`) Exp 5–6 | `run_pauli_shadows_benchmark`, `bell_fwht_4ary`, `noisy_bell_memory_threshold`, `barren_plateau_audit`, `haar_2design_gradient_variance`, `compute_geometric_difference` |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Citation
|
|
152
|
+
|
|
153
|
+
If you use `qdsr-audit` in academic research, QML benchmarking, or AI safety evaluations, please cite:
|
|
154
|
+
|
|
155
|
+
```bibtex
|
|
156
|
+
@software{pierret2026qdsr_audit,
|
|
157
|
+
author = {Pierret, Fabien},
|
|
158
|
+
title = {qdsr-audit: Open-Source Quantum Overfitting, Post-Selection, and QML Auditing Library},
|
|
159
|
+
year = {2026},
|
|
160
|
+
version = {0.1.0},
|
|
161
|
+
publisher = {Zenodo},
|
|
162
|
+
doi = {10.5281/zenodo.24591062},
|
|
163
|
+
url = {https://doi.org/10.5281/zenodo.24591062},
|
|
164
|
+
license = {MIT},
|
|
165
|
+
note = {ORCID: 0009-0001-1223-2170}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
QML & Detection-Loophole Diagnostics Demo for qdsr-audit:
|
|
4
|
+
1. Randomized Pauli Classical Shadows on a 4-qubit entangled cluster state
|
|
5
|
+
2. HEA Barren Plateaus (shallow local trainable vs deep global 4^-n collapse)
|
|
6
|
+
3. Bell-CHSH / LLM Detection Loophole closed by deterministic imputation (empty -> +1)
|
|
7
|
+
4. Welch-Superposition <-> MIA Privacy Duality (V_AI^2 + D_MIA^2 <= 1)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from qdsr_audit import (
|
|
13
|
+
barren_plateau_audit,
|
|
14
|
+
compute_welch_mia_duality,
|
|
15
|
+
run_pauli_shadows_benchmark,
|
|
16
|
+
simulate_lhv_loophole_point,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main() -> None:
|
|
21
|
+
print("1) PAULI CLASSICAL SHADOWS (n=4 entangled cluster state, N=6,000 shots)")
|
|
22
|
+
sh = run_pauli_shadows_benchmark(n_qubits=4, n_shots=6000, weight=2, seed=42)
|
|
23
|
+
print(f" Entanglement S : {sh.bipartite_entanglement_bits:.3f} bits | M = {sh.n_observables} weight-2 Paulis")
|
|
24
|
+
print(f" Shadows max error : {sh.shadow_max_error:.4f} vs Dedicated: {sh.dedicated_max_error:.4f} ({sh.shadow_over_dedicated_gain:.2f}x better)\n")
|
|
25
|
+
|
|
26
|
+
print("2) BARREN PLATEAUS AUDIT (n=6 brickwork HEA)")
|
|
27
|
+
bp_s = barren_plateau_audit(n_qubits=6, depth=1, n_samples=160, seed=42)
|
|
28
|
+
bp_d = barren_plateau_audit(n_qubits=6, depth=18, n_samples=160, seed=42)
|
|
29
|
+
print(f" Shallow L=1 local : Var = {bp_s.var_local_z1:.4f} (~{bp_s.shots_required_local_snr1:.1f} shots)")
|
|
30
|
+
print(f" Deep L=18 local : Var = {bp_d.var_local_z1:.5f} (~{bp_d.shots_required_local_snr1:,.0f} shots, ~2^n)")
|
|
31
|
+
print(f" Deep L=18 global : Var = {bp_d.var_global_proj0:.2e} (~{bp_d.shots_required_global_snr1:,.0f} shots, ~4^n)\n")
|
|
32
|
+
|
|
33
|
+
print("3) DETECTION LOOPHOLE AUDIT (eta = 82.84% symmetric threshold)")
|
|
34
|
+
lhv = simulate_lhv_loophole_point(0.828427, n_pairs=60_000, seed=42)
|
|
35
|
+
print(f" Post-selected CHSH : {lhv['s_post_mc']:.4f} (matches Tsirelson 2*sqrt(2) with classical LHV!)")
|
|
36
|
+
print(f" Loophole-free CHSH : {lhv['s_filled_mc']:.4f} (closed <= 2.00 via empty -> +1)\n")
|
|
37
|
+
|
|
38
|
+
print("4) WELCH-SUPERPOSITION <-> MIA PRIVACY DUALITY (rho = M/d = 4.0)")
|
|
39
|
+
mia = compute_welch_mia_duality(bottleneck_dim_d=16, num_features_m=64)
|
|
40
|
+
print(f" V_AI = {mia.v_ia_overlap:.4f}, D_MIA = {mia.d_mia_whitebox_opt:.4f}, V_AI^2 + D_MIA^2 = {mia.duality_sum:.4f} <= 1")
|
|
41
|
+
print(f" MIA leakage cut : -{mia.mia_leakage_reduction_pct:.1f}% vs orthogonal regime")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
main()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Quickstart Demo for qdsr-audit (Paper 1 + Paper 3):
|
|
4
|
+
1. Heavy-Tail Q-DSR_nu audit exposing a False Green Light from Naive DSR(C)
|
|
5
|
+
2. Exact 10-qubit unitary statevector Grover overfitting audit
|
|
6
|
+
3. Minimax SIPS_infinity exposing single-mode linear aggregator blindness
|
|
7
|
+
|
|
8
|
+
Ideal for running live during the 2-minute Unitary Foundation pitch video!
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from qdsr_audit import compute_qdsr_audit, compute_sips_audit, simulate_grover_search
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> None:
|
|
17
|
+
print("1) HEAVY-TAIL Q-DSR_nu AUDIT (4-yr SR=3.2, T=1,000, C=1,000 Grover queries, Student-t_3)")
|
|
18
|
+
q = compute_qdsr_audit(
|
|
19
|
+
sharpe_observed=3.2,
|
|
20
|
+
query_budget_c=1000,
|
|
21
|
+
sample_size_t=1000,
|
|
22
|
+
search_mode="quantum_grover",
|
|
23
|
+
tail_regime="student_t",
|
|
24
|
+
student_nu=3.0,
|
|
25
|
+
)
|
|
26
|
+
print(f" Verdict : {q.verdict_code} — {q.verdict_label}")
|
|
27
|
+
print(f" M_eff (Grover) : {q.m_effective_raw:,} hypotheses (at C={q.query_budget_c:,} queries)")
|
|
28
|
+
print(f" Naive DSR(C) : {100 * q.naive_dsr_c:.2f}% <-- FALSE GREEN LIGHT!")
|
|
29
|
+
print(f" Exact Q-DSR_nu : {100 * q.qdsr_exact:.2f}% (FWER p = {q.p_value_fwer_exact:.4f})")
|
|
30
|
+
print(f" Amplification R(C) : {q.amplification_ratio_at_c:.2f}x null mirage blow-up")
|
|
31
|
+
print(f" Landauer reset : {q.landauer.bits_quantum_reset:.2f} bits vs {q.landauer.bits_classical:.2f} bits classical\n")
|
|
32
|
+
|
|
33
|
+
print("2) EXACT UNITARY STATEVECTOR GROVER AUDIT (q = 10 qubits, M = 1,024)")
|
|
34
|
+
g = simulate_grover_search(q_qubits=10, tail_regime="student_t", student_nu=3.0, seed=42)
|
|
35
|
+
print(f" P_succ exact : {g.p_succ_exact:.6f} (unitarity err = {g.unitarity_norm_err:.1e})")
|
|
36
|
+
print(f" In-sample mirage : classical {g.classical_max_is:.2f} -> Grover {g.grover_max_is:.2f}")
|
|
37
|
+
print(f" Out-of-sample : {g.grover_winner_oos:+.2f} (exact Q-DSR_nu = {100 * g.qdsr_grover_winner:.1f}%)\n")
|
|
38
|
+
|
|
39
|
+
print("3) MINIMAX SIPS_infinity FOUR-PILLAR AUDIT (Paper 3)")
|
|
40
|
+
s = compute_sips_audit(i_mul=0.88, i_ood=0.04, i_inv=0.03, i_col=0.02)
|
|
41
|
+
print(f" Linear average l1 : {s.sips_linear_uniform:.3f} (PASSES <= 0.50 -> BLIND!)")
|
|
42
|
+
print(f" SIPS_infinity max : {s.sips_infinity:.3f} (VETOES -> {s.verdict_code})")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|