Make above-the-line deduction sums deterministic - #9446
Merged
Conversation
Person-level adjusted gross income and the student-loan-interest MAGI built their list of tax-unit deductions from a set difference, so the float32 accumulation order followed the process hash seed and results could differ across runs at the last digits. Sort the unique deduction names instead. This is the fix the accepted canonical candidate wheel carried (the acceptance matrix's seed-invariance rests on it) but which never reached the merged branch; the published 2.0.0 sums in hash-seed order. The regression tests cover both formulas, with and without deductions, in both orders, and a subprocess check across two hash seeds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9446 +/- ##
============================================
- Coverage 100.00% 62.29% -37.71%
============================================
Files 2 2
Lines 20 61 +41
Branches 0 3 +3
============================================
+ Hits 20 38 +18
- Misses 0 22 +22
- Partials 0 1 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Why
adjusted_gross_income_personandstudent_loan_interest_ald_magibuild their list of tax-unit deductions aslist(set(all_alds) - set(PERSON_ALDS)). Set iteration order over strings follows the process hash seed, so the float32 accumulation order, and therefore the last digits of AGI, could differ between processes. The canonical SPM acceptance matrix's seed-invariance (byte-identical vectors underPYTHONHASHSEED0 and 42) rests on the accepted candidate wheel having this fix; the fix lived on the determinism branch and never reached the merged #9428, so the published 2.0.0 sums in hash-seed order.What
sorted(...)in both formulas (two lines).policyengine_us/tests/core/test_ald_determinism.py: both formulas, with and without deductions, in both list orders, plus a subprocess check under two hash seeds.The candidate's exact
policyengine-core==3.32.5pin is deliberately not ported: the wrapper bundle pins core exactly; the country keeps>=3.30.1.Verification
uv run python -m pytest policyengine_us/tests/core/test_ald_determinism.py: see the run recorded below the fold in the rollout runbook; ruff format check clean.🤖 Generated with Claude Code