perf(staggered): O(n_units) CS aggregation IF assembly + R did 2.5.1 yardstick#617
Merged
Conversation
|
Overall Assessment Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…yardstick Rewrite CallawaySantAnna's combined influence-function assembly (also inherited by StaggeredTripleDifference aggregation) - previously 56-85% of analytical fit time at scale: - Per-fit cohort tables (np.unique + np.bincount) cached on the precomputed structures with array-identity validation (safe against triple-diff's shallow-copy + zeroed-cohort aggregation pattern) - Closed-form WIF (wif_i = w_i * (E(c_i)/S - K(c_i)*d/S^2)) replacing dense (n_units x n_gt) indicator/outer-product matrices - algebraically identical, documented in REGISTRY - Fancy-index scatter replacing np.add.at (per-cell index arrays are duplicate-free by construction; invariant documented at all IF producers) - Pre-rewrite general path preserved verbatim as fallback for direct callers Point estimates bit-identical; aggregated SEs <=5e-16 relative (drift-bound frozen-copy tests at rtol=0 atol=1e-9 across panel/survey/RCS/unbalanced/ triple-diff/inf-coded fixtures). Analytical fits 2.3-6.3x faster at 2-5M rows, bootstrap fits 1.4-1.6x, RCS peak memory -55 to -68%. 3-11x faster than R did 2.5.1 at equal work (single- and multi-core R; benchmarks/R/benchmark_did.R extended with bootstrap/covariate/parallelism flags for the yardstick). Golden aggregated-SE assertions enabled for dr scenarios (match R fixtures at 1e-12..7e-6). Pre-existing reg-method aggregated-SE gap vs R fixtures (3-20%, ATTs exact) documented in TODO.md for follow-up investigation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4AzrFUMqJxcUumSH31mSr
0f4fce8 to
d0a7a98
Compare
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment 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
CallawaySantAnna's combined influence-function assembly (staggered_aggregation._compute_combined_influence_function, also inherited byStaggeredTripleDifference) from per-target full-DataFrame scans + per-unit Python loops + dense(n_units × n_gt)WIF matrices to per-fit cohort tables (identity-validated cache) + closed-form WIF + fancy-index scatter; the pre-rewrite general path is preserved verbatim as the fallback for direct callersdocs/performance-plan.mddid2.5.1 yardstick: 3-11x faster at equal work (att_gt+ 3aggtevsfit(aggregate="all"), identical biters/cband, single- AND multi-core R; R'spl/coresis BLAS-bound on this path).benchmarks/R/benchmark_did.Rextended with--xformla/--bstrap/--biters/--cband/--pl/--cores/--faster-mode(backward-compatible defaults; errors on unknown flags; config recorded in JSON metadata)np.add.atsibling, lazy per-cell label arrays, dead_compute_aggregated_seremovalMethodology references (required if estimator / math changes)
did::wif()/compute.aggte.R)didpackage (bcallaway11/did)Validation
tests/test_staggered_aggregation.py(new: frozen byte-copy parity, WIF zero-contract, cache-invalidation, fast-path-taken dispatch tests),tests/test_csdid_ported.py(golden aggregated-SE assertions for dr scenarios)docs/performance-plan.mdSecurity / privacy
Generated with Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01X4AzrFUMqJxcUumSH31mSr