perf(solvers): zero-copy col-major QR native kernel + call-time GRADWAVE_EIGENSOLVER read - #469
Merged
Merged
Conversation
…ly scatter zeroing in the native Davidson kernel The row-major (rows, m) basis block is byte-identical to the col-major (m, rows) matrix whose columns are the basis vectors, so zgeqrf/zungqr now run directly on the buffers (LAPACK_COL_MAJOR) — deleting the two explicit transposes plus LAPACKE's hidden row-major transpose copies (~6 full passes per orthonormalization). Hot elementwise loops (kinetic, v_eff multiply, residual norms, Teter directions) move to planar double views with omp simd. The per-band full-box memset becomes 2m sphere-slot writes against a kept-zero scatter buffer (m/n ~ 0.06-0.1), with the forward FFT landing in a separate gather box. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018j6BBnPtBSjkrnASSc52mT
The import-frozen copy silently ignored os.environ set after gradwave was imported — an in-process solver override no-oped and a benchmark ladder's "native" arms all ran eager. Tests now pin the override via the actual environment (monkeypatch.setenv) to lock in the call-time contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018j6BBnPtBSjkrnASSc52mT
This was referenced Sep 10, 2026
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
Two changes to the native Davidson stack:
solvers/native/davidson_native.c) — zero-copy col-major QR (zgeqrf/zungqrrun directly on the basis buffers, exploiting that a row-major(rows, m)block is byte-identical to the col-major(m, rows)matrix whose columns are the basis vectors — deletes 2 explicit + ~4 hidden LAPACKE transpose passes per orthonormalization), planar-double SIMD elementwise loops (kinetic, v_eff multiply, residual norms, Teter directions), and sphere-only scatter-buffer zeroing instead of a full(n+1)-point memset per band (m/n ≈ 0.06–0.1).GRADWAVE_EIGENSOLVERread at call time, not import time (scf/loop.py) — the import-frozen copy silently ignoredos.environset afterimport gradwave. This is not cosmetic: it silently degraded every "native" arm of a benchmark ladder to eager (identical wall to eager at every thread count was the tell). Tests now pin the override viamonkeypatch.setenvto lock in the call-time contract.Measured (asus, 22-core, same-harness A/B, per-solve spy verifying the native path engaged — zero fallbacks; identical F and iteration counts in every arm)
Al-4 conv 4³ FD and Al-1 fcc 8³ FD, ecut 30 Ry, full SCF wall:
Honest verdict: the kernel rewrite is an end-to-end wash vs the old kernel (≤2%, within noise). It ships because it is strictly cleaner (fewer memory passes, no LAPACKE hidden copies), never slower, and the measurement campaign it enabled corrects two records:
eigensolver: davidson-native), identical free energies to all printed digits. Last night's "9.8 s" figure was harness-inflated.External proxy note: VASP is not runnable on this infrastructure; QE (same box, same ONCV pseudos/ecut/k-mesh) remains the honest external reference — QE pw.x Al-4 best 0.6–2.3 s, so the small-cell gap is now ~3–8× (was ~2–9×).
8/8 native unit tests pass against the new
.so; the fast tier passes on asus with the branch.soactive.🤖 Generated with Claude Code
https://claude.ai/code/session_018j6BBnPtBSjkrnASSc52mT