qubasic 0.14.0__tar.gz → 0.16.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.
- {qubasic-0.14.0 → qubasic-0.16.0}/CHANGELOG.md +42 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/PKG-INFO +77 -6
- qubasic-0.14.0/qubasic.egg-info/PKG-INFO → qubasic-0.16.0/README.md +68 -38
- {qubasic-0.14.0 → qubasic-0.16.0}/pyproject.toml +4 -1
- qubasic-0.14.0/README.md → qubasic-0.16.0/qubasic.egg-info/PKG-INFO +109 -5
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic.egg-info/SOURCES.txt +6 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic.egg-info/requires.txt +11 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/__init__.py +1 -1
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/algorithms.py +162 -10
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/algos2.py +4 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/analysis.py +3 -1
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/benchmarking.py +82 -43
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/cli.py +35 -2
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/control_flow.py +5 -1
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/dynamics.py +125 -4
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/engine.py +14 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/executor.py +27 -4
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/expression.py +17 -2
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/file_io.py +24 -9
- qubasic-0.16.0/qubasic_core/jupyter_kernel.py +98 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/locc_commands.py +8 -7
- qubasic-0.16.0/qubasic_core/logical.py +164 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/memory.py +10 -1
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/patterns.py +1 -1
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/profiler.py +4 -2
- qubasic-0.16.0/qubasic_core/qchem.py +150 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/qec.py +59 -12
- qubasic-0.16.0/qubasic_core/qec2.py +366 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/resources.py +5 -4
- qubasic-0.16.0/qubasic_core/sweep.py +127 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/terminal.py +75 -20
- qubasic-0.16.0/qubasic_core/web_repl.py +131 -0
- qubasic-0.16.0/tests/test_golden.py +270 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/tests/test_qubasic.py +10 -0
- qubasic-0.14.0/qubasic_core/sweep.py +0 -83
- {qubasic-0.14.0 → qubasic-0.16.0}/LICENSE +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/MANIFEST.in +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/examples/bell.qb +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/examples/grover3.qb +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/examples/locc_teleport.qb +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/examples/sweep_rx.qb +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic.egg-info/dependency_links.txt +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic.egg-info/entry_points.txt +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic.egg-info/top_level.txt +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/__main__.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/backend.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/bosonic.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/classic.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/debug.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/demos.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/display.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/engine_state.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/errors.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/exec_context.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/gates.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/help_text.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/io_protocol.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/locc.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/locc_display.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/locc_engine.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/locc_execution.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/mock_backend.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/noise_mixin.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/parser.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/pauliprop.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/program_mgmt.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/protocol.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/qol.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/qudits.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/scope.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/screen.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/state_display.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/statements.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/strings.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/qubasic_core/subs.py +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/setup.cfg +0 -0
- {qubasic-0.14.0 → qubasic-0.16.0}/tests/test_features.py +0 -0
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0 (2026-07-02)
|
|
4
|
+
|
|
5
|
+
Research-grade error correction, per-method scale, parametric variational
|
|
6
|
+
loops, molecular Hamiltonians, and two new front ends (Jupyter, web). The
|
|
7
|
+
existing command surface is unchanged; everything below is additive.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Circuit-level QEC: `LOGICAL_ERROR_RATE <code> <d> <p> CIRCUIT [shots]` runs stim-generated syndrome-extraction circuits (noisy gates, measurements, and resets over d rounds) decoded from the detector error model by pymatching MWPM — a d=21 surface patch samples ~13k shots/s. `MWPM` runs batched pymatching at code capacity for distances the lookup table cannot reach. Both need the `[qec]` extra (stim + pymatching).
|
|
11
|
+
- Bivariate-bicycle qLDPC codes: `QEC BB [l m]` builds the family from cyclic-shift polynomials (6 6 gives [[72,12,6]], 12 6 the [[144,12,12]] gross code) with k verified by GF(2) ranks, and `LOGICAL_ERROR_RATE BB <p>` decodes with an internal belief-propagation + ordered-statistics (BP+OSD-0) decoder — no external dependency.
|
|
12
|
+
- Logical-qubit mode: `LQUBITS <n> CODE <name> <d> [PHYS p]` runs the program on logical qubits — every op carries the code's per-op logical error channel, measurement a logical readout flip, and RUN appends the lattice-surgery report (surgery ops, syndrome rounds, physical qubits, error budget). `LQUBITS OFF` returns to physical mode.
|
|
13
|
+
- Molecular Hamiltonians: `HAMILTONIAN H = MOLECULE H2 [R]` builds the exact 4-qubit Jordan-Wigner Hamiltonian from a self-contained STO-3G integrals engine (no pyscf); exact diagonalization reproduces the FCI energy -1.1373 Ha at R=0.7414, and `SAVE_EXPECT <name> -> var` now accepts a declared Hamiltonian for VQE cost functions.
|
|
14
|
+
- Optimizers: `MINIMIZE ... METHOD SPSA` (two evaluations per iteration, robust to shot noise) and `METHOD GRAD` (parameter-shift gradient descent with adaptive step) join Nelder-Mead.
|
|
15
|
+
- Lindblad trajectories: `LINDBLAD ... TRAJ [n]` switches to Monte Carlo wavefunction unraveling (sparse H_eff + quantum jumps), raising the open-system ceiling from 5 to 15 qubits.
|
|
16
|
+
- Jupyter kernel (`qubasic --install-kernel`, then pick "QUBASIC") and a token-gated browser REPL (`qubasic --web [port]`, localhost by default).
|
|
17
|
+
- A golden-script test layer (`tests/test_golden.py`): whole programs asserted end to end on physics identities (inverse round trips, teleportation fidelity, EXPORT-LOADQASM fixed point, FCI energies) and on the 0.15.0 audit regressions.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Qubit ceilings are per METHOD: statevector keeps the 32-qubit memory wall, stabilizer reaches 4096 (an 881-qubit GHZ runs in ~12 s), MPS/automatic 1024, extended_stabilizer 63. Switching METHOD clamps QUBITS when needed, and QUBITS/RAM report memory in method-appropriate terms instead of a misleading 2^n estimate.
|
|
21
|
+
- MINIMIZE, GRADIENT, and SWEEP compile the circuit once with bound qiskit Parameters and re-bind per evaluation when the ansatz permits (reported as "parametric compile"), an order of magnitude on variational loops; non-symbolic programs fall back to the rebuild path.
|
|
22
|
+
- GST characterizes 2-qubit programs (product fiducials, 16x16 Pauli Transfer Matrix) as well as 1-qubit.
|
|
23
|
+
- The STATS progress spinner writes only to an interactive terminal, and SWEEP shows a transient progress bar there; piped and captured output is unchanged.
|
|
24
|
+
- `PRINT`ing a quantum DATA token shows ket notation (|GHZ3>) instead of the storage form; IQPE hints when the target register has no eigenstate preparation; LOCCINFO branch statistics count every SEND across all shots instead of the bits' final values; LOADQASM points at `pip install qubasic[qasm3]` when the 3.0 importer is missing.
|
|
25
|
+
|
|
26
|
+
## 0.15.0 (2026-07-02)
|
|
27
|
+
|
|
28
|
+
Error-handling, calibration, and I/O fixes from a full-surface audit. The
|
|
29
|
+
quantum engine is unchanged.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
- `RESUME`, `RESUME NEXT`, and `RESUME <line>` return to the mainline after a trapped error: the executor routes per-line errors through the ON ERROR handler in-loop, so a handler runs as ordinary program code and resumes where the README says. Error trapping arms per run (a stale target from a previous RUN no longer traps early), the 200-line handler budget applies per activation, and an error raised inside a handler is fatal.
|
|
33
|
+
- `$D014` (entanglement_entropy) is populated after each run with the qubit-0-vs-rest entropy in bits, matching `ENTROPY 0`; it always read 0.0.
|
|
34
|
+
- `EXPORT` emits OpenQASM 2.0 when the circuit allows, so its output round-trips through `LOADQASM` without the optional `qiskit_qasm3_import` package. Dynamic circuits still export as 3.0, and the message reports the version written.
|
|
35
|
+
- `SWEEP` restores the swept variable afterward instead of leaving it at the final sweep point, so a following RUN or STATS sees the program's own value.
|
|
36
|
+
- A UTF-8 BOM no longer mangles the first statement: piped stdin and all program readers (script files, `LOAD`, `INCLUDE`, `IMPORT`, `LOADQASM`) decode utf-8-sig.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- `XEB` reports the self-normalized linear fidelity (sampled numerator over the perfect-sampling denominator `2^n sum(p^2) - 1`), so 1.0 is the true ideal at any width; the raw estimator tops out at (D-1)/(D+1), 0.6 at 2 qubits.
|
|
40
|
+
- `OPTIMIZE` reports a depth increase as such instead of a negative reduction.
|
|
41
|
+
- The `SWEEP` chart's y-axis is fixed to [0, 1].
|
|
42
|
+
- `DUMP` prints registers wider than a byte compactly (`698.6`) instead of truncating the decimal.
|
|
43
|
+
- Qiskit's advisory warning about passing coupling_map/basis_gates with a backend is silenced on the device-model path, where that combination is by design.
|
|
44
|
+
|
|
3
45
|
## 0.14.0 (2026-06-19)
|
|
4
46
|
|
|
5
47
|
Second audit-gap round: a complete agent contract, BASIC truth values, range
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qubasic
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.0
|
|
4
4
|
Summary: Quantum BASIC Interactive Terminal
|
|
5
5
|
Author-email: "Charles C. Norton" <machineelv@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -29,6 +29,14 @@ Provides-Extra: charts
|
|
|
29
29
|
Requires-Dist: plotille>=5.0; extra == "charts"
|
|
30
30
|
Provides-Extra: readline
|
|
31
31
|
Requires-Dist: pyreadline3>=3.4; sys_platform == "win32" and extra == "readline"
|
|
32
|
+
Provides-Extra: qasm3
|
|
33
|
+
Requires-Dist: qiskit-qasm3-import>=0.4; extra == "qasm3"
|
|
34
|
+
Provides-Extra: qec
|
|
35
|
+
Requires-Dist: stim>=1.12; extra == "qec"
|
|
36
|
+
Requires-Dist: pymatching>=2.1; extra == "qec"
|
|
37
|
+
Provides-Extra: jupyter
|
|
38
|
+
Requires-Dist: ipykernel>=6.0; extra == "jupyter"
|
|
39
|
+
Requires-Dist: jupyter-client>=7.0; extra == "jupyter"
|
|
32
40
|
Dynamic: license-file
|
|
33
41
|
|
|
34
42
|
# QUBASIC
|
|
@@ -62,6 +70,10 @@ QUBASIC is a quantum computing environment built on Qiskit Aer that uses BASIC s
|
|
|
62
70
|
pip install qubasic
|
|
63
71
|
```
|
|
64
72
|
|
|
73
|
+
Optional extras: `qubasic[qec]` (stim + pymatching for circuit-level error
|
|
74
|
+
correction), `qubasic[jupyter]` (notebook kernel), `qubasic[qasm3]` (OpenQASM
|
|
75
|
+
3 import), `qubasic[charts]` (sweep charts).
|
|
76
|
+
|
|
65
77
|
Development install:
|
|
66
78
|
|
|
67
79
|
```
|
|
@@ -79,6 +91,8 @@ qubasic script.qb Run a script file
|
|
|
79
91
|
qubasic --quiet script Suppress banner, output results only
|
|
80
92
|
qubasic --json script Machine-readable JSON output
|
|
81
93
|
qubasic --spec Print a JSON contract (commands, gates, functions)
|
|
94
|
+
qubasic --web [port] Browser REPL (localhost, token-gated)
|
|
95
|
+
qubasic --install-kernel Install the Jupyter kernelspec (then pick "QUBASIC")
|
|
82
96
|
qubasic --help Show CLI help
|
|
83
97
|
```
|
|
84
98
|
|
|
@@ -206,7 +220,7 @@ RESET 0 Reset qubit to |0>
|
|
|
206
220
|
## Configuration
|
|
207
221
|
|
|
208
222
|
```
|
|
209
|
-
QUBITS 8 Set qubit count (
|
|
223
|
+
QUBITS 8 Set qubit count (ceiling is per METHOD)
|
|
210
224
|
SHOTS 2048 Set measurement shots
|
|
211
225
|
METHOD statevector Set simulation method
|
|
212
226
|
METHOD GPU Set simulation device
|
|
@@ -219,6 +233,13 @@ STATUS JSON Same, as machine-readable JSON
|
|
|
219
233
|
|
|
220
234
|
Automatic selection: stabilizer for Clifford-only circuits, MPS for >28 qubits, statevector otherwise.
|
|
221
235
|
|
|
236
|
+
Qubit ceilings are per method: the 32-qubit wall is a statevector memory
|
|
237
|
+
limit only. `stabilizer` reaches 4096 qubits (polynomial tableau),
|
|
238
|
+
`matrix_product_state` and `automatic` reach 1024 (MPS memory is set by
|
|
239
|
+
entanglement, not width), `extended_stabilizer` 63; an 881-qubit GHZ runs in
|
|
240
|
+
seconds on the stabilizer backend. Switching METHOD clamps QUBITS to the new
|
|
241
|
+
ceiling when needed.
|
|
242
|
+
|
|
222
243
|
## Variables and expressions
|
|
223
244
|
|
|
224
245
|
```
|
|
@@ -472,9 +493,16 @@ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
|
|
|
472
493
|
20 SAVE_EXPECT Z 0 -> cost
|
|
473
494
|
MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
|
|
474
495
|
MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
|
|
496
|
+
MINIMIZE a, b -> cost METHOD SPSA SPSA (2 evals/iter, robust to shot noise)
|
|
497
|
+
MINIMIZE a -> cost METHOD GRAD Parameter-shift gradient descent
|
|
475
498
|
GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
|
|
476
499
|
```
|
|
477
500
|
|
|
501
|
+
When the ansatz permits, MINIMIZE/GRADIENT/SWEEP compile the circuit once
|
|
502
|
+
with bound qiskit Parameters and only re-bind values per evaluation (reported
|
|
503
|
+
as "parametric compile") — an order of magnitude on variational loops. The
|
|
504
|
+
fallback for non-symbolic programs is the classic rebuild per step.
|
|
505
|
+
|
|
478
506
|
## Dynamic circuits (feedforward)
|
|
479
507
|
|
|
480
508
|
In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
|
|
@@ -516,26 +544,64 @@ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; need
|
|
|
516
544
|
```
|
|
517
545
|
HAMILTONIAN H = 1.0 ZZ 0 1 + 0.5 X 0 Declare a Pauli-sum Hamiltonian
|
|
518
546
|
HAMILTONIAN H = ISING 1.0 0.5 Builders: ISING, HEISENBERG, HUBBARD, RYDBERG
|
|
547
|
+
HAMILTONIAN H = MOLECULE H2 0.7414 H2/STO-3G (built-in integrals engine, no pyscf)
|
|
519
548
|
10 EVOLVE H, 1.5, 20 Trotterized e^{-iHt} (time, steps) in a circuit
|
|
520
|
-
|
|
549
|
+
10 SAVE_EXPECT H -> e <H> of a declared Hamiltonian (VQE cost)
|
|
550
|
+
LINDBLAD NONE, 1.0, 200, 1.0 SM 0 Open-system master-equation evolution (dense, <=5 qubits)
|
|
551
|
+
LINDBLAD H, 1.0, 200, 1.0 SM 0 TRAJ 500 Monte Carlo wavefunction unraveling (<=15 qubits)
|
|
521
552
|
CHANNEL AD = [[1,0],[0,0.95]] ; [[0,0.31],[0,0]] Define a Kraus channel
|
|
522
553
|
10 APPLYCHANNEL AD 0 Apply a custom channel
|
|
523
554
|
```
|
|
524
555
|
|
|
556
|
+
`MOLECULE H2 [R]` computes the exact 4-qubit Jordan-Wigner Hamiltonian from a
|
|
557
|
+
self-contained STO-3G integrals engine (Gaussian s-orbital closed forms, RHF
|
|
558
|
+
by symmetry). Exact diagonalization at R = 0.7414 reproduces the FCI energy
|
|
559
|
+
-1.1373 Ha, and a one-parameter VQE reaches it in ~30 evaluations.
|
|
560
|
+
|
|
525
561
|
## Error correction
|
|
526
562
|
|
|
527
563
|
```
|
|
528
564
|
QEC STEANE Show a code (REP [d], STEANE, SHOR, SURFACE [d]) and its stabilizers
|
|
565
|
+
QEC BB [l m] Bivariate-bicycle qLDPC (6 6 -> [[72,12,6]], 12 6 -> [[144,12,12]])
|
|
529
566
|
LOGICAL_ERROR_RATE STEANE 0.02 Monte-Carlo logical error rate (optimal lookup decoder)
|
|
530
|
-
LOGICAL_ERROR_RATE SURFACE 0.02 UF
|
|
567
|
+
LOGICAL_ERROR_RATE SURFACE 0.02 UF Union-find / matching decoder
|
|
568
|
+
LOGICAL_ERROR_RATE SURFACE 11 0.05 MWPM Batched pymatching MWPM (large distances)
|
|
569
|
+
LOGICAL_ERROR_RATE SURFACE 21 0.001 CIRCUIT 1000000 Circuit-level noise (stim + pymatching)
|
|
570
|
+
LOGICAL_ERROR_RATE BB 0.01 BB codes decode with the internal BP+OSD
|
|
531
571
|
THRESHOLD REP 0.0 0.5 11 Sweep p across distances 3/5/7 (crossing at 0.5)
|
|
532
572
|
DISTILL 0.02 15-to-1 magic-state distillation (output error ~35 p^3)
|
|
533
573
|
LATTICE 0 1 Lattice-surgery joint Zbar-Zbar measurement of two patches
|
|
534
574
|
```
|
|
535
575
|
|
|
536
576
|
Codes: repetition (any odd distance), Steane [[7,1,3]], Shor [[9,1,3]], rotated
|
|
537
|
-
surface
|
|
538
|
-
|
|
577
|
+
surface, and the bivariate-bicycle qLDPC family (parity checks built from the
|
|
578
|
+
cyclic-shift polynomials, k verified by GF(2) ranks). Decoders: an optimal
|
|
579
|
+
minimum-weight lookup table (all codes), a union-find / matching decoder (`UF`),
|
|
580
|
+
batched pymatching MWPM (`MWPM`), and an internal belief-propagation +
|
|
581
|
+
ordered-statistics decoder (BP+OSD-0) for the qLDPC codes.
|
|
582
|
+
|
|
583
|
+
`CIRCUIT` switches from code capacity to full circuit-level noise: stim
|
|
584
|
+
generates the noisy syndrome-extraction circuit (d rounds of gates,
|
|
585
|
+
measurements, and resets, each carrying errors), pymatching decodes the
|
|
586
|
+
detector error model, and millions of shots run in seconds — a d=21 surface
|
|
587
|
+
patch (944 physical qubits, 9240 detectors) samples at ~13k shots/s.
|
|
588
|
+
|
|
589
|
+
### Logical-qubit mode
|
|
590
|
+
|
|
591
|
+
```
|
|
592
|
+
LQUBITS 2 CODE SURFACE 5 PHYS 1e-3 Program on 2 LOGICAL qubits (surface, d=5)
|
|
593
|
+
10 H 0 Gates now act on logical qubits
|
|
594
|
+
20 CX 0,1 CX compiles to a lattice-surgery merge+split
|
|
595
|
+
30 MEASURE
|
|
596
|
+
RUN Histogram of LOGICAL outcomes
|
|
597
|
+
LQUBITS OFF Back to physical qubits
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
While active, every operation carries the code's per-op logical error channel
|
|
601
|
+
(from the code-capacity rate for the chosen code, distance, and physical p),
|
|
602
|
+
measurement carries a logical readout flip, and RUN appends the
|
|
603
|
+
lattice-surgery report: surgery ops, syndrome rounds, physical-qubit total,
|
|
604
|
+
wall time at 1 us/round, and the cumulative logical error budget.
|
|
539
605
|
|
|
540
606
|
## Benchmarking and verification
|
|
541
607
|
|
|
@@ -883,6 +949,11 @@ qubasic_core/
|
|
|
883
949
|
display.py Histograms, statevector, Bloch sphere rendering
|
|
884
950
|
locc.py LOCC commands, execution, display
|
|
885
951
|
analysis.py EXPECT, ENTROPY, DENSITY, BENCH, RAM
|
|
952
|
+
qec2.py Circuit-level QEC (stim/pymatching), BB qLDPC, BP+OSD
|
|
953
|
+
logical.py LQUBITS logical-qubit mode + lattice-surgery report
|
|
954
|
+
qchem.py STO-3G molecular Hamiltonians (MOLECULE H2)
|
|
955
|
+
jupyter_kernel.py Jupyter kernel (qubasic --install-kernel)
|
|
956
|
+
web_repl.py Browser REPL (qubasic --web)
|
|
886
957
|
sweep.py Parameter sweep with plotille charts
|
|
887
958
|
memory.py PEEK/POKE/SYS/DUMP/MAP/MONITOR
|
|
888
959
|
strings.py String functions
|
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: qubasic
|
|
3
|
-
Version: 0.14.0
|
|
4
|
-
Summary: Quantum BASIC Interactive Terminal
|
|
5
|
-
Author-email: "Charles C. Norton" <machineelv@gmail.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/CharlesCNorton/qubasic
|
|
8
|
-
Project-URL: Repository, https://github.com/CharlesCNorton/qubasic
|
|
9
|
-
Project-URL: Issues, https://github.com/CharlesCNorton/qubasic/issues
|
|
10
|
-
Keywords: quantum,computing,qiskit,basic,repl,simulator
|
|
11
|
-
Classifier: Development Status :: 3 - Alpha
|
|
12
|
-
Classifier: Intended Audience :: Education
|
|
13
|
-
Classifier: Intended Audience :: Science/Research
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
-
Requires-Python: >=3.10
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
Requires-Dist: qiskit>=1.0
|
|
24
|
-
Requires-Dist: qiskit-aer>=0.13
|
|
25
|
-
Requires-Dist: numpy>=1.24
|
|
26
|
-
Requires-Dist: psutil>=5.9
|
|
27
|
-
Requires-Dist: rich>=13.0
|
|
28
|
-
Provides-Extra: charts
|
|
29
|
-
Requires-Dist: plotille>=5.0; extra == "charts"
|
|
30
|
-
Provides-Extra: readline
|
|
31
|
-
Requires-Dist: pyreadline3>=3.4; sys_platform == "win32" and extra == "readline"
|
|
32
|
-
Dynamic: license-file
|
|
33
|
-
|
|
34
1
|
# QUBASIC
|
|
35
2
|
|
|
36
3
|
Quantum computing in a BASIC REPL.
|
|
@@ -62,6 +29,10 @@ QUBASIC is a quantum computing environment built on Qiskit Aer that uses BASIC s
|
|
|
62
29
|
pip install qubasic
|
|
63
30
|
```
|
|
64
31
|
|
|
32
|
+
Optional extras: `qubasic[qec]` (stim + pymatching for circuit-level error
|
|
33
|
+
correction), `qubasic[jupyter]` (notebook kernel), `qubasic[qasm3]` (OpenQASM
|
|
34
|
+
3 import), `qubasic[charts]` (sweep charts).
|
|
35
|
+
|
|
65
36
|
Development install:
|
|
66
37
|
|
|
67
38
|
```
|
|
@@ -79,6 +50,8 @@ qubasic script.qb Run a script file
|
|
|
79
50
|
qubasic --quiet script Suppress banner, output results only
|
|
80
51
|
qubasic --json script Machine-readable JSON output
|
|
81
52
|
qubasic --spec Print a JSON contract (commands, gates, functions)
|
|
53
|
+
qubasic --web [port] Browser REPL (localhost, token-gated)
|
|
54
|
+
qubasic --install-kernel Install the Jupyter kernelspec (then pick "QUBASIC")
|
|
82
55
|
qubasic --help Show CLI help
|
|
83
56
|
```
|
|
84
57
|
|
|
@@ -206,7 +179,7 @@ RESET 0 Reset qubit to |0>
|
|
|
206
179
|
## Configuration
|
|
207
180
|
|
|
208
181
|
```
|
|
209
|
-
QUBITS 8 Set qubit count (
|
|
182
|
+
QUBITS 8 Set qubit count (ceiling is per METHOD)
|
|
210
183
|
SHOTS 2048 Set measurement shots
|
|
211
184
|
METHOD statevector Set simulation method
|
|
212
185
|
METHOD GPU Set simulation device
|
|
@@ -219,6 +192,13 @@ STATUS JSON Same, as machine-readable JSON
|
|
|
219
192
|
|
|
220
193
|
Automatic selection: stabilizer for Clifford-only circuits, MPS for >28 qubits, statevector otherwise.
|
|
221
194
|
|
|
195
|
+
Qubit ceilings are per method: the 32-qubit wall is a statevector memory
|
|
196
|
+
limit only. `stabilizer` reaches 4096 qubits (polynomial tableau),
|
|
197
|
+
`matrix_product_state` and `automatic` reach 1024 (MPS memory is set by
|
|
198
|
+
entanglement, not width), `extended_stabilizer` 63; an 881-qubit GHZ runs in
|
|
199
|
+
seconds on the stabilizer backend. Switching METHOD clamps QUBITS to the new
|
|
200
|
+
ceiling when needed.
|
|
201
|
+
|
|
222
202
|
## Variables and expressions
|
|
223
203
|
|
|
224
204
|
```
|
|
@@ -472,9 +452,16 @@ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
|
|
|
472
452
|
20 SAVE_EXPECT Z 0 -> cost
|
|
473
453
|
MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
|
|
474
454
|
MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
|
|
455
|
+
MINIMIZE a, b -> cost METHOD SPSA SPSA (2 evals/iter, robust to shot noise)
|
|
456
|
+
MINIMIZE a -> cost METHOD GRAD Parameter-shift gradient descent
|
|
475
457
|
GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
|
|
476
458
|
```
|
|
477
459
|
|
|
460
|
+
When the ansatz permits, MINIMIZE/GRADIENT/SWEEP compile the circuit once
|
|
461
|
+
with bound qiskit Parameters and only re-bind values per evaluation (reported
|
|
462
|
+
as "parametric compile") — an order of magnitude on variational loops. The
|
|
463
|
+
fallback for non-symbolic programs is the classic rebuild per step.
|
|
464
|
+
|
|
478
465
|
## Dynamic circuits (feedforward)
|
|
479
466
|
|
|
480
467
|
In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
|
|
@@ -516,26 +503,64 @@ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; need
|
|
|
516
503
|
```
|
|
517
504
|
HAMILTONIAN H = 1.0 ZZ 0 1 + 0.5 X 0 Declare a Pauli-sum Hamiltonian
|
|
518
505
|
HAMILTONIAN H = ISING 1.0 0.5 Builders: ISING, HEISENBERG, HUBBARD, RYDBERG
|
|
506
|
+
HAMILTONIAN H = MOLECULE H2 0.7414 H2/STO-3G (built-in integrals engine, no pyscf)
|
|
519
507
|
10 EVOLVE H, 1.5, 20 Trotterized e^{-iHt} (time, steps) in a circuit
|
|
520
|
-
|
|
508
|
+
10 SAVE_EXPECT H -> e <H> of a declared Hamiltonian (VQE cost)
|
|
509
|
+
LINDBLAD NONE, 1.0, 200, 1.0 SM 0 Open-system master-equation evolution (dense, <=5 qubits)
|
|
510
|
+
LINDBLAD H, 1.0, 200, 1.0 SM 0 TRAJ 500 Monte Carlo wavefunction unraveling (<=15 qubits)
|
|
521
511
|
CHANNEL AD = [[1,0],[0,0.95]] ; [[0,0.31],[0,0]] Define a Kraus channel
|
|
522
512
|
10 APPLYCHANNEL AD 0 Apply a custom channel
|
|
523
513
|
```
|
|
524
514
|
|
|
515
|
+
`MOLECULE H2 [R]` computes the exact 4-qubit Jordan-Wigner Hamiltonian from a
|
|
516
|
+
self-contained STO-3G integrals engine (Gaussian s-orbital closed forms, RHF
|
|
517
|
+
by symmetry). Exact diagonalization at R = 0.7414 reproduces the FCI energy
|
|
518
|
+
-1.1373 Ha, and a one-parameter VQE reaches it in ~30 evaluations.
|
|
519
|
+
|
|
525
520
|
## Error correction
|
|
526
521
|
|
|
527
522
|
```
|
|
528
523
|
QEC STEANE Show a code (REP [d], STEANE, SHOR, SURFACE [d]) and its stabilizers
|
|
524
|
+
QEC BB [l m] Bivariate-bicycle qLDPC (6 6 -> [[72,12,6]], 12 6 -> [[144,12,12]])
|
|
529
525
|
LOGICAL_ERROR_RATE STEANE 0.02 Monte-Carlo logical error rate (optimal lookup decoder)
|
|
530
|
-
LOGICAL_ERROR_RATE SURFACE 0.02 UF
|
|
526
|
+
LOGICAL_ERROR_RATE SURFACE 0.02 UF Union-find / matching decoder
|
|
527
|
+
LOGICAL_ERROR_RATE SURFACE 11 0.05 MWPM Batched pymatching MWPM (large distances)
|
|
528
|
+
LOGICAL_ERROR_RATE SURFACE 21 0.001 CIRCUIT 1000000 Circuit-level noise (stim + pymatching)
|
|
529
|
+
LOGICAL_ERROR_RATE BB 0.01 BB codes decode with the internal BP+OSD
|
|
531
530
|
THRESHOLD REP 0.0 0.5 11 Sweep p across distances 3/5/7 (crossing at 0.5)
|
|
532
531
|
DISTILL 0.02 15-to-1 magic-state distillation (output error ~35 p^3)
|
|
533
532
|
LATTICE 0 1 Lattice-surgery joint Zbar-Zbar measurement of two patches
|
|
534
533
|
```
|
|
535
534
|
|
|
536
535
|
Codes: repetition (any odd distance), Steane [[7,1,3]], Shor [[9,1,3]], rotated
|
|
537
|
-
surface
|
|
538
|
-
|
|
536
|
+
surface, and the bivariate-bicycle qLDPC family (parity checks built from the
|
|
537
|
+
cyclic-shift polynomials, k verified by GF(2) ranks). Decoders: an optimal
|
|
538
|
+
minimum-weight lookup table (all codes), a union-find / matching decoder (`UF`),
|
|
539
|
+
batched pymatching MWPM (`MWPM`), and an internal belief-propagation +
|
|
540
|
+
ordered-statistics decoder (BP+OSD-0) for the qLDPC codes.
|
|
541
|
+
|
|
542
|
+
`CIRCUIT` switches from code capacity to full circuit-level noise: stim
|
|
543
|
+
generates the noisy syndrome-extraction circuit (d rounds of gates,
|
|
544
|
+
measurements, and resets, each carrying errors), pymatching decodes the
|
|
545
|
+
detector error model, and millions of shots run in seconds — a d=21 surface
|
|
546
|
+
patch (944 physical qubits, 9240 detectors) samples at ~13k shots/s.
|
|
547
|
+
|
|
548
|
+
### Logical-qubit mode
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
LQUBITS 2 CODE SURFACE 5 PHYS 1e-3 Program on 2 LOGICAL qubits (surface, d=5)
|
|
552
|
+
10 H 0 Gates now act on logical qubits
|
|
553
|
+
20 CX 0,1 CX compiles to a lattice-surgery merge+split
|
|
554
|
+
30 MEASURE
|
|
555
|
+
RUN Histogram of LOGICAL outcomes
|
|
556
|
+
LQUBITS OFF Back to physical qubits
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
While active, every operation carries the code's per-op logical error channel
|
|
560
|
+
(from the code-capacity rate for the chosen code, distance, and physical p),
|
|
561
|
+
measurement carries a logical readout flip, and RUN appends the
|
|
562
|
+
lattice-surgery report: surgery ops, syndrome rounds, physical-qubit total,
|
|
563
|
+
wall time at 1 us/round, and the cumulative logical error budget.
|
|
539
564
|
|
|
540
565
|
## Benchmarking and verification
|
|
541
566
|
|
|
@@ -883,6 +908,11 @@ qubasic_core/
|
|
|
883
908
|
display.py Histograms, statevector, Bloch sphere rendering
|
|
884
909
|
locc.py LOCC commands, execution, display
|
|
885
910
|
analysis.py EXPECT, ENTROPY, DENSITY, BENCH, RAM
|
|
911
|
+
qec2.py Circuit-level QEC (stim/pymatching), BB qLDPC, BP+OSD
|
|
912
|
+
logical.py LQUBITS logical-qubit mode + lattice-surgery report
|
|
913
|
+
qchem.py STO-3G molecular Hamiltonians (MOLECULE H2)
|
|
914
|
+
jupyter_kernel.py Jupyter kernel (qubasic --install-kernel)
|
|
915
|
+
web_repl.py Browser REPL (qubasic --web)
|
|
886
916
|
sweep.py Parameter sweep with plotille charts
|
|
887
917
|
memory.py PEEK/POKE/SYS/DUMP/MAP/MONITOR
|
|
888
918
|
strings.py String functions
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qubasic"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.16.0"
|
|
8
8
|
description = "Quantum BASIC Interactive Terminal"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -40,6 +40,9 @@ Issues = "https://github.com/CharlesCNorton/qubasic/issues"
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
charts = ["plotille>=5.0"]
|
|
42
42
|
readline = ["pyreadline3>=3.4; sys_platform == 'win32'"]
|
|
43
|
+
qasm3 = ["qiskit-qasm3-import>=0.4"]
|
|
44
|
+
qec = ["stim>=1.12", "pymatching>=2.1"]
|
|
45
|
+
jupyter = ["ipykernel>=6.0", "jupyter-client>=7.0"]
|
|
43
46
|
|
|
44
47
|
[project.scripts]
|
|
45
48
|
qubasic = "qubasic_core.cli:main"
|
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qubasic
|
|
3
|
+
Version: 0.16.0
|
|
4
|
+
Summary: Quantum BASIC Interactive Terminal
|
|
5
|
+
Author-email: "Charles C. Norton" <machineelv@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/CharlesCNorton/qubasic
|
|
8
|
+
Project-URL: Repository, https://github.com/CharlesCNorton/qubasic
|
|
9
|
+
Project-URL: Issues, https://github.com/CharlesCNorton/qubasic/issues
|
|
10
|
+
Keywords: quantum,computing,qiskit,basic,repl,simulator
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: qiskit>=1.0
|
|
24
|
+
Requires-Dist: qiskit-aer>=0.13
|
|
25
|
+
Requires-Dist: numpy>=1.24
|
|
26
|
+
Requires-Dist: psutil>=5.9
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Provides-Extra: charts
|
|
29
|
+
Requires-Dist: plotille>=5.0; extra == "charts"
|
|
30
|
+
Provides-Extra: readline
|
|
31
|
+
Requires-Dist: pyreadline3>=3.4; sys_platform == "win32" and extra == "readline"
|
|
32
|
+
Provides-Extra: qasm3
|
|
33
|
+
Requires-Dist: qiskit-qasm3-import>=0.4; extra == "qasm3"
|
|
34
|
+
Provides-Extra: qec
|
|
35
|
+
Requires-Dist: stim>=1.12; extra == "qec"
|
|
36
|
+
Requires-Dist: pymatching>=2.1; extra == "qec"
|
|
37
|
+
Provides-Extra: jupyter
|
|
38
|
+
Requires-Dist: ipykernel>=6.0; extra == "jupyter"
|
|
39
|
+
Requires-Dist: jupyter-client>=7.0; extra == "jupyter"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
1
42
|
# QUBASIC
|
|
2
43
|
|
|
3
44
|
Quantum computing in a BASIC REPL.
|
|
@@ -29,6 +70,10 @@ QUBASIC is a quantum computing environment built on Qiskit Aer that uses BASIC s
|
|
|
29
70
|
pip install qubasic
|
|
30
71
|
```
|
|
31
72
|
|
|
73
|
+
Optional extras: `qubasic[qec]` (stim + pymatching for circuit-level error
|
|
74
|
+
correction), `qubasic[jupyter]` (notebook kernel), `qubasic[qasm3]` (OpenQASM
|
|
75
|
+
3 import), `qubasic[charts]` (sweep charts).
|
|
76
|
+
|
|
32
77
|
Development install:
|
|
33
78
|
|
|
34
79
|
```
|
|
@@ -46,6 +91,8 @@ qubasic script.qb Run a script file
|
|
|
46
91
|
qubasic --quiet script Suppress banner, output results only
|
|
47
92
|
qubasic --json script Machine-readable JSON output
|
|
48
93
|
qubasic --spec Print a JSON contract (commands, gates, functions)
|
|
94
|
+
qubasic --web [port] Browser REPL (localhost, token-gated)
|
|
95
|
+
qubasic --install-kernel Install the Jupyter kernelspec (then pick "QUBASIC")
|
|
49
96
|
qubasic --help Show CLI help
|
|
50
97
|
```
|
|
51
98
|
|
|
@@ -173,7 +220,7 @@ RESET 0 Reset qubit to |0>
|
|
|
173
220
|
## Configuration
|
|
174
221
|
|
|
175
222
|
```
|
|
176
|
-
QUBITS 8 Set qubit count (
|
|
223
|
+
QUBITS 8 Set qubit count (ceiling is per METHOD)
|
|
177
224
|
SHOTS 2048 Set measurement shots
|
|
178
225
|
METHOD statevector Set simulation method
|
|
179
226
|
METHOD GPU Set simulation device
|
|
@@ -186,6 +233,13 @@ STATUS JSON Same, as machine-readable JSON
|
|
|
186
233
|
|
|
187
234
|
Automatic selection: stabilizer for Clifford-only circuits, MPS for >28 qubits, statevector otherwise.
|
|
188
235
|
|
|
236
|
+
Qubit ceilings are per method: the 32-qubit wall is a statevector memory
|
|
237
|
+
limit only. `stabilizer` reaches 4096 qubits (polynomial tableau),
|
|
238
|
+
`matrix_product_state` and `automatic` reach 1024 (MPS memory is set by
|
|
239
|
+
entanglement, not width), `extended_stabilizer` 63; an 881-qubit GHZ runs in
|
|
240
|
+
seconds on the stabilizer backend. Switching METHOD clamps QUBITS to the new
|
|
241
|
+
ceiling when needed.
|
|
242
|
+
|
|
189
243
|
## Variables and expressions
|
|
190
244
|
|
|
191
245
|
```
|
|
@@ -439,9 +493,16 @@ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
|
|
|
439
493
|
20 SAVE_EXPECT Z 0 -> cost
|
|
440
494
|
MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
|
|
441
495
|
MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
|
|
496
|
+
MINIMIZE a, b -> cost METHOD SPSA SPSA (2 evals/iter, robust to shot noise)
|
|
497
|
+
MINIMIZE a -> cost METHOD GRAD Parameter-shift gradient descent
|
|
442
498
|
GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
|
|
443
499
|
```
|
|
444
500
|
|
|
501
|
+
When the ansatz permits, MINIMIZE/GRADIENT/SWEEP compile the circuit once
|
|
502
|
+
with bound qiskit Parameters and only re-bind values per evaluation (reported
|
|
503
|
+
as "parametric compile") — an order of magnitude on variational loops. The
|
|
504
|
+
fallback for non-symbolic programs is the classic rebuild per step.
|
|
505
|
+
|
|
445
506
|
## Dynamic circuits (feedforward)
|
|
446
507
|
|
|
447
508
|
In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
|
|
@@ -483,26 +544,64 @@ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; need
|
|
|
483
544
|
```
|
|
484
545
|
HAMILTONIAN H = 1.0 ZZ 0 1 + 0.5 X 0 Declare a Pauli-sum Hamiltonian
|
|
485
546
|
HAMILTONIAN H = ISING 1.0 0.5 Builders: ISING, HEISENBERG, HUBBARD, RYDBERG
|
|
547
|
+
HAMILTONIAN H = MOLECULE H2 0.7414 H2/STO-3G (built-in integrals engine, no pyscf)
|
|
486
548
|
10 EVOLVE H, 1.5, 20 Trotterized e^{-iHt} (time, steps) in a circuit
|
|
487
|
-
|
|
549
|
+
10 SAVE_EXPECT H -> e <H> of a declared Hamiltonian (VQE cost)
|
|
550
|
+
LINDBLAD NONE, 1.0, 200, 1.0 SM 0 Open-system master-equation evolution (dense, <=5 qubits)
|
|
551
|
+
LINDBLAD H, 1.0, 200, 1.0 SM 0 TRAJ 500 Monte Carlo wavefunction unraveling (<=15 qubits)
|
|
488
552
|
CHANNEL AD = [[1,0],[0,0.95]] ; [[0,0.31],[0,0]] Define a Kraus channel
|
|
489
553
|
10 APPLYCHANNEL AD 0 Apply a custom channel
|
|
490
554
|
```
|
|
491
555
|
|
|
556
|
+
`MOLECULE H2 [R]` computes the exact 4-qubit Jordan-Wigner Hamiltonian from a
|
|
557
|
+
self-contained STO-3G integrals engine (Gaussian s-orbital closed forms, RHF
|
|
558
|
+
by symmetry). Exact diagonalization at R = 0.7414 reproduces the FCI energy
|
|
559
|
+
-1.1373 Ha, and a one-parameter VQE reaches it in ~30 evaluations.
|
|
560
|
+
|
|
492
561
|
## Error correction
|
|
493
562
|
|
|
494
563
|
```
|
|
495
564
|
QEC STEANE Show a code (REP [d], STEANE, SHOR, SURFACE [d]) and its stabilizers
|
|
565
|
+
QEC BB [l m] Bivariate-bicycle qLDPC (6 6 -> [[72,12,6]], 12 6 -> [[144,12,12]])
|
|
496
566
|
LOGICAL_ERROR_RATE STEANE 0.02 Monte-Carlo logical error rate (optimal lookup decoder)
|
|
497
|
-
LOGICAL_ERROR_RATE SURFACE 0.02 UF
|
|
567
|
+
LOGICAL_ERROR_RATE SURFACE 0.02 UF Union-find / matching decoder
|
|
568
|
+
LOGICAL_ERROR_RATE SURFACE 11 0.05 MWPM Batched pymatching MWPM (large distances)
|
|
569
|
+
LOGICAL_ERROR_RATE SURFACE 21 0.001 CIRCUIT 1000000 Circuit-level noise (stim + pymatching)
|
|
570
|
+
LOGICAL_ERROR_RATE BB 0.01 BB codes decode with the internal BP+OSD
|
|
498
571
|
THRESHOLD REP 0.0 0.5 11 Sweep p across distances 3/5/7 (crossing at 0.5)
|
|
499
572
|
DISTILL 0.02 15-to-1 magic-state distillation (output error ~35 p^3)
|
|
500
573
|
LATTICE 0 1 Lattice-surgery joint Zbar-Zbar measurement of two patches
|
|
501
574
|
```
|
|
502
575
|
|
|
503
576
|
Codes: repetition (any odd distance), Steane [[7,1,3]], Shor [[9,1,3]], rotated
|
|
504
|
-
surface
|
|
505
|
-
|
|
577
|
+
surface, and the bivariate-bicycle qLDPC family (parity checks built from the
|
|
578
|
+
cyclic-shift polynomials, k verified by GF(2) ranks). Decoders: an optimal
|
|
579
|
+
minimum-weight lookup table (all codes), a union-find / matching decoder (`UF`),
|
|
580
|
+
batched pymatching MWPM (`MWPM`), and an internal belief-propagation +
|
|
581
|
+
ordered-statistics decoder (BP+OSD-0) for the qLDPC codes.
|
|
582
|
+
|
|
583
|
+
`CIRCUIT` switches from code capacity to full circuit-level noise: stim
|
|
584
|
+
generates the noisy syndrome-extraction circuit (d rounds of gates,
|
|
585
|
+
measurements, and resets, each carrying errors), pymatching decodes the
|
|
586
|
+
detector error model, and millions of shots run in seconds — a d=21 surface
|
|
587
|
+
patch (944 physical qubits, 9240 detectors) samples at ~13k shots/s.
|
|
588
|
+
|
|
589
|
+
### Logical-qubit mode
|
|
590
|
+
|
|
591
|
+
```
|
|
592
|
+
LQUBITS 2 CODE SURFACE 5 PHYS 1e-3 Program on 2 LOGICAL qubits (surface, d=5)
|
|
593
|
+
10 H 0 Gates now act on logical qubits
|
|
594
|
+
20 CX 0,1 CX compiles to a lattice-surgery merge+split
|
|
595
|
+
30 MEASURE
|
|
596
|
+
RUN Histogram of LOGICAL outcomes
|
|
597
|
+
LQUBITS OFF Back to physical qubits
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
While active, every operation carries the code's per-op logical error channel
|
|
601
|
+
(from the code-capacity rate for the chosen code, distance, and physical p),
|
|
602
|
+
measurement carries a logical readout flip, and RUN appends the
|
|
603
|
+
lattice-surgery report: surgery ops, syndrome rounds, physical-qubit total,
|
|
604
|
+
wall time at 1 us/round, and the cumulative logical error budget.
|
|
506
605
|
|
|
507
606
|
## Benchmarking and verification
|
|
508
607
|
|
|
@@ -850,6 +949,11 @@ qubasic_core/
|
|
|
850
949
|
display.py Histograms, statevector, Bloch sphere rendering
|
|
851
950
|
locc.py LOCC commands, execution, display
|
|
852
951
|
analysis.py EXPECT, ENTROPY, DENSITY, BENCH, RAM
|
|
952
|
+
qec2.py Circuit-level QEC (stim/pymatching), BB qLDPC, BP+OSD
|
|
953
|
+
logical.py LQUBITS logical-qubit mode + lattice-surgery report
|
|
954
|
+
qchem.py STO-3G molecular Hamiltonians (MOLECULE H2)
|
|
955
|
+
jupyter_kernel.py Jupyter kernel (qubasic --install-kernel)
|
|
956
|
+
web_repl.py Browser REPL (qubasic --web)
|
|
853
957
|
sweep.py Parameter sweep with plotille charts
|
|
854
958
|
memory.py PEEK/POKE/SYS/DUMP/MAP/MONITOR
|
|
855
959
|
strings.py String functions
|
|
@@ -38,11 +38,13 @@ qubasic_core/file_io.py
|
|
|
38
38
|
qubasic_core/gates.py
|
|
39
39
|
qubasic_core/help_text.py
|
|
40
40
|
qubasic_core/io_protocol.py
|
|
41
|
+
qubasic_core/jupyter_kernel.py
|
|
41
42
|
qubasic_core/locc.py
|
|
42
43
|
qubasic_core/locc_commands.py
|
|
43
44
|
qubasic_core/locc_display.py
|
|
44
45
|
qubasic_core/locc_engine.py
|
|
45
46
|
qubasic_core/locc_execution.py
|
|
47
|
+
qubasic_core/logical.py
|
|
46
48
|
qubasic_core/memory.py
|
|
47
49
|
qubasic_core/mock_backend.py
|
|
48
50
|
qubasic_core/noise_mixin.py
|
|
@@ -52,7 +54,9 @@ qubasic_core/pauliprop.py
|
|
|
52
54
|
qubasic_core/profiler.py
|
|
53
55
|
qubasic_core/program_mgmt.py
|
|
54
56
|
qubasic_core/protocol.py
|
|
57
|
+
qubasic_core/qchem.py
|
|
55
58
|
qubasic_core/qec.py
|
|
59
|
+
qubasic_core/qec2.py
|
|
56
60
|
qubasic_core/qol.py
|
|
57
61
|
qubasic_core/qudits.py
|
|
58
62
|
qubasic_core/resources.py
|
|
@@ -64,5 +68,7 @@ qubasic_core/strings.py
|
|
|
64
68
|
qubasic_core/subs.py
|
|
65
69
|
qubasic_core/sweep.py
|
|
66
70
|
qubasic_core/terminal.py
|
|
71
|
+
qubasic_core/web_repl.py
|
|
67
72
|
tests/test_features.py
|
|
73
|
+
tests/test_golden.py
|
|
68
74
|
tests/test_qubasic.py
|