Repository navigation
Fix magnetic-field sign, add fast HF Fock path, and restore green CI - #9
Open
skilledwolf wants to merge 6 commits into
Open
skilledwolf wants to merge 6 commits into
skilledwolf wants to merge 6 commits into
Conversation
Versions <= 1.1.x silently inverted sign_magneticfield relative to the
analytic convention documented in docs/conventions.md: a caller-supplied
sign_magneticfield=X produced results corresponding to sigma=-X. This
affected every backend (laguerre, ogata, hankel, legendre) and the fast
Fock-apply path. For Hermitian single-LL densities the hidden identity
X^sigma[a,b,p,q] = X^{-sigma}[p,q,a,b] masked the bug, but multi-LL
contractions and anything reading the literal kernel values were wrong
(~1% on representative hex WC benchmarks).
Fixes in this release:
- _evaluate_exchange_kernels_laguerre_numba and _ogata_q_evaluate_numba:
relabel d_in = m2 - n2, d_out = m1 - n1 and access
phase_in[d_in] * phase_out[d_out], matching the analytic phase
i^{a_tot} (-1)^{d_in} exp(i sigma (d_out - d_in) theta).
- exchange_ogata, exchange_hankel, exchange_legendre: invert the gating
of the post-hoc sign-flip branch so sign_magneticfield=X yields sigma=X.
- _exchange_fock_numba: restructure so it applies X as the canonical
(n1,m1) -> (n2,m2) linear map used throughout the rest of the library
(including _build_compressed_constructor) instead of the transposed
(n2,m2) -> (n1,m1) map it was silently implementing.
Added tests/test_coulomb_analytic_general.py, which gates every backend
x sign_magneticfield = +/-1 against an mpmath closed-form Coulomb
integral, plus cross-backend and form-factor <-> exchange-kernel
consistency checks.
Docs/README now carry a prominent warning about the historical bug and
link to CHANGELOG.md. Callers that must reproduce pre-1.2.0 numerics
should pin quantumhall-matrixelements<1.2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The HF-convention exchange Fock apply (used by quantumhall_hf) lacked
a counterpart to the Numba-JIT fast path that exists for the standard
convention. Previously get_fockmatrix_constructor_hf always built the
compressed (values, select) representation and applied it via vectorized
np.add.at — fast at nmax=1,2 but bottlenecked at nmax >= 3.
For the default method='laguerre' case, get_fockmatrix_constructor_hf
now materializes the full kernel tensor once and applies via BLAS-backed
np.einsum (with a precomputed contraction path). Measured ~3.4x speedup
at nmax=4, ~10x at nmax=8; roughly tied at nmax=1,2. Falls back to the
compressed apply if the full tensor would exceed memory limits.
Also adds ExchangeFockPrecompute.exchange_fock_hf, a Numba HF apply
that mirrors exchange_fock for the HF index pattern (cost O(nmax^4 * Nq)
per G; useful as a reference / for memory-constrained workloads).
New test cross-checks the fast HF path against the existing compressed
apply for nmax in {1..4} and both sign_magneticfield choices.
100/100 matrixelements tests pass; 144/144 quantumhall_hf tests pass.
The test loaded a helper from the untracked playground/ directory at import time, so collection failed in CI. Inline the independent Eq. (13) closed form instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sphinx-gallery requires a titled docstring; sphinx -W failed on three examples without one. Also fix the list indentation and bare |G| that docutils parsed as a substitution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop unused full-tensor imports from fock.py, sort imports in the HF constructor test, and build the exhaustive select list with itertools.product. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
tests/test_symmetric_onebody.py. It used to load the untrackedplayground/helper, which broke collection in CI.compare_exchange_backends,plot_form_factors_radialandplot_exchange_kernels_radialvalid RST titles, and fix the list indentation and the bare|G|, which docutils read as a substitution, sosphinx -Wpassesfock.py, sort the imports (I001), and fix PERF401 withitertools.productactions/checkoutto v5 andactions/setup-pythonto v6 (Node 24)Verification
Checked locally in a clean clone without
playground/:ruff check .passesmypypassespytest -m "not release"passespython -m sphinx -W --keep-going -b html docs <tmp>exits 0🤖 Generated with Claude Code