benches: add mlxQ exact-statevector baseline (Apple silicon) to the third-party Pauli benchmark - #183
Open
BoltzmannEntropy wants to merge 1 commit into
Conversation
…mark Adds an exact (non-propagation) baseline to benches/third_party/pauli_prop: mlxQ, an MLX statevector simulator for Apple-silicon GPUs. Wherever the 2^n statevector fits, its per-step cost is independent of operator growth, so it locates the lattice size below which Pauli propagation is not worth running (~25-28 qubits against monoprop on an M1 Max, 32 GB). - backends.py: run_mlxq() following the existing per-backend pattern (lazy imports, one Trotter step + expectation per timed point); registered in MEMORY_METRICS/LABELS/THREAD_VARS and a new APPLE_BACKENDS group. - run_model.py / run_one.py: dispatch + choices for the new group. Also make _num_threads portable to macOS (os.sched_getaffinity does not exist there). - README: install and usage note; the backend is deliberately not in the uv project's dependencies since MLX wheels only exist for Apple silicon. Cross-validated against monoprop at 3x3/3x4: expectation values agree to ~2.6e-5 (monoprop's lower_atol=1e-6 truncation plus mlxQ's complex64).
BoltzmannEntropy
requested review from
diagonal-hamiltonian,
fpietra,
ludmilaasb and
robertodr
as code owners
August 2, 2026 03:30
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
- Coverage 87.56% 87.44% -0.12%
==========================================
Files 59 59
Lines 4239 4239
Branches 1497 1497
==========================================
- Hits 3712 3707 -5
- Misses 163 164 +1
- Partials 364 368 +4
Flags with carried forward coverage won't be shown. Click here to find out more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
An exact statevector baseline for the third-party Pauli benchmark: mlxQ, an MLX-based simulator for Apple-silicon GPUs, wired in as a
mlxqbackend following the existing per-backend pattern inbenches/third_party/pauli_prop/backends.py(lazy imports inside the function, one Trotter step + expectation value per timed point, same timer bracket).Pauli propagation's natural competitor at small-to-medium sizes is exact simulation, and none of the current backends provides that reference. Wherever the 2^n statevector fits in memory its per-step cost is independent of operator growth, so this backend locates the lattice size below which propagation is not worth running — and, symmetrically, makes the size where propagation wins unarguable.
Changes:
backends.py:run_mlxq()+ registration (MEMORY_METRICS,LABELS,THREAD_VARS, newAPPLE_BACKENDSgroup).run_model.py/run_one.py: dispatch and--backends/--backendchoices.run_one.py:_num_threadsnow falls back toos.cpu_count()—os.sched_getaffinitydoes not exist on macOS, sorun_one.py/run_scaling.pypreviously could not run there for any backend.benches/third_party/README.md: install/usage note.Measured (your committed TFIM scenario, resized)
Apple M1 Max (32 GB), macOS 26.3, monoprop 0.8.0 PyPI wheel, medians over ≥3 dedicated-process runs, per-point timing identical to
_run_steps:Full report with raw per-run data, the kicked-Ising counterpart, and fairness caveats: https://github.com/BoltzmannEntropy/Qupertino/tree/main/bench/monoprop_compare.
Correctness
Cross-validated against monoprop at 3x3/3x4 via
run_model.py: expectation values agree to ~2.6e-5 (yourlower_atol=1e-6truncation plus mlxQ's complex64). Independently, both engines match a dense-matrixexpmreference (monoprop to ~1e-14, mlxQ to ~1e-6).Notes for maintainers
mlxqis intentionally not added to the uv project — MLX wheels only exist for macOS/arm64 and the currentpyproject.tomlpins CUDA packages that can't resolve there anyway. Happy to add it behind asys_platform == "darwin"marker instead if you prefer lockfile-managed installs.ExpGate's parameter p acts as exp(−i·p·P) — back-propagating Z through an X gate with parameter p returns cos(2p) — while the README quick-example comments read as exp(−i·θ/2·P). The library is self-consistent; a clarifying line in the docstring would save independent users a debugging cycle.ruff format/ruff check(the oneI001onbackends.pyimports fires on the untouched file as well outside the prek context).