Skip to content

perf(hex-matrix): Submatrix views for the mulStrassen recursion#8734

Open
kim-em wants to merge 1 commit into
mainfrom
issue-8652-submatrix
Open

perf(hex-matrix): Submatrix views for the mulStrassen recursion#8734
kim-em wants to merge 1 commit into
mainfrom
issue-8652-submatrix

Conversation

@kim-em

@kim-em kim-em commented Jul 11, 2026

Copy link
Copy Markdown
Owner

This PR add the Submatrix view type — named after Lean's Subarray/Substring: a base matrix plus row/column offsets and block dimensions, whose entry reads are pure offset arithmetic into the shared flat buffer — and rewire mulStrassen's internal recursion over views, so quadrants stop being materialized copies (the generated C shows zero quadrant-copy allocations; allocation remains only for the operand sums, the seven recursive products, padding, and leaf materialization for the unchanged baseMul signature). mulStrassen_eq_mul is re-proved through view-to-Matrix abstraction lemmas with the algorithm, its statement, and the three named correctness lemmas untouched; the colAdd/colAddRight/colSwap family moves from the materializing mapRows pass to flat per-entry column engines with unchanged public lemma statements; and the SPEC's BlockView mentions are renamed. The re-measured cost model is honestly neutral: the cutoff sweep and scaling series on the view recursion are within noise of the committed flat baseline (0.99–1.01× everywhere — the removed copies are O(n²) per level against O(n^2.81) multiply work, so they never dominated at benched sizes), so strassenDefault.cutoff stays at the measured 96, with the committed exports and overlay figure recording the outcome. Whole-graph and root-invalidated builds green (4160 jobs), conformance green, no sorry/axiom/native_decide. Closes #8652.

🤖 Prepared with Claude Code

Add the Submatrix view type (Subarray-style: base matrix, row/col
offsets, block dimensions; entry reads are offset arithmetic into the
shared flat buffer) and rewire mulStrassen's internal recursion over
views, so quadrants stop being materialized copies — generated C shows
zero quadrant-copy allocations, with allocation remaining only for the
operand sums, the seven products, padding, and leaf materialization for
the unchanged baseMul signature. mulStrassen_eq_mul is re-proved via
view-to-Matrix abstraction lemmas; the algorithm, its statement, and
the three named correctness lemmas are untouched. The colAdd family
moves from the materializing mapRows pass to flat per-entry column
engines with unchanged public lemma statements. Cost model re-measured
on the view recursion: cutoff sweep and scaling series within noise of
the committed flat baseline (0.99-1.01x), so strassenDefault.cutoff
stays at the measured 96; the committed exports and overlay figure
record the outcome.

Closes #8652.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(hex-matrix): flat Vector R (n*m) backing for Matrix

1 participant