Appendix I: The vqelab Package
The progressive project, complete. 29 modules, 6,769 lines, one per chapter from 12 to 40, each extending the last. This listing was generated from the files on disk, not from the chapter text.
The inventory
| Ch | Module | Lines | What it refuses to do |
|---|---|---|---|
| 12 | backends.py |
212 | Choose a backend without a written decision procedure |
| 13 | mitigation.py |
208 | Report a mitigated value without its sampling overhead |
| 14 | translate.py |
156 | Translate a circuit without flagging endianness |
| 15 | resources.py |
128 | Quote a qubit count without the T-factory share |
| 16 | variational.py |
211 | Return a gradient without its variance |
| 17 | topology.py |
176 | Compare modalities without connectivity |
| 18 | interop.py |
207 | Claim a round trip without verifying it |
| 19 | oracles.py |
216 | Count an oracle's cost without its ancillas |
| 20 | algorithms.py |
246 | Claim a separation without naming the promise |
| 21 | grover.py |
221 | Report a speedup without the iteration count |
| 22 | qft.py |
199 | Call the QFT a speedup without the readout problem |
| 23 | shor.py |
244 | Report a factoring without the classical reduction |
| 24 | variational_algorithms.py |
257 | Quote an energy without the shot budget |
| 25 | errorcorrection.py |
421 | Claim a code helps without naming what it is blind to |
| 26 | debugging.py |
252 | Return AGREE when the method is BLIND |
| 27 | testing.py |
265 | Accept a tolerance below the shot-noise floor |
| 28 | optimization.py |
202 | Compare optimization levels without measured fidelity |
| 29 | hardware.py |
231 | Recommend a layout by default |
| 30 | benchmarking.py |
206 | Quote a fidelity without naming its statistic |
| 31 | timing.py |
262 | Evaluate decoupling it cannot evaluate |
| 32 | qml.py |
245 | Price an encoding in qubits alone |
| 33 | classifiers.py |
238 | Compare models below MIN_SPLITS = 5 |
| 34 | kernels.py |
261 | Accept a Gram matrix that is not PSD |
| 35 | hybrid.py |
243 | Claim advantage below the simulation boundary |
| 36 | chemistry.py |
296 | Report an energy error without the active-space error |
| 37 | combinatorial.py |
277 | Return one number for a state and an answer |
| 38 | qkd.py |
262 | Call an unauthenticated link secure at any QBER |
| 39 | platform.py |
243 | Price a job without a circuit duration |
| 40 | claims.py |
184 | Return a score instead of failures |
★ Read the right-hand column as the actual index to this book. Every entry is a refusal the corresponding chapter earned by measuring something, and in seven cases by getting it wrong first.
Assembling the package
Each chapter's code/vqelab/ holds that chapter's module. To assemble the whole package:
mkdir -p vqelab
find part-*/chapter-*/code/vqelab -name "*.py" ! -name "__init__.py" -exec cp {} vqelab/ \;
touch vqelab/__init__.py
⚠️ A naming collision was found while writing this appendix. Chapters 28 and 37 both produced
vqelab/optimization.py— one about circuit optimization, one about combinatorial optimization. In separate chapter directories they coexist; assembled into one package, one silently overwrites the other.Chapter 37's module was renamed to
combinatorial.py. If you are assembling from an older copy of this book's source, check for the collision before you trust the result — it produces no error, just a missing half.
The checkpoint chain
Every chapter's project-checkpoint.py tests its own module. The full chain, run in order, is 503
tests.
for d in part-*/chapter-*/code; do
(cd "$d" && [ -f project-checkpoint.py ] && python project-checkpoint.py)
done
Chapter 40's checkpoint additionally verifies the book's scorecard against the chapters that measured it — if a capstone number is not in its source chapter, it fails.
Design principles, in the order they were earned
1. A function that cannot answer the question raises. It does not return a plausible default.
total_error (Ch. 36) raises without a measured active-space error, because a default of zero is
silently wrong by seven orders of magnitude in the flattering direction.
2. Required arguments have no defaults. quoted_fidelity(dist, statistic, include_dead) (Ch. 30)
takes both explicitly, because one chip supported errors from 0.00750 to 0.07205 depending on the
choice.
3. Absence is None, not a convenient number. UncertifiedResult.certified_ratio (Ch. 37) returns
None. Returning 1.0 would be a lie.
4. A refusal is a distinct answer from a negative result. INSUFFICIENT_SEEDS is not "no
difference" (Ch. 37); UNVALIDATED is not "the error is small" (Ch. 36); BLIND is not "the circuits
agree" (Ch. 26).
5. The module ships its own caveats as data. secret_key_rate (Ch. 38) returns a caveat field
stating that its finite-key model is optimistic — in the return value, not the docstring, where it
cannot be skipped.
6. Provenance travels with the number. PriceBook.as_of is required (Ch. 39); an undated price rots
without telling you.
7. No scores. audit_claim (Ch. 40) returns failures. A claim that cannot name its baseline is not
fractionally correct — it is unevaluable, and averaging that with a pass would be the last instance of
the error this book is about.
Using it after the book
The modules are deliberately small and dependency-light. Most are useful on their own:
claims.py— the eight questions, applicable to any quantitative claim in any field.platform.py— cost modelling for any shot-based workload.testing.py— the shot-noise floor and the two-error-rates framing.benchmarking.py— refusing to quote a number without its statistic.
None of them need a quantum computer.
See also: every chapter from 12 onward; Chapter 40 §40.7 for what the package was actually teaching.