Skip to content

chore(deps): update policyengine to 6.20.4 - #1169

Merged
anth-volk merged 6 commits into
mainfrom
auto/update-policyengine-6.20.4
Dec 1, 2026
Merged

anth-volk merged 6 commits into
mainfrom
auto/update-policyengine-6.20.4

Conversation

@policyengine

@policyengine policyengine Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1168

Summary

Update .py (policyengine) from 6.20.0 to 6.20.4 in the simulation service. The executor's two policyengine[models] pins (the project's dependencies and the modal-simulation-image group) and uv.lock move to 6.20.4. The executor's Docker image and every Modal image install from that lock, so requests for .py 6.20.4 run on it.

6.20.4 (PolicyEngine/policyengine.py#777) ranks households with equal incomes in the order of their rows when it calculates the Gini coefficient and the top 10% and top 1% income shares. Before, numpy's default sort put tied households in an order that depends on the CPU, so the same UK report could give different top shares on different hosts (in one check of 20 UK values, up to 9.8e-5 relative apart) and Gini values that differed in their last bits. With 6.20.4 the same rows give the same values on every host.

This PR started as the automated update PR; it adds a test, a test fix and a fuller changelog fragment.

What the update brings in

The pin moves from 6.20.0, so the update also brings in 6.20.1 to 6.20.3:

  • 6.20.4: the stable sort in Inequality.run and its Gini calculation. The bundle manifest changes only its version labels.
  • 6.20.1: a new certified UK data release built with policyengine-uk 2.177.7; policyengine-uk 2.174.1 → 2.177.7 and policyengine-core 3.33.3 → 3.34.10. UK files are read from Microcosm's build folders, each pinned to the Hugging Face commit that published it.
  • 6.20.2: Microcosm names for the Belgian dataset class and some certification constants, keeping the old names as aliases. The simulation service uses none of them.
  • 6.20.3: the certified UK data release uk-frs-calibration-attempt-20261122T100732Z-b891aa69, built with policyengine-uk 2.179.2.

What changes for the simulation service:

  • UK results change for v1's calculation and Stage 12 alike: policyengine-uk 2.179.2 (rule changes listed in its changelog from 2.174.2 to 2.179.2) and newly certified national (microcosm_uk_2024_25, SHA-256 ae116bc3…) and local-area (microcosm_uk_2024_25_dense, SHA-256 cf1c98ac…) datasets.
  • UK labels: a UK national report's data_version becomes uk-frs-calibration-attempt-20261122T100732Z-b891aa69 (was microcosm-uk-2024-25-national-20261107T020434Z-eeb6093e). The UK datasets' revisions are 40-character Hugging Face commit hashes instead of tag names, so a UK-wide or nation report on the local-area dataset is labelled with one; US revisions have been commit hashes since 6.20.0.
  • US: policyengine-us stays 2.2.2 and the US data release is unchanged. policyengine-core 3.34.10's reform and caching fixes apply to both countries.

The bundle the update installs, as the automated update read it from the 6.20.4 wheel:

  • policyengine-core: 3.34.10
  • policyengine-us: 2.2.2
  • policyengine-uk: 2.179.2
  • spm-calculator: 1.1.0
  • US data release: populace-us-2024-spm-20260915
  • UK data release: uk-frs-calibration-attempt-20261122T100732Z-b891aa69
  • UK certified dataset SHA-256: ae116bc3cff798fe68df253083f0b26d779e02a0a818ee68df7d29fbc557165a
  • UK certificate digest (receipt v1): 897d9dcb6fc22209496bfe30fdaad0eec398082cd8ab626dfb9106060eadc08d
  • release dispatch verified against the installed wheel: true

Tests

  • New: the inequality row-order tests. They rebuild UK frames as Stage 12's aggregation does (_dataset_from_frames, PrecomputedSimulation), run calculate_uk_inequality (what the UK economic_impact_analysis runs for each simulation) and read the values build_inequality reports.
    • Twenty copies of one household with the same income sit at the top 10% and top 1% cutoffs, ten with weight 1 and ten with weight 3. With the light copies first, the top 10% share is 12 × 50,000 / 2,700,000 and the top 1% share 3 × 50,000 / 2,700,000; with the heavy copies first, 13 and 2 copies' weight.
    • Ten seeded cases of 200 households at eight income levels: rows in household_id order (as Stage 12 stores them) give exactly the Gini, and the shares to 1e-12 relative, of the same rows listed by income with ties kept in row order. Each share divides by the total income summed in the rows' own order, so the two lists differ in the last bits; a different ranking of tied households at a cutoff moves a share by about 1e-4 relative or more.
  • The failing test came first. The test commit sits on main with .py 6.20.0, where all 12 cases failed on an arm64 Mac with numpy 2.4.4. With the light copies first the top 10% share came out 0.2037 instead of 0.2222; with the heavy copies first the top 1% share 0.0741 instead of 0.0370; the seeded cases differed in the Gini and by 5e-4 to 0.33 relative in the shares. After the update all 12 pass.
  • Fixed: test_the_installed_bundle_routes_area_regions_to_the_dense_dataset expected the local-area dataset's revision to start with microcosm-uk-2024-25-dense-. Since 6.20.1 it is a commit hash; the test now checks for one, and still checks that it equals the installed release manifest's revision. This was the one executor test failure on the automated 6.20.1 to 6.20.3 PRs.
  • Run locally, each by node ID: the 12 new cases and the fixed test. Ruff format and lint, the rules registry, the quality checks, Pyright for the executor and uv lock --check pass.

Review

One round of adversarial review (a read-only reviewer) found no bugs. Its four wording findings are fixed in the last commit: the changelog fragment now says the top shares differed between hosts, and that policyengine-core's fixes reach US simulations too; the new test module says "API v1's calculation"; and reported_data_version's docstring says the UK revisions are commit hashes since .py 6.20.1. No bugs are left.

What the merge waits for

API v1 and the order of merges

  • API v1 sends its own installed .py version with each economy request, and the simulation service routes each request to the app deployed for that version; API v1's /v2/ routes select by the same version. So API v1, and through it API v2, moves onto 6.20.4 only in API v1's own update, Update PolicyEngine bundle to 6.20.4 policyengine-api#4377 (D5 · 9 in the migration plan). This PR changes only the simulation service.
  • API v1's deploys check that its pinned .py version equals the simulation service's policyengine.latest at /versions. Once this PR deploys and staging's latest is 6.20.4, API v1 master deploys stop at that check until Update PolicyEngine bundle to 6.20.4 policyengine-api#4377 merges, and that PR's own check fails until staging serves 6.20.4. So Update PolicyEngine bundle to 6.20.4 policyengine-api#4377 should be reviewed and ready before this PR merges, and merge as soon as this PR is deployed.

Deployment and environment variables

  • No environment variable, secret, workflow, Dockerfile or Modal secret is added or changed. The images install the new versions from uv.lock.
  • The new UK files are in the same Hugging Face repository (policyengine/populace-uk-private) and are read with the existing credential: the GitHub Actions secret PE_UK_PRIVATE_HF_READ_TOKEN, which the deploy workflow validates and copies to the Modal secret pe-uk-private-hf-read-token.
  • The numerical release check at deploy computes its expected values from the locked bundle, so it needs no new values.

The earlier automated update PRs, #1080 (6.20.1), #1084 (6.20.2) and #1116 (6.20.3), are superseded by this one.

🤖 Generated with Claude Code

github-actions Bot and others added 6 commits December 1, 2026 01:44
Rebuild UK frames as Stage 12's aggregation does and run the inequality
calculation the UK economic impact analysis runs, then read the values
build_inequality reports. With twenty copies of one household at the top
10% and top 1% cutoffs, the shares must follow the order of the copies'
rows. Rows in household_id order must give exactly the Gini of the same
rows listed by income with ties kept in row order, and the same shares
to 1e-12 relative: each share divides by the total income summed in the
rows' own order, which differs between the two lists in the last bits.

.py 6.20.0 ranks incomes with numpy's default sort, which reorders equal
values, so all twelve cases fail on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ity test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since .py 6.20.1 the UK release pins each file in Microcosm's build
folders to the Hugging Face commit that published it, so the local-area
dataset's revision is a 40-character commit hash, not a
microcosm-uk-2024-25-dense-… tag name. The test still checks that it is
the revision the installed release manifest records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The raise from 6.20.0 brings in the stable inequality sort and, from
6.20.1 to 6.20.3, a new UK model, core package and certified UK
datasets, with new UK label forms. API v1 keeps requesting its own .py
version until it raises its pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The changelog fragment says the top shares differed between hosts, by
up to 9.8e-5 relative in one check, rather than between runs, and that
policyengine-core's reform and caching fixes apply to US simulations
too. The row-order tests' docstring writes "API v1's calculation". The
reported_data_version docstring says the UK national and local-area
revisions are Hugging Face commits since .py 6.20.1, as the US one has
been since 6.20.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review December 1, 2026 17:18
@anth-volk
anth-volk merged commit 20c5063 into main Dec 1, 2026
30 of 32 checks passed
@anth-volk
anth-volk deleted the auto/update-policyengine-6.20.4 branch December 1, 2026 17:29
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.

Update policyengine to 6.20.4

1 participant