Skip to content

Align shared DRDID estimators and preserve cross-package inference - #88

Merged
pedrohcgs merged 7 commits into
mainfrom
fix/cross-package-weight-scale
Oct 27, 2026
Merged

pedrohcgs merged 7 commits into
mainfrom
fix/cross-package-weight-scale

Conversation

@pedrohcgs

@pedrohcgs pedrohcgs commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Harmless changes to sampling-weight units can produce NA ATT estimates or incorrect aggregate inference. At weight scale 1e307, all 12 DR/IPW/regression × panel/RC × execution-mode routes can fail. Sparse float32 weights can lose positive mass, and squared cohort-mass denominators can corrupt aggregation derivatives. The shared-kernel audit also found int64 outcome subtraction wrapping before conversion to double, and float32 kernels disagreeing with their identical represented values in double precision.

This repairs weight reductions and aggregation ratio derivatives when ordinary arithmetic becomes unreliable, and converts built-in numeric inputs before arithmetic/fitting. Raw user columns, custom-estimator inputs, cache behavior and ordinary float64 results are preserved. Independent ratio derivatives, aggregation nesting and closed-form difference-of-means cases verify the corrected behavior. The same R slow-path aggregation defect is corrected in did #280.

The coordinated candidates are CSDID 0.4.4 and Python DRDID 1.1.7. CSDID now requires exactly drdid==1.1.7 and locks its reviewed source commit. Local DR/IPW kernels and external regression dispatch are tested against standalone DRDID and R. Future backend upgrades must update the dependency and source lock together.

Validation:

  • 2,935 tests and 19 subtests pass with both exact candidate wheels installed together in a fresh environment, including slow tests and release-gate failure probes; zero failures/errors/skips. All 72 direct shared-kernel comparisons pass on raw and original-unit outputs. Source/wheel/installed hashes and every loaded package module origin are checked.
  • 648 strict complete-output R checks pass against the reviewed corrected R did source and official R DRDID: 552 weight-scale checks plus 96 sparse-float32 checks. They compare ATT, full IF, SE, confidence limits, Wald fields and every aggregate/component output with unchanged tolerances, support and nonfinite masks.
  • With the final installed pair, 240 healthy workflows and 960 aggregates are bit-identical to baseline, including warnings and RNG state. The initial 187 new scale/precision contracts produce 140 failures on the original runtime and pass with the correction; the later dtype contracts add independent closed-form checks.
  • The DRDID companion's four CI jobs pass at 53a6b76. R did #280 passes all five R/OS jobs and build-check; its full local suite passes 5,896 assertions without failures/warnings/errors/skips.

Both mandatory Python CI lanes now rebuild and jointly install the exact pair and rerun both suites and the kernel bridge. The existing required current-R job retains its fixtures, reviewed pins and numerical tolerances. Any unreviewed tracked R-tree change now requires review, including a source-only change whose numerical grid passes; a live probe verifies exit 3 after all 125 comparisons pass. CSDID's three main-branch checks remain mandatory with no bypass actors.

Publishing requires all three trusted successful main-push checks at the tested revision. CSDID also requires a published backend wheel matching every reviewed Python source byte and its PyPI digest. DRDID must be released first; no merge or publication has been performed. For subsequent exact-pin upgrades, validate both candidates, merge the reviewed CSDID lock/pin update first (publication safely blocks), rerun/release DRDID, then retry CSDID publication.

Retained numerical limitation: 36 raw aggregate-IF comparisons exceed the existing tolerance at outcome multiplier 1e10; the replay keeps exit 1. ATT, SE, confidence limits and Wald outputs pass in that audit. The largest violating difference is about 0.1288, or 1.29e-11 in original outcome units; R's fast/slow paths also miss 42 IF fields. No tolerance was widened or failing case removed. This establishes bounded compatibility for matched shared methods, not universal numerical equivalence. R-only pushes do not themselves trigger Python CI.

See the compatibility record, paired-wheel receipt and audit replay instructions. These supersede the earlier release/dependency statements while preserving historical evidence.

All three final required CSDID checks pass at b46de13: Python 3.8/3.12 and joint installed wheels, and fresh current-R parity. Each Python lane passes 2,933 non-slow tests and all 72 bridge cases using peer 53a6b76; the local full run also includes both slow tests. The R runner was retried once after unusually slow Ubuntu mirror downloads, without a code or workflow change. The orphan backend R gitlink was removed; all runtime source bytes remain identical to the recorded full local proof.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 04:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@pedrohcgs pedrohcgs changed the title Preserve cross-package inference across sampling-weight units Align shared DRDID estimators and preserve cross-package inference Oct 27, 2026
@pedrohcgs
pedrohcgs merged commit 86bf962 into main Oct 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants