feat(rust): one-way HC2 robust vcov kernel#651
Open
igerber wants to merge 1 commit into
Open
Conversation
ae6098f to
66bd128
Compare
The Rust vcov path supported only HC1/CR1; HC2 fell through to NumPy (noticeable at large n). Adds compute_robust_vcov_hc2 mirroring the NumPy hc2 branch exactly: hat diagonals off the same bread, u^2/max(1-h, 1e-10) leverage meat, no n/(n-k) factor — matches NumPy at ~1e-15 across a seed grid. The near-singular hat-diagonal guard stays Python-side: the kernel returns a sentinel error and the documented warn-and-fall-back-to-HC1 fires in the dispatcher, identical to the NumPy branch (locked by a monkeypatched-sentinel test + an exact-h=1 clamp-parity test). The symbol imports independently (mixed-version safe: a stale extension degrades HC2 to NumPy without disabling older Rust accelerations). return_dof / weighted / clustered / CR2-BM requests stay on NumPy; the TODO row is narrowed to CR2-BM. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
66bd128 to
fef4197
Compare
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good — no unmitigated P0/P1 findings. Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
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
ngap). Addscompute_robust_vcov_hc2mirroring the NumPy hc2 branch exactly: hat diagonals off the same bread,u²/max(1−h, 1e-10)leverage meat, no n/(n−k) factor — matching NumPy at ~1e-15 across a seed grid, per the Python-canonical convention.demean_map/ the batched ridge kernel) — a stale extension degrades HC2 to NumPy without disabling older Rust accelerations.return_dof/ weighted / clustered / CR2-BM requests stay on NumPy; the TODO row is narrowed to the CR2-BM remainder.Methodology references (required if estimator / math changes)
sandwich::vcovHC type="HC2"convention already documented for the NumPy branch) — backend port only, no formula changeValidation
tests/test_rust_backend.py::TestRustHC2Vcov(7 tests: seed-grid parity, kernel shape/symmetry/PD, exact-h=1 clamp parity, sentinel→HC1-fallback plumbing, instability→NumPy-HC2 fallback plumbing, length-mismatch rejection, DOF/weights dispatch-decline equivalence).tests/test_rust_backend.py+tests/test_linalg.pypass (258);cargo check/fmt/clippyclean on the new code.Security / privacy
Generated with Claude Code