Skip to content

perf(ldlt): improve factorization kernel#151

Merged
acgetchell merged 1 commit into
mainfrom
perf/146-ldlt-kernel
Jun 9, 2026
Merged

perf(ldlt): improve factorization kernel#151
acgetchell merged 1 commit into
mainfrom
perf/146-ldlt-kernel

Conversation

@acgetchell

@acgetchell acgetchell commented Jun 9, 2026

Copy link
Copy Markdown
Owner
  • Preserve the tiny-dimension update shape for D2-D5 to avoid regressing the core fixed-size path
  • Fuse multiplier computation with trailing updates for larger dimensions to reduce extra column walks
  • Rely on the LDLT factorization proof instead of a redundant final finite-storage scan

Closes #146

Summary by CodeRabbit

  • Performance

    • LDLT factorization now uses optimized computation paths based on matrix dimensions for improved performance.
  • Bug Fixes & Robustness

    • Enhanced error detection for non-finite values and invalid pivots during matrix factorization.
    • Expanded test coverage for edge cases.
  • Documentation

    • Clarified documentation for matrix operations.

- Preserve the tiny-dimension update shape for D2-D5 to avoid regressing the core fixed-size path
- Fuse multiplier computation with trailing updates for larger dimensions to reduce extra column walks
- Rely on the LDLT factorization proof instead of a redundant final finite-storage scan

Closes #146
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b14bcb4-3e64-48cf-8b28-1c39ab8f01b4

📥 Commits

Reviewing files that changed from the base of the PR and between 9a869fc and 8837df1.

📒 Files selected for processing (2)
  • src/ldlt.rs
  • src/matrix.rs

📝 Walkthrough

Walkthrough

The PR optimizes LDLT factorization by splitting the rank-1 update loop into two compile-time paths: for D ≤ 5, multipliers are computed first then the trailing submatrix is updated; for D > 5, multiplier computation is fused with trailing-row updates to reduce overhead. New tests validate overflow detection in the fused-update path.

Changes

LDLT Factorization Kernel Optimization

Layer / File(s) Summary
LDLT rank-1 update split by dimension threshold
src/ldlt.rs
factor_symmetric's LDLT update loop conditionally branches at compile time based on D <= 5 vs larger dimensions. The smaller-D path separates multiplier computation from the trailing submatrix update; the larger-D path fuses multiplier computation with trailing-row prefix updates in the same inner loop. Both paths retain non-finite entry checks, positive-semidefinite pivot validation, and correct lower-triangular storage.
Fused-update overflow test coverage
src/ldlt.rs
Two new 6x6 test cases exercise the D > 5 fused-update branch: nonfinite_l_multiplier_overflow_fused_branch_6d constructs a Gram-like matrix that overflows during L-multiplier computation and asserts LaError::NonFinite with row: Some(5), col: 0; nonfinite_trailing_submatrix_overflow_fused_branch_6d exercises trailing-diagonal overflow and asserts LaError::NonFinite with row: Some(5), col: 5.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • acgetchell/la-stack#129: Introduced factor_symmetric via SymmetricMatrix, which this PR now further optimizes with compile-time dimension branching.
  • acgetchell/la-stack#136: Previously modified LDLT rank-1 and trailing-update logic and non-finite validation during that phase, establishing the baseline this PR branches from.
  • acgetchell/la-stack#146: The performance investigation that motivated this kernel optimization.

Suggested labels

enhancement, rust

Poem

🐰 A rabbit hops through LDLT's loop,
Splitting branching at five—then swoop!
Small D's keep multipliers neat and pure,
Larger D fuses updates for sure.
Overflow caught at every turn,
Tests confirm what factorizations learn! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'perf(ldlt): improve factorization kernel' directly and specifically describes the primary change: a performance improvement to the LDLT factorization implementation.
Linked Issues check ✅ Passed The PR successfully addresses issue #146 objectives: splits LDLT updates for D≤5 vs larger dimensions to reduce overhead [#146], preserves the finite-by-construction invariant [#146], maintains the solve API [#146], and keeps error behavior unchanged [#146].
Out of Scope Changes check ✅ Passed All changes are in-scope: src/ldlt.rs contains the targeted LDLT kernel optimization with new test coverage, and src/matrix.rs contains a documentation clarification related to the finite invariant preservation, both supporting the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/146-ldlt-kernel

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.25%. Comparing base (9a869fc) to head (8837df1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   98.23%   98.25%   +0.01%     
==========================================
  Files           7        7              
  Lines        3228     3264      +36     
==========================================
+ Hits         3171     3207      +36     
  Misses         57       57              
Flag Coverage Δ
unittests 98.25% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acgetchell acgetchell merged commit 6d819df into main Jun 9, 2026
18 checks passed
@acgetchell acgetchell deleted the perf/146-ldlt-kernel branch June 9, 2026 01:59
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: improve LDLT factorization kernel

1 participant