Remove Rust outer-loop SDID variance to fix SE mismatch and perf regression#147
Merged
Remove Rust outer-loop SDID variance to fix SE mismatch and perf regression#147
Conversation
…d perf regression The Rust placebo/bootstrap variance paths used a different RNG (Xoshiro256PlusPlus) producing different permutation sequences than Python, causing SE divergence between backends. Rayon parallelism across all replications also saturated memory bandwidth at 1k+ scale (3-10x slower than pure Python). Inner Frank-Wolfe weight calls still dispatch to Rust for ~18x speedup over R. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Overall Assessment ✅ Looks good 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
synthetic_did.pyrust/src/sdid_variance.rs(498 lines) and all associated exports/registrationsTestSDIDVarianceRustBackendtest class (9 tests that directly imported deleted Rust functions)Root causes fixed
default_rng, causing SE divergence between backends (Python=0.1048, Rust=0.0987 at small scale)par_iteracross all replications saturated memory bandwidth at 1k+ scale (3.2x slower at 1k, 9.7x slower at 5k vs pure Python)Architecture after fix
Python sequential loop is the only orchestration path for variance estimation. When Rust is available, inner Frank-Wolfe weight calls dispatch to Rust via
utils.py→_backend.py→_rust_backend. TheDIFF_DIFF_BACKENDenv var controls this cleanly.SE convergence validation (Python vs R at increasing iteration counts)
Both converge to ~0.106; gap is Monte Carlo noise.
Performance (small scale, 2000 reps)
Methodology references (required if estimator / math changes)
Validation
tests/test_methodology_sdid.py: AddedTestBackendSEConsistency(2 tests: placebo + bootstrap SE matching across backends,rtol=1e-4)tests/test_rust_backend.py: RemovedTestSDIDVarianceRustBackend(9 tests for deleted Rust functions)test_methodology_sdid.py,test_rust_backend.py,test_estimators.pyDIFF_DIFF_BACKEND=pythonmodematurin develop --releasebuilds cleanlygrep -r "placebo_variance_sdid\|bootstrap_variance_sdid"returns zero hitsSecurity / privacy
Generated with Claude Code