perf(exact): restore small-matrix det_sign_exact throughput#182
Conversation
- Reuse proof-bearing shared minors for D4 determinant and permanent evaluation. - Restore the dense D3 filter while preserving sparse, overflow, and underflow fallbacks. - Require headline benchmarks to exercise the intended filter and document historical harness overhead. Closes #157
📝 WalkthroughWalkthroughD=3 and D=4 determinant fast paths now use streamlined arithmetic and shared-minor proof handling. Error-bound and overflow tests expand coverage, while benchmark assertions and documentation clarify direct-filter behavior and historical comparison methodology. ChangesDeterminant fast paths and benchmark validation
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #182 +/- ##
==========================================
- Coverage 97.77% 97.77% -0.01%
==========================================
Files 8 8
Lines 4684 4768 +84
==========================================
+ Hits 4580 4662 +82
- Misses 104 106 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/exact_bench_config.rs (1)
151-162: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGenerate per-dimension tests through the required macro.
This test manually repeats the D=2–5 baseline assertions. Use a dimension-literal macro to generate independently named tests while retaining the adversarial fixture checks.
As per coding guidelines, dimension-generic tests must use a macro invoked for D=2, 3, 4, and 5.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/exact_bench_config.rs` around lines 151 - 162, Replace the repeated baseline assertions in det_sign_exact_benchmark_filter_paths_are_stable with the required dimension-literal macro, invoking it for dimensions 2, 3, 4, and 5 to generate independently named tests. Keep the near_singular_3x3_input, large_entries_3x3_input, and Hilbert fixture assertions in the test coverage.Source: Coding guidelines
src/matrix.rs (1)
1866-1884: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd matching
det_errbound/det_direct_with_errboundassertions for the new overflow fixtures.These tests correctly exercise the new dense shared-minor/permanent kernels for
det_direct()/det(), but the same matrices would be a good check thatdet4_dense_abs_permanent_elements/det3_abs_permanent_elements's dense path — the actual bound-computation code changed by this PR — also surfacesNonFiniterather than silently returning an unbounded or incorrect value. Note the expected error differs:det_errbound()/det_direct_with_errbound()classify the failure asArithmeticOperation::DeterminantErrorBound(checked before the determinant's own finiteness indet_direct_with_errbound_from_arithmetic), notDeterminant.Based on the coding guideline "Unit tests should cover known values, error paths, and dimension-generic correctness across D=2..=5," and since this is precisely the changed critical path, this seems worth the small addition. Happy to draft the two test functions if useful.
🧪 Proposed additional coverage
#[test] fn det_errbound_d3_dense_reports_legitimate_overflow() { let scale = 1.6e102; let m = black_box( Matrix::<3>::try_from_rows([ [4.0 * scale, scale, scale], [scale, 4.0 * scale, scale], [scale, scale, 4.0 * scale], ]) .unwrap(), ); assert_eq!( m.det_errbound(), Err(LaError::non_finite_computation_scalar( ArithmeticOperation::DeterminantErrorBound )) ); } #[test] fn det_errbound_d4_dense_reports_legitimate_overflow() { let scale = 3.2e76; let m = black_box( Matrix::<4>::try_from_rows([ [4.0 * scale, scale, scale, scale], [scale, 4.0 * scale, scale, scale], [scale, scale, 4.0 * scale, scale], [scale, scale, scale, 4.0 * scale], ]) .unwrap(), ); assert_eq!( m.det_errbound(), Err(LaError::non_finite_computation_scalar( ArithmeticOperation::DeterminantErrorBound )) ); }Also applies to: 1938-1957
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/matrix.rs` around lines 1866 - 1884, Add matching overflow tests alongside det_direct_d3_dense_reports_legitimate_overflow and the corresponding D4 fixture, asserting both det_errbound() and det_direct_with_errbound() return non_finite_computation_scalar(ArithmeticOperation::DeterminantErrorBound). Reuse the existing dense matrices and black_box setup, while preserving the determinant tests’ expected Determinant error classification.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/matrix.rs`:
- Around line 1866-1884: Add matching overflow tests alongside
det_direct_d3_dense_reports_legitimate_overflow and the corresponding D4
fixture, asserting both det_errbound() and det_direct_with_errbound() return
non_finite_computation_scalar(ArithmeticOperation::DeterminantErrorBound). Reuse
the existing dense matrices and black_box setup, while preserving the
determinant tests’ expected Determinant error classification.
In `@tests/exact_bench_config.rs`:
- Around line 151-162: Replace the repeated baseline assertions in
det_sign_exact_benchmark_filter_paths_are_stable with the required
dimension-literal macro, invoking it for dimensions 2, 3, 4, and 5 to generate
independently named tests. Keep the near_singular_3x3_input,
large_entries_3x3_input, and Hilbert fixture assertions in the test coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e8780e88-6905-47c4-b533-0d9503903dc8
📒 Files selected for processing (4)
benches/common/exact.rsdocs/BENCHMARKING.mdsrc/matrix.rstests/exact_bench_config.rs
Closes #157
Summary by CodeRabbit
Performance
Reliability
Documentation
Tests