perf(callaway): fancy-+= per-(g,t) IF scatters; drop dead _compute_aggregated_se#636
Conversation
…gregated_se The per-(g,t) cluster-SE helper (_cluster_robust_se_from_per_gt_if) and the general combined-IF assembly scattered per-cell influence functions with np.add.at (unbuffered ufunc, 5-20x slower than fancy +=). Index arrays are duplicate-free by construction at every producer (np.where on disjoint masks — the invariant _combined_if_fast already relies on), so the fancy scatter is bit-identical. Also removes the dead _compute_aggregated_se (zero in-package callers; superseded by _compute_aggregated_se_with_wif), updates the stale test_se_accuracy docstring pointer, and refreshes the REGISTRY/dispatch-comment wording about the general fallback path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Overall Assessment✅ Looks good — no unmitigated P0/P1 findings. Executive Summary
MethodologyNo findings. The changed scatter sites still assemble the same per-index IF vectors before variance computation: The methodology registry documents the combined-IF contract and explicitly notes the fancy Code QualityNo findings. The deleted PerformanceNo findings. The change removes MaintainabilityNo findings. The comments and registry now align with the implementation and clearly state the duplicate-free index contract. Tech DebtNo findings. The PR removes the completed CS-scaling TODO rows and leaves the remaining related deferred allocation item tracked in SecurityNo findings. The diff is limited to numerical aggregation code, docs, TODO/changelog, and a test docstring pointer; no secrets, file IO, network, or deserialization surfaces are introduced. Documentation/TestsNo PR findings. Registry and changelog documentation were updated. Test execution was not possible in this review environment: |
Summary
staggered.py::_cluster_robust_se_from_per_gt_ifand the general combined-IF assembly path instaggered_aggregation.pyfromnp.add.at(unbuffered ufunc, 5-20x slower per element) to fancy+=. Index arrays are duplicate-free by construction at every producer (np.whereon disjoint masks — the documented invariant_combined_if_fastalready relies on), so the fancy scatter is bit-identical._compute_aggregated_se(zero in-package callers; superseded by_compute_aggregated_se_with_wifsince the WIF adjustment landed) and update the staletest_se_accuracy.pydocstring pointer.+=scatter).np.add.atscatter + dead-code removal); CHANGELOG entry under Unreleased → Performance.Methodology references (required if estimator / math changes)
np.add.atand fancy+=are bit-identical on duplicate-free index arrays (each element receives exactly one add of the same two floats).Validation
tests/test_se_accuracy.py(docstring pointer only). Existing gates cover the change:tests/test_staggered_aggregation.py::TestCombinedIFFrozenParity(frozen pre-rewrite oracle over panel / survey / RCS / unbalanced / triple-diff scenarios) andtests/test_staggered.py::TestCallawaySantAnnaClusterSafetyGates::test_per_gt_se_matches_compute_survey_if_variance_helper(exactrel=0, abs=0equality vs annp.add.atreconstruction)..so, resolved by rebuild — not code issues).Security / privacy
Generated with Claude Code