Skip to content

Give UK simulations a working subsample - #2265

Open
MaxGhenis wants to merge 19 commits into
mainfrom
fix-subsample-2254
Open

MaxGhenis wants to merge 19 commits into
mainfrom
fix-subsample-2254

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2254

Status: waiting for policyengine-core holder resync. The r3 invalidation workaround has been removed. Supplied/model restoration regressions remain strict expected failures until the core fix is released.

What was wrong

Simulation.subsample() was inherited from policyengine-core and raised TypeError: Simulation.build_from_dataset() missing 1 required positional argument: 'dataset'. I reproduced it on main (2.125.2) with a six-household in-memory dataset, on policyengine-core 3.32.27 (the locked version) and 3.33.1.

Why the signature was not the whole problem

I read core's subsample and flat-file loader (master 8fdf59e9, 3.33.2) against the UK builders, and ran the issue's option 3:

  1. Option 3 fails. With build_from_dataset(self, dataset=None) falling back to self.dataset, core's subsample hands the UK builder the flat-file Dataset it rebuilt with Dataset.from_dataframe. The UK builder calls dataset.load_dataset(), which reads only the table, time-period-array and array formats, and raises UnboundLocalError for a flat file. I ran this on core 3.32.27 and 3.33.2. The UK builder would also rebuild every year from the first one, projected forward, rather than keep each year's inputs.
  2. Memberships. Core reads each person's household and benefit unit from the stored person_household_id and person_benunit_id inputs. On main the UK model stores both as 32-bit floats, which hold integers exactly only up to 2**24 (16,777,216). In the full-size UK dataset the issue's reproduction used, household identifiers reach about 900 million: its 535,080 distinct household identifiers are only 76,551 distinct values as float32, and its 618,980 benefit unit identifiers are 544,894. A rebuild from those columns would merge households and benefit units. (Store person_household_id and person_benunit_id as integers #2273 proposes storing them as integers. This PR does not depend on it.)
  3. Baseline. Core rebuilds branches["baseline"]. A UK simulation's baseline is a separate Simulation, which core's method does not touch, so a reform and its baseline would hold different households.
  4. Seed. With no seed, core reads self.dataset.name. UK datasets have no name.
  5. Weights. Core rescales every column whose name contains weight__. In the UK that would include household_bus_fare_age_weight if it were supplied as an input; it shares out bus fare spending and is not a sampling weight.

So this is option 1 in the issue: a UK subsample. It does not call core's method and does not change build_from_dataset. The subsample implementation stays in the UK model. This PR waits for the policyengine-core holder resync fix. Holders cache variable instances after runtime reforms replace the system definitions. The attempted UK invalidation workaround has been removed: it caused core to reject an existing neutralised CGT input replacement, and it was too late for writes inside a restoring reform. Keeping holders current on every access cannot preserve the unchanged CGT contract through core’s public input API. The supplied/model restoration regressions remain strict expected failures with reason needs policyengine-core holder resync; every assertion is retained.

What the UK method does

Same signature as core's: subsample(n=None, frac=None, seed=None, time_period=None, quantize_weights=True).

  • Draws n households with replacement and keeps every household drawn at least once, with its benefit units and people. Only households with a positive weight in time_period can be drawn: with quantize_weights=True (the default), each with probability proportional to that weight; without it, each with equal probability. A period before the first one the simulation was given household weights for has none, so the first given weights are used.
  • Takes households, benefit units and people from the populations (ids and members_entity_id), which are exact, not from the stored identifier inputs.
  • Keeps every supplied input (from the dataset or set_input) for the sampled records, for every period. It reads each input from the storage tier (memory or disk) the holder records it in, so a value calculated later and cached over the input is not kept. Calculated values are dropped and recalculated on the sample, and the tracer starts again.
  • Replaces each supplied weight so that its total over its own entity is unchanged in every period. The weights are listed (household_weight, benunit_weight, person_weight, original_weight, raw_person_weight), and a test fails if a new variable ending in weight is not classified.
  • Replaces the baseline, and its baseline, with copies subsampled with the same draw. It does not change a baseline in place: core's clone shares a separate baseline between a simulation and its clone, so subsampling a clone would otherwise cut down the source's baseline. The copy is made as get_branch makes a branch, so it shares the old baseline's arrays as read-only views instead of copying them, and it rebuilds its own at once. (A plain clone copied every cached array first, which took the full-size run below past a 20 GB memory limit.) The old baseline stays in memory until nothing holds it.
  • Replaces dataset with the rows of the dataset the simulation was built from for the sampled records, weights rescaled the same way. The original object is not changed (it can be the shared entry of the URL cache). Like the dataset before subsampling, it holds whole years only, and not values set with set_input after the build.
  • Keeps two records main added since this PR opened, which a rebuild of the populations forgets. Values the model stored as its own with set_model_value (the Universal Credit health element reform stores them for every simulation, for 2026 to 2032) are stored back with set_model_value, so supplied_input still does not read them as supplied. The record of where each capital gains input came from (supplied or projected, by period) is restored, and the dataset's annotation of projected capital gains inputs is carried to the subsampled dataset.
  • Works out every subsample before changing anything, so a refusal leaves every simulation as it was.

Differences from core's method, all deliberate:

  • The draw uses a local numpy.random.RandomState seeded from a SHA-256 digest of the seed, so a seed draws the same households in every process, and the global random state is not touched. A seed therefore does not pick the same households as it would in core.
  • With no seed, a fixed seed is used.
  • A simulation built from a situation, one given no household weights or a negative weight, a branch, a benefit unit spread over two households, and a baseline holding other households are refused with a ValueError.
  • The baseline object is replaced, not changed in place (see above).

Invariants

Stated in policyengine_uk/tests/test_subsample.py and tested with Hypothesis for generated datasets of one year (which the model projects) and of several years whose weights change differently from household to household (two explicit examples make sure the shares change), for every n, seed, sampling period and quantize_weights:

  1. Size: between 1 and n households are kept, each with a positive weight in the sampling period.
  2. Weight totals: the total household weight of every year is unchanged, to float32 precision, and so is the total of every other supplied weight over its own entity.
  3. Quantized weights: a household's weight is its number of draws times the year's total over the draws of households with a positive weight that year: in the sampling year, a whole multiple of total / n, with the multiples summing to n. The same draws set every year's weights. With quantize_weights=False, it is proportional to its old weight times a whole number of draws. Either way, a zero weight stays zero in every year, and each supplied weight is rescaled to its own entity's total (so a supplied person weight need not equal the new weight of the person's household).
  4. Links: a kept household or benefit unit has exactly the people it had, a kept person keeps their household and benefit unit, and no other record is kept. This holds for neighbouring identifiers near 900 million, which float32 cannot tell apart, and whatever the stored membership inputs hold.
  5. Inputs: every supplied value other than a weight is unchanged for the kept records in every period, and the subsample supplies the same variables and periods as before.
  6. Determinism: the same seed keeps the same households with the same weights.
  7. Baseline: the baseline is a copy holding the same households and weights, with its own policy. The baseline held before is unchanged, so subsampling a clone leaves the source and its baseline as they were.
  8. Dataset (differential): dataset holds the same records as the populations. For a simulation whose inputs are all in its dataset, a simulation built from that dataset gives the same results as the subsampled simulation. This compares the two implementations of the subsample: the one that cuts the stored inputs and the one that cuts the dataset tables.
  9. Unbiasedness: over 3,000 seeds, a household's mean quantized weight in the sampling period is its old weight (within 3%).
  10. Trace and tiers: the tracer starts again, and an input stored on disk is kept rather than a value cached over it in memory. On core 3.33 and later, a differential test checks the tier rule against core's own Simulation._get_recorded_input_array (it skips on 3.32, which has no such method).
  11. Model values and origins: a value the model stored as its own stays the model's, a supplied value stays supplied, and the capital gains input origins reported by capital_gains_projection_metadata are unchanged. A simulation built from the subsampled dataset reports the same origins as one built from the full dataset.

Intended exceptions, each pinned by a test:

  • In a year other than the sampling one, a household's mean new weight is its share of the sampling year's total times that year's total. That equals its old weight only if its share is the same in both years.
  • quantize_weights=False keeps the total exactly, which makes the new weights a ratio estimate. I measured the bias: about 6% at 40 draws and under 1% at 400, for a seven-household example. This is the same definition as core's.
  • An input the dataset does not hold stays in the simulation and out of dataset: one set with set_input after the build, or one for part of a year, which a DataFrame can give and a dataset of whole years cannot hold. A weight set with set_input on the simulation alone is rescaled to its own total there, while the baseline and the dataset keep the dataset's weights.

Tests

  • UK hub r3 follow-up / stop decision (2026-10-23): reverted the invalidation override to parent behaviour. New supplied/model regressions check writes inside restoration both directly and after subsampling; direct cases and the unchanged CGT test pass under parent behaviour, while the existing r2 restoration cases and sampled write cases require core holder resync. At e4c54d7fa, the locked foreground pytest -n 2 run passed 244 tests with 4 strict expected failures, 0 unexpected failures and 0 skips in 1h12m40s: subsample (56 passed / 2 xfailed), input records (3 passed / 2 xfailed), the whole CGT projection file (115 passed), input DataFrame export (25 passed), reform-input lifecycle (17 passed), and reform representations (28 passed). The unchanged CGT routes and both direct supplied/model write controls passed. Touched-file Ruff format/lint, repository-wide uvx ruff format --check . (1940 files), whitespace and CI xfail-allowlist checks passed. This PR must wait for the upstream fix.

  • UK hub r2 P2 fix (2026-10-23): existing holders rebind to the current system definitions before reform cache invalidation. Both supplied/model restoration regressions and the canonical neutralised-input replay remain unchanged. At 74b0c65d7, the locked foreground pytest -n 2 run passed 85 tests, 0 failed, 0 skipped in 47m10s: test_subsample.py (58), test_input_records.py (1), test_input_dataframe_export.py (25), and test_capital_gains_projection.py::test_restoring_neutralized_projection_preserves_applied_fingerprint (1). Python 3.13.9, core 3.33.2. Touched-file Ruff format/lint, repository-wide uvx ruff format --check . (1940 files), and whitespace checks pass. No full suite or aggregate-impact run was repeated for this infrastructure fix.

  • UK hub P2 follow-up (2026-10-22): commit 9a91736f3 (on merge fc537e4e3 of origin/main at fe0b99a36) preserves neutralised stored inputs and model markers when subsampling, and adds supplied/model ANI restoration regressions. Touched-file Ruff format and lint, whitespace checks and repository-wide uvx ruff format --check . pass. The focused pytest -n 2 runs were not run locally: the host was outside its load and disk limits (load1 172.65, free disk 54.98 GB). CI on this head is the test evidence, and the hub's independent review reruns the focused tests.

  • policyengine_uk/tests/test_subsample.py: 58 tests. They cover the reported call, each failure mode above, each refusal, the findings of two review rounds and of @vahid-ahmadi's review, the records main added, and the properties.

  • Mutation check at 01f5d051: I made 22 single changes to utils/subsample.py and utils/supplied_inputs.py and ran the file against each. 21 were caught. The survivor removes the reset of the input record, which _invalidate_all_caches repeats later in the same function, so it changes nothing observable. After merging main, three more (store model values with set_input, drop the capital gains origins, drop the dataset annotation) were each caught by the two new tests.

  • Local runs at 7b4c3c28 (the branch with main at 7918fc2a merged in), with 4 workers, of the new file plus test_input_records.py, test_simulation_dataset_sources.py, test_dataframe_dataset.py, the four test_uc_health_*.py files, test_capital_gains_projection.py and test_capital_gains_response_default.py:

    • core 3.33.2 (now the locked version), Hypothesis 6.169.0: 377 passed.
    • core 3.33.12 (latest on PyPI), Hypothesis 6.170.5, pandas 3.0.6, NumPy 2.5.4: 377 passed.
  • At ab843c80 (zero weights stay zero), test_subsample.py with 4 workers: core 3.33.2, 56 passed; core 3.33.12, 56 passed. Later commits change only docstrings.

  • Full-size check under core 3.33.2 at 5dd27677, before the merge with main that added the model-value and capital gains handling (not rerun since), on the full-size UK dataset the issue's reproduction used (535,080 households): subsample(n=10_000, seed=0, time_period=2026) took 6.7 seconds and kept 8,660 households. From the weights alone, the expected number of distinct households in such a draw is 8,634. Memberships matched the dataset's 64-bit identifiers exactly, the 1,260 supplied variable-periods were the same as before, the baseline was a new copy with the same records and the old baseline still held every household, every year of dataset held the same records, and each year's household weight total was unchanged to 3 parts in 100 million. The same held for quantize_weights=False (9,864 households, 4.0 seconds).

  • Memory: that run stayed under the 20 GB process limit that the plain-clone version exceeded. On a synthetic dataset of 60,000 households with 922 supplied variable-periods, the subsample raised the process's peak resident memory from 2,755 to 2,786 MiB (about 1%).

  • Not run locally: the full suite. CI runs it.

Aggregate impact

From the Aggregate impact report on 7b4c3c28 merged into main (b4495e5cb1 against a8b2848c13, enhanced_frs_2024_25.h5, policyengine-uk-data 1.58.1, fiscal years 2025-26 to 2031-32):

Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0

No household's net income changes in any year.

The one check failing on both sides is sign:vat (VAT is never negative), which this PR does not touch. Expected: subsample is not called in a full microsimulation, and the changes to supplied_inputs.py only add helpers. Later commits change only utils/subsample.py and its tests.

Found on the way

axiom: n/a: simulation infrastructure, no policy rule change

🤖 Generated with Claude Code

Reproducer: policyengine_uk/tests/test_subsample.py::test_subsample_runs_on_a_dataset_simulation

MaxGhenis and others added 3 commits October 10, 2026 15:36
Simulation.subsample was inherited from policyengine-core and raised
TypeError: it rebuilds through build_from_dataset() with no arguments,
and the UK builder takes the dataset to load.

Making that argument optional would not have been enough. Core's method
reads each person's household and benefit unit back from the stored
person_household_id and person_benunit_id inputs, which the UK model
holds as 32-bit floats, so identifiers above 2**24 would merge
households. It also leaves Simulation.dataset as a core Dataset, while
UK formulas read dataset.years, and it rebuilds a baseline branch, while
a UK baseline is a simulation of its own.

The UK method takes households, benefit units and people from the
populations, keeps every supplied input for the sampled records,
rescales each supplied weight to keep its total, and subsamples the
baseline and the dataset with the same draw.

Fixes #2254

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A result calculated before subsampling is calculated again on the sample,
and the record of an input that a calculated value replaced is not kept.
Found by mutating the subsample module: removing the cache invalidation
went unnoticed until these assertions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The simulations usage page gains a short section on subsampling, since
the method now works for UK simulations. A simulation built from a
DataFrame keeps no dataset object, so test that subsampling it leaves
dataset as None and still cuts the baseline to the same households.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI formats Python blocks in Markdown with the latest ruff, which the
locked ruff does not check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Merge-order note from #2273 (fixes #2267, stores person_household_id and person_benunit_id as int32).

On a local merge of this branch (fa7b0f0a) with #2273, test_identifiers_beyond_float32_precision_keep_their_households fails on one line, its precondition:

assert len(set(stored.tolist())) < len(households)

With #2273 the stored values tell the 900-million households apart (6 < 6 fails). The test's own checks, that subsample keeps whole households with their benefit units and people, all pass on the merge. So did the rest of test_subsample.py.

Whichever PR lands second should:

  • change that line to assert the stored memberships are exact, for example assert len(set(stored.tolist())) == len(households), and reword the comment above it;
  • update the sentence in policyengine_uk/utils/subsample.py's module docstring that says the UK model stores person_household_id and person_benunit_id as 32-bit floats (and invariant 4's "identifiers that 32-bit floats cannot tell apart" in the test docstring, if wanted). Reading the populations stays the right approach either way.

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub, for this PR's owner: test interaction with #2270.

#2270 (DataFrame inputs load as the dataset they describe) is armed to land once its Test passes. After it, a DataFrame-built simulation has a dataset, so test_a_simulation_built_from_a_dataframe_has_no_dataset_to_subsample in this PR's test_subsample.py, which asserts dataset is None, will fail.

This PR's last Test run was cancelled, so it has no green run yet. Merging main also brings the 120-minute Test limit (#2258).

MaxGhenis and others added 4 commits October 11, 2026 09:17
Address the independent review of #2265:

- Subsampling a clone changed the source simulation's baseline, because
  policyengine-core's clone shares a separate baseline. Replace each
  baseline with a subsampled copy instead of changing it in place.
- A calculated value cached in memory over an input stored on disk was
  kept as the input. Read each supplied input from the tier the holder
  records it in, as Holder._stores_user_input decides.
- A trace kept values calculated on the replaced populations. Give each
  simulation a new tracer, shared as before.
- Say that dataset holds the rows of the dataset the simulation was
  built from, without later set_input values, and that weights are
  unbiased in the sampling period only. Generate multi-year datasets
  whose weights change differently by household in the property test.

Also adapt to main: a DataFrame-built simulation now has a dataset, and
test memberships without assuming how the identifiers are stored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address the second independent review of #2265:

- Copying a baseline with clone copied every cached array before the
  subsample discarded them, which took a full-size run past a 20 GB
  memory limit. Announce the copy as get_branch does, so it shares the
  arrays as views and copies none.
- A negative household weight could leave a negative weight in the
  sample. Refuse negative sampling weights, and negative values in any
  weight being rescaled.
- An input for part of a year, which a DataFrame can give, stays in the
  simulation and out of the dataset of whole years. Say so, and test it.
- Give the property test two explicit cases whose weight shares change
  from year to year, which the generated cases had not reached.
- Qualify the docstring's sampling and unbiasedness claims by
  quantize_weights, and describe the first-weights fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mutation testing showed the rescaling check alone also caught a negative
household weight, so removing the draw's own check went unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

For coordination: #2308 (fixes #2307) is stacked on this branch and builds on stored_supplied_value.

  • It makes supplied_input and supplied_input_periods use the same tier rule, so they no longer count a value cached over a supplied input as supplied.
  • It moves the tier lookup in stored_supplied_value into a private _supplied_value_storage, so that supplied_input_periods can check a tier without reading a value that may be on disk. What stored_supplied_value returns is unchanged.

Nothing in this PR needs to change for #2308. If stored_supplied_value changes here before merging, #2308 will follow it. #2308 moves to main when this PR merges.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

CI run cancelled to free runners (UK hub, 2026-10-11 23:30Z). The PolicyEngine org is at GitHub's limit of 60 concurrent jobs, with about 360 queued. Fleet ops asked the hub to let the Budget-critical #2305 take runners first. This PR's queued run had not started, so I cancelled it. Nothing is wrong with the PR.

Please don't re-run it or push just to retrigger CI. The hub re-runs this run itself once #2305 has runners. The record is ~/reviews/uk-hub/ci-yield-2026-10-11.json; see notice 17 in ~/reviews/uk-hub/notices.md.

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fine once it is merged with main and keeps the model-value record across the rebuild.

@MaxGhenis, the approach is right. The memberships come from the populations, the baseline and the dataset are cut with the same draw, and the draw is deterministic and independent of process. The quantized weights are unbiased in the sampling year: E[count] = n·w/W, so E[count·W/n] = w. Two things need doing before merge, both from main moving on since 82e0c4995.

  1. must: merge main. policyengine_uk/utils/supplied_inputs.py conflicts in two places, the module docstring and the end of the file. Both sides add text there, so keeping both works: I did that locally and the import is fine. Run ruff format afterwards, because the joined file gets an extra blank line.
  2. must, after the merge: subsample turns a scenario's model value into a supplied input. Main now has set_model_value (supplied_inputs.py), and scenarios/uc_reform.py:163 uses it for uc_LCWRA_element. _apply (utils/subsample.py:336) calls build_from_ids, which on main calls build_from_populations, which calls forget_model_values. The loop at subsample.py:353 then stores every kept value with set_input, which main treats as supplied. On a local merge, with the six-household dataset() from test_subsample.py, I called set_model_value(sim, "uc_LCWRA_element", 2026, ...) and then subsample(n=4, seed=0, time_period=2026). supplied_input(benunit, "uc_LCWRA_element", 2026) was None before the subsample and returned the stored array after it. _model_values went from four keys to none. So a subsampled scenario simulation reads its own adjustment as a user's entry. That breaks the "same results as the same households in the full simulation" property for formulas that ask supplied_input. Suggested fix: in _plan, cut each _model_values array by the same entity positions; in _apply, write the cut arrays back into simulation._model_values after the set_input loop. Add a test that supplied_input is still None after the subsample.
  3. nit: rescale_weights (subsample.py:139). With quantize_weights=True, a record whose own weight is 0 gets a positive weight if its household was drawn: rescale_weights([0, 100, 100], [1, 1, 0]) gives [100, 100, 0]. In the sampling year this can't happen for households. It can for a household with zero weight in another year, or for a supplied person or benefit unit weight of 0. If that is intended, say so in the docstring. If not, use counts * (weights > 0).
  4. nit: each supplied weight is rescaled to its own entity's total separately (entity_counts in _plan). If a dataset ever supplies person_weight alongside household_weight, a person's new weight will not equal their household's, though the model defines it that way. None of the dataset code here supplies it today, so a line in the docstring is enough.

What I checked

  • Fresh uv venv at 82e0c4995. I then merged origin/main locally (the merge is not pushed), resolved the conflict as in point 1 and re-synced to the merged lock.
  • On that merge: test_subsample.py, test_input_records.py, test_simulation_dataset_sources.py and test_dataframe_dataset.py gave 141 passed. They don't cover point 2.
  • The model-value probe in point 2, and rescale_weights called directly for point 3.
  • ruff check and ruff format --check clean on utils/subsample.py, simulation.py and tests/test_subsample.py.
  • CI at 82e0c4995: Test, Lint, Fix evidence and the smoke imports passed. There is no run on a merge with current main, because GitHub reports the PR as conflicting.
  • Not checked: the full-size dataset run and the memory figures in the PR body. My #2193 adds apply_reform to simulation.py, in a different place from subsample, so there is no textual clash.

🤖 Generated with Claude Code

@juaristi22

Copy link
Copy Markdown
Collaborator

A note from #2419, the CGT retention-rate default, tracked in the checklist on PolicyEngine/policyengine.py#602.

Once #2419 lands, every reform simulation measures marginal rates on gains against its baseline, at the reform's own gains before the response. So the baseline has to hold the same people. A subsample() that leaves self.baseline at full size would make reform calculations fail. #2419 raises a clear error in that case ("The simulation has N people and its baseline M…"), but subsample() should subsample the baseline too, or rebuild it from the subsampled data.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub takeover for the Budget fix sprint (Max, 21 Oct). The owner session local_eb7a5ce3 has been idle since mid-October. The hub woke it on 21 Oct at 23:58Z, and it did not start. To land this before the Budget model locks (the first pe-uk release cut by about 12:00Z Thu 22 Oct), the hub has taken it over as build 20261021-211252-sprint-2265, which merges main, re-tests, pushes as a fast-forward and marks it ready. The hub then reviews it and lands it through the merge queue.

If the owner session wakes, please don't push to this branch; comment here instead, so there's only one writer.

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub: takeover withdrawn. The owner session has been woken (22 Oct 01:25Z) and is finishing this PR itself, so the hub's build is cancelled. One writer: the owner session.

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

The owner session has resumed this PR at the UK hub's request (2026-10-22 01:20Z); the hub's takeover note above is withdrawn and its build 20261021-211252-sprint-2265 is cancelled. I am the only writer: merging main now, then tests, CI and a hand-off back to the hub.

MaxGhenis and others added 2 commits October 21, 2026 21:45
Main added a record of the model's own values (set_model_value), which
the UK Universal Credit health element reform stores in every simulation,
and a record of where each capital gains input came from. A subsample
rebuilds the populations, which forgets both, so it now stores each
model value back with set_model_value, restores the capital gains
record, and carries the dataset's projection annotation. Resolved the
supplied_inputs.py conflict by keeping both sides' helpers, and the
simulation.py import conflict by importing both modules.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Aggregate impact on certified data: pass

Base c65bced644 against head f53e365c01, both on enhanced_frs_2024_25.h5 (policyengine-uk-data 1.58.1, sha256 056e80fd8e91), fiscal years 2025-26 to 2031-32. Each year is a full microsimulation run on each side.

Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in report_spec.yaml; a flag does not fail the job).

Workflow run and full report

Notes

  • In the years a figure from fewer than 10 records is suppressed (spending.disabled_students_allowance), every total containing it, and the decile incomes, are rebuilt from their other components, so no published total includes it. Those totals are marked †. A change is withheld where the two sides leave out different figures and can't be lined up.

Moves flagged for review

None.

Spending by benefit and service

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed

Caseloads

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed

Standard reform costings (change in gov_balance)

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise additional rate by 3pp 0 0 0 0 0 suppressed suppressed

Standard reforms: change in each reform's target

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise additional rate by 3pp: change in income_tax 0 0 0 0 0 suppressed suppressed

Household net income by decile

No household's net income changes in any year.

No change in any year: receipts by tax head; government balance, each component counted once; model totals; household income totals; population; poverty rates; people in poverty; inequality; mean household net income in each side's own deciles.

Checks failing on both base and head (1)
  • VAT is never negative (sign:vat): 2025-26: 76 units below zero, a weighted £-54,797,972 in total; 2026-27: 76 units below zero, a weighted £-56,271,349 in total; 2027-28: 76 units below zero, a weighted £-57,609,146 in total
Counted-once check

Each of 84 components was raised by £1 per unit in 2026-27, and every head of its totals was read household by household: its own head must rise by exactly £1, no other tax head may move, no other benefit may rise, and the model's own total must move by what its heads moved. A head that breaks a rule is measured again twice: with every other head held at its baseline value, and with every other head held at its value after the first £1 while the component rises again. It fails where either still shows the response. 0 failed; 0 were skipped.

Provenance
Side Commit Runtime Environment hash Partition hash Time
base main c65bced644 uk 2.148.3 (files d7572c3e5c6c), core 3.33.2, py 3.13.17 aarch64 31784e87dc6a d4c1e9f08160 1555.72s
head #2265 merged into main f53e365c01 uk 2.148.3 (files 41ab9541418a), core 3.33.2, py 3.13.17 aarch64 31784e87dc6a d4c1e9f08160 1537.74s

Dataset: hf://policyengine/policyengine-uk-data-private/enhanced_frs_2024_25.h5@2526edbbb687a3b54dbb11272e5389e4b62d2ac2, sha256 056e80fd8e9151d78f432a25cde863340baee81304c6216a37fb575ce8563784 (verified on both sides), policyengine-uk-data 1.58.1.

Receipts by tax head: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Income tax £299.29bn £319.01bn £336.54bn £351.69bn £367.24bn £385.36bn £403.66bn
National Insurance (employee and self-employed) £52.58bn £54.94bn £56.75bn £58.48bn £60.62bn £62.57bn £65.03bn
National Insurance (employer) £152.64bn £159.18bn £164.14bn £168.73bn £176.11bn £181.72bn £188.90bn
Employer NI change borne by capital £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Employer NI change borne by consumers £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Capital gains tax £12.62bn £13.06bn £13.55bn £14.04bn £14.54bn £15.09bn £15.65bn
Student loan repayments £7.83bn £8.12bn £8.35bn £8.56bn £8.79bn £9.04bn £9.38bn
VAT £253.71bn £260.53bn £266.72bn £273.14bn £279.83bn £286.71bn £293.71bn
Change in VAT from its baseline £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
VAT on private school fees £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Fuel duties £24.53bn £24.64bn £26.64bn £26.69bn £26.42bn £25.76bn £26.35bn
Alcohol duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Tobacco duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Vehicle excise duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
TV licence fee £4.28bn £4.43bn £4.44bn £4.46bn £4.48bn £4.51bn £4.53bn
Council tax £49.56bn £52.45bn £55.78bn £59.39bn £62.98bn £66.74bn £70.70bn
High value council tax surcharge £0.00bn £0.00bn £0.00bn £0.48bn £0.49bn £0.51bn £0.52bn
Northern Ireland domestic rates £0.55bn £0.58bn £0.61bn £0.63bn £0.67bn £0.70bn £0.73bn
Business rates £31.73bn £31.73bn £31.73bn £31.73bn £31.73bn £31.73bn £31.73bn
Stamp duty land tax on the household's own purchases £6.93bn £7.42bn £7.85bn £8.26bn £8.68bn £9.09bn £9.51bn
Stamp duty land tax paid by companies £3.13bn £3.13bn £3.13bn £3.13bn £3.13bn £3.13bn £3.13bn
Land transaction tax (Wales) £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Land and buildings transaction tax (Scotland) £0.01bn £0.01bn £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn
Unspecified tax change borne by capital £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Unspecified tax change borne by consumers £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Wealth tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Wealth tax excluding the main residence £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Land value tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Carbon tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Spending by benefit and service: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
State Pension £122.15bn £126.64bn £127.76bn £129.65bn £133.46bn £137.40bn £141.47bn
Pension Credit £6.68bn £7.07bn £7.09bn £7.16bn £7.28bn £7.42bn £7.52bn
Winter Fuel Payment £1.70bn £1.68bn £1.59bn £1.57bn £1.57bn £1.55bn £1.52bn
Pension Age Winter Heating Payment (Scotland) £0.19bn £0.20bn £0.20bn £0.21bn £0.21bn £0.22bn £0.22bn
Universal Credit £75.54bn £80.75bn £83.40bn £85.21bn £86.21bn £87.61bn £88.91bn
Housing Benefit £8.59bn £8.93bn £9.19bn £9.33bn £9.61bn £9.87bn £10.15bn
Council Tax Reduction £1.99bn £2.03bn £2.08bn £2.13bn £2.18bn £2.23bn £2.29bn
Employment and Support Allowance (income-related) £2.12bn £2.18bn £2.23bn £2.28bn £2.33bn £2.39bn £2.45bn
Employment and Support Allowance (contribution-based) £5.22bn £5.36bn £5.49bn £5.62bn £5.76bn £5.90bn £6.04bn
Jobseeker's Allowance (income-based) £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Jobseeker's Allowance (contribution-based) £0.29bn £0.30bn £0.30bn £0.31bn £0.32bn £0.33bn £0.33bn
Income Support £0.12bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Working Tax Credit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Child Tax Credit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Incapacity Benefit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Personal Independence Payment £27.05bn £28.19bn £29.28bn £30.02bn £30.75bn £31.51bn £32.28bn
Disability Living Allowance £7.52bn £7.83bn £8.14bn £8.34bn £8.55bn £8.76bn £8.97bn
Attendance Allowance £8.71bn £9.08bn £9.43bn £9.67bn £9.90bn £10.15bn £10.40bn
Carer's Allowance £4.50bn £4.69bn £4.87bn £4.99bn £5.11bn £5.23bn £5.36bn
Carer Support Payment (Scotland) £0.31bn £0.32bn £0.34bn £0.34bn £0.35bn £0.36bn £0.37bn
Carer's Allowance Supplement (Scotland) £0.00bn £0.04bn £0.04bn £0.04bn £0.04bn £0.04bn £0.04bn
Severe Disablement Allowance £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn
Industrial Injuries Disablement Benefit £0.51bn £0.52bn £0.53bn £0.54bn £0.56bn £0.57bn £0.59bn
Armed Forces Compensation Scheme £0.61bn £0.62bn £0.64bn £0.65bn £0.67bn £0.69bn £0.70bn
War Widow's or Widower's Pension £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Child Benefit £16.23bn £16.91bn £17.53bn £17.96bn £18.39bn £18.84bn £19.29bn
Scottish Child Payment £0.50bn £0.52bn £0.53bn £0.55bn £0.56bn £0.57bn £0.58bn
Two Child Limit Payment (Scotland, counterfactual) £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Healthy Start vouchers £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn
Maternity Allowance £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Statutory Maternity Pay £3.32bn £3.41bn £3.49bn £3.57bn £3.66bn £3.75bn £3.84bn
Statutory Paternity Pay £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Statutory Sick Pay £1.13bn £1.16bn £1.19bn £1.22bn £1.25bn £1.28bn £1.31bn
Sure Start Maternity Grant £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn
Bereavement Support Payment £0.67bn £0.69bn £0.70bn £0.72bn £0.74bn £0.76bn £0.78bn
Tax-Free Childcare £0.55bn £0.56bn £0.57bn £0.58bn £0.60bn £0.61bn £0.59bn
Extended childcare entitlement £2.77bn £3.27bn £3.36bn £3.43bn £3.53bn £3.61bn £3.70bn
Universal childcare entitlement £2.26bn £2.45bn £2.51bn £2.58bn £2.64bn £2.72bn £2.78bn
Targeted childcare entitlement £0.47bn £0.49bn £0.50bn £0.51bn £0.52bn £0.53bn £0.47bn
Care to Learn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Childcare Grant £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Parents' Learning Allowance £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn
Adult Dependants' Grant £0.06bn £0.06bn £0.04bn £0.04bn £0.04bn £0.04bn £0.04bn
Travel Grant £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed
16 to 19 Bursary Fund £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
NHS spending £204.68bn £205.46bn £206.22bn £207.04bn £207.96bn £208.89bn £209.79bn
State education spending £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn
Transport subsidy spending £25.15bn £25.25bn £25.34bn £25.44bn £25.55bn £25.67bn £25.78bn
Cost-of-living support payment £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Energy Bills Rebate £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Energy Price Guarantee subsidy £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Basic income £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Disability basic income £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Other public spending budget change £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Caseloads: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
State Pension 11,308k 11,208k 10,906k 10,812k 10,860k 10,908k 10,955k
Pension Credit 1,491k 1,489k 1,478k 1,459k 1,459k 1,456k 1,453k
Winter Fuel Payment 7,091k 7,011k 6,599k 6,512k 6,493k 6,379k 6,248k
Pension Age Winter Heating Payment (Scotland) 806k 807k 807k 805k 809k 812k 816k
Universal Credit 6,361k 6,370k 6,404k 6,419k 6,390k 6,387k 6,368k
Housing Benefit 1,254k 1,252k 1,254k 1,239k 1,245k 1,247k 1,249k
Council Tax Reduction 3,186k 3,211k 3,226k 3,245k 3,264k 3,281k 3,293k
Employment and Support Allowance (income-related) 187k 188k 188k 189k 190k 190k 191k
Employment and Support Allowance (contribution-based) 722k 724k 727k 730k 733k 737k 740k
Jobseeker's Allowance (income-based) 0k 0k 0k 0k 0k 0k 0k
Jobseeker's Allowance (contribution-based) 67k 67k 68k 68k 68k 69k 69k
Income Support 25k 0k 0k 0k 0k 0k 0k
Working Tax Credit 0k 0k 0k 0k 0k 0k 0k
Child Tax Credit 0k 0k 0k 0k 0k 0k 0k
Incapacity Benefit 0k 0k 0k 0k 0k 0k 0k
Personal Independence Payment 3,581k 3,595k 3,608k 3,623k 3,639k 3,655k 3,671k
Disability Living Allowance 1,296k 1,301k 1,306k 1,311k 1,317k 1,323k 1,329k
Attendance Allowance 1,701k 1,708k 1,714k 1,721k 1,729k 1,736k 1,744k
Carer's Allowance 1,038k 1,042k 1,046k 1,050k 1,055k 1,059k 1,064k
Carer Support Payment (Scotland) 71k 72k 72k 72k 73k 73k 73k
Carer's Allowance Supplement (Scotland) 0k 72k 72k 72k 73k 73k 73k
Severe Disablement Allowance 4k 4k 4k 4k 4k 4k 4k
Industrial Injuries Disablement Benefit 137k 138k 139k 139k 140k 140k 141k
Armed Forces Compensation Scheme 94k 94k 94k 95k 95k 95k 96k
War Widow's or Widower's Pension 0k 0k 0k 0k 0k 0k 0k
Child Benefit 8,136k 8,165k 8,185k 8,215k 8,249k 8,282k 8,314k
Scottish Child Payment 352k 354k 355k 359k 357k 358k 357k
Two Child Limit Payment (Scotland, counterfactual) 0k 0k 0k 0k 0k 0k 0k
Healthy Start vouchers 200k 201k 202k 203k 204k 204k 205k
Maternity Allowance 0k 0k 0k 0k 0k 0k 0k
Statutory Maternity Pay 334k 335k 336k 338k 339k 341k 342k
Statutory Paternity Pay 0k 0k 0k 0k 0k 0k 0k
Statutory Sick Pay 182k 183k 183k 184k 185k 186k 186k
Sure Start Maternity Grant 26k 26k 26k 27k 27k 27k 27k
Bereavement Support Payment 98k 98k 99k 99k 100k 100k 101k
Tax-Free Childcare 1,018k 1,029k 1,028k 1,033k 1,034k 1,039k 1,023k
Extended childcare entitlement 718k 724k 728k 732k 737k 741k 743k
Universal childcare entitlement 986k 989k 992k 997k 1,002k 1,013k 1,015k
Targeted childcare entitlement 98k 98k 96k 96k 96k 97k 84k
Care to Learn 0k 0k 0k 0k 0k 0k 0k
Childcare Grant 0k 0k 0k 0k 0k 0k 0k
Parents' Learning Allowance 98k 99k 99k 100k 100k 100k 101k
Adult Dependants' Grant 18k 18k 12k 13k 13k 13k 13k
Travel Grant 0k 0k 0k 0k 0k 0k 0k
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed
16 to 19 Bursary Fund 0k 0k 0k 0k 0k 0k 0k
Cost-of-living support payment 0k 0k 0k 0k 0k 0k 0k
Energy Bills Rebate 0k 0k 0k 0k 0k 0k 0k
Energy Price Guarantee subsidy 0k 0k 0k 0k 0k 0k 0k
Basic income 0k 0k 0k 0k 0k 0k 0k
Disability basic income 0k 0k 0k 0k 0k 0k 0k
Government balance, each component counted once: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Government receipts, each component once £899.38bn £939.24bn £976.25bn £1,009.45bn £1,045.73bn £1,082.67bn £1,123.55bn
Government spending £531.92bn † £546.96bn † £554.90bn † £562.04bn † £570.63bn † £579.83bn † £588.90bn †
Government balance, each receipt once £367.47bn † £392.28bn † £421.35bn † £447.41bn † £475.10bn † £502.84bn † £534.65bn †
Benefits in household_benefits but not in gov_spending £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Model totals: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
gov_tax £899.38bn £939.24bn £976.25bn £1,009.45bn £1,045.73bn £1,082.67bn £1,123.55bn
household_tax £493.03bn £519.53bn £545.39bn £567.58bn £589.79bn £614.24bn £640.95bn
pre_budget_change_household_tax £485.21bn £511.41bn £537.04bn £558.54bn £580.51bn £604.69bn £631.05bn
gov_spending £531.92bn † £546.96bn † £554.90bn † £562.04bn † £570.63bn † £579.83bn † £588.90bn †
household_benefits £531.92bn † £546.96bn † £554.90bn † £562.04bn † £570.63bn † £579.83bn † £588.90bn †
gov_balance £367.47bn † £392.28bn † £421.35bn † £447.41bn † £475.10bn † £502.84bn † £534.65bn †
Household income totals: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Household market income £1,657.06bn £1,719.25bn £1,771.68bn £1,821.99bn £1,872.88bn £1,930.99bn £2,001.98bn
Household net income £1,656.67bn † £1,705.92bn † £1,739.31bn † £1,773.51bn † £1,809.65bn † £1,851.24bn † £1,902.89bn †
Household net income (HBAI definition) £1,463.15bn £1,510.70bn £1,544.54bn £1,577.63bn £1,611.73bn £1,650.77bn £1,701.20bn
Population: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
People 69,514k 69,778k 70,036k 70,316k 70,626k 70,944k 71,249k
Benefit units 35,247k 35,381k 35,512k 35,654k 35,811k 35,972k 36,127k
Households 31,167k 31,285k 31,401k 31,526k 31,665k 31,808k 31,944k
Poverty rates: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Absolute poverty, before housing costs: everyone 16.2% 15.2% 15.5% 15.7% 15.7% 15.8% 15.8%
Absolute poverty, before housing costs: children 24.6% 21.4% 21.6% 21.6% 21.8% 22.0% 21.9%
Absolute poverty, before housing costs: working-age adults 13.9% 13.5% 14.0% 14.1% 14.2% 14.3% 14.2%
Absolute poverty, before housing costs: pensioners 13.7% 13.2% 13.2% 13.5% 13.5% 13.6% 13.6%
Absolute poverty, after housing costs: everyone 21.5% 20.8% 21.4% 21.6% 21.9% 22.2% 22.2%
Absolute poverty, after housing costs: children 33.4% 30.9% 31.2% 31.3% 31.7% 32.2% 32.3%
Absolute poverty, after housing costs: working-age adults 19.8% 19.6% 20.3% 20.4% 20.8% 21.0% 21.0%
Absolute poverty, after housing costs: pensioners 12.8% 12.6% 12.6% 13.0% 13.3% 13.4% 13.4%
Relative poverty, before housing costs: everyone 17.2% 16.5% 16.5% 16.6% 16.4% 16.5% 16.6%
Relative poverty, before housing costs: children 26.4% 23.7% 23.4% 23.4% 22.9% 23.0% 23.4%
Relative poverty, before housing costs: working-age adults 14.6% 14.4% 14.6% 14.8% 14.7% 14.8% 14.9%
Relative poverty, before housing costs: pensioners 15.0% 14.8% 14.1% 14.2% 14.0% 14.1% 14.2%
Relative poverty, after housing costs: everyone 21.7% 21.1% 21.3% 21.3% 21.4% 21.5% 21.9%
Relative poverty, after housing costs: children 33.5% 31.3% 31.1% 31.0% 31.0% 31.1% 31.7%
Relative poverty, after housing costs: working-age adults 19.9% 19.8% 20.2% 20.3% 20.4% 20.5% 20.8%
Relative poverty, after housing costs: pensioners 13.0% 12.7% 12.6% 12.3% 12.2% 12.2% 13.1%
People in poverty: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Absolute poverty, before housing costs: everyone 11,270k 10,578k 10,858k 11,007k 11,103k 11,238k 11,252k
Absolute poverty, before housing costs: children 3,696k 3,227k 3,267k 3,285k 3,319k 3,371k 3,363k
Absolute poverty, before housing costs: working-age adults 5,940k 5,792k 6,071k 6,182k 6,234k 6,302k 6,314k
Absolute poverty, before housing costs: pensioners 1,634k 1,559k 1,519k 1,540k 1,550k 1,566k 1,575k
Absolute poverty, after housing costs: everyone 14,972k 14,539k 14,956k 15,179k 15,479k 15,741k 15,843k
Absolute poverty, after housing costs: children 5,005k 4,656k 4,709k 4,752k 4,834k 4,930k 4,973k
Absolute poverty, after housing costs: working-age adults 8,445k 8,399k 8,796k 8,942k 9,125k 9,271k 9,320k
Absolute poverty, after housing costs: pensioners 1,521k 1,484k 1,452k 1,485k 1,520k 1,539k 1,550k
Relative poverty, before housing costs: everyone 11,980k 11,485k 11,528k 11,641k 11,552k 11,677k 11,832k
Relative poverty, before housing costs: children 3,967k 3,570k 3,543k 3,556k 3,491k 3,522k 3,593k
Relative poverty, before housing costs: working-age adults 6,227k 6,161k 6,359k 6,462k 6,453k 6,536k 6,596k
Relative poverty, before housing costs: pensioners 1,785k 1,754k 1,627k 1,623k 1,608k 1,619k 1,644k
Relative poverty, after housing costs: everyone 15,057k 14,705k 14,915k 14,985k 15,110k 15,227k 15,621k
Relative poverty, after housing costs: children 5,024k 4,718k 4,698k 4,701k 4,731k 4,765k 4,874k
Relative poverty, after housing costs: working-age adults 8,480k 8,486k 8,769k 8,885k 8,981k 9,056k 9,230k
Relative poverty, after housing costs: pensioners 1,552k 1,501k 1,448k 1,398k 1,398k 1,405k 1,516k
Inequality: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Gini coefficient, equivalised HBAI income before housing costs 0.3087 0.3060 0.3067 0.3074 0.3079 0.3085 0.3096
Mean household net income in each side's own deciles: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Decile 1: mean household_net_income per household £17,832 † £18,015 † £18,026 † £18,059 † £18,395 † £18,583 † £18,743 †
Decile 2: mean household_net_income per household £28,134 † £29,089 † £28,825 † £29,239 † £29,564 † £29,945 † £30,476 †
Decile 3: mean household_net_income per household £34,455 † £35,681 † £36,264 † £36,779 † £37,076 † £37,626 † £38,511 †
Decile 4: mean household_net_income per household £39,398 † £41,043 † £42,036 † £42,777 † £43,509 † £44,366 † £44,673 †
Decile 5: mean household_net_income per household £43,698 † £45,019 † £46,119 † £46,804 † £47,819 † £48,805 † £49,921 †
Decile 6: mean household_net_income per household £48,494 † £49,775 † £50,906 † £51,593 † £52,132 † £53,429 † £54,829 †
Decile 7: mean household_net_income per household £56,356 † £57,547 † £58,429 † £59,170 † £60,256 † £60,799 † £62,484 †
Decile 8: mean household_net_income per household £68,817 † £70,403 † £71,736 † £73,017 † £74,372 † £75,880 † £77,602 †
Decile 9: mean household_net_income per household £79,735 † £82,088 † £83,308 † £84,528 † £86,191 † £87,657 † £90,676 †
Decile 10: mean household_net_income per household £117,772 † £120,640 † £122,567 † £124,670 † £126,895 † £129,221 † £132,115 †
Standard reform costings (change in gov_balance): head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise basic rate by 1pp £6.22bn £6.50bn £6.70bn £6.90bn £7.11bn £7.34bn £7.62bn
Raise higher rate by 1pp £3.54bn £3.82bn £4.05bn £4.27bn £4.49bn £4.76bn £4.96bn
Raise personal allowance by ~800GBP/year £-3.83bn £-3.96bn £-4.03bn £-4.10bn £-4.19bn £-4.30bn £-2.02bn
Raise child benefit by 25GBP/week per additional child £-2.00bn £-1.76bn £-1.58bn £-1.48bn £-1.38bn £-1.28bn £-1.17bn
Reduce Universal Credit taper rate to 20% £-20.49bn £-21.05bn £-21.50bn £-21.94bn £-22.03bn £-22.40bn £-22.87bn
Raise Class 1 main employee NICs rate to 10% £11.07bn £11.51bn £11.84bn £12.14bn £12.49bn £12.83bn £13.23bn
Raise VAT standard rate by 2pp £25.01bn £25.68bn £26.29bn £26.92bn £27.58bn £28.26bn £28.95bn
Raise additional rate by 3pp £2.83bn £3.07bn £3.27bn £3.47bn £3.67bn suppressed suppressed
Raise the Universal Credit standard allowance by 10% £-3.03bn £-3.16bn £-3.28bn £-3.35bn £-3.39bn £-3.44bn £-3.51bn
Raise the State Pension by 10% £-7.81bn £-8.07bn £-7.99bn £-8.11bn £-8.36bn £-8.66bn £-9.02bn
Standard reforms: change in each reform's target: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise basic rate by 1pp: change in income_tax £6.36bn £6.65bn £6.86bn £7.07bn £7.28bn £7.52bn £7.80bn
Raise higher rate by 1pp: change in income_tax £3.55bn £3.83bn £4.06bn £4.28bn £4.50bn £4.77bn £4.97bn
Raise personal allowance by ~800GBP/year: change in income_tax £-3.96bn £-4.10bn £-4.19bn £-4.26bn £-4.36bn £-4.47bn £-1.77bn
Raise child benefit by 25GBP/week per additional child: change in child_benefit £2.34bn £2.15bn £1.96bn £1.85bn £1.74bn £1.63bn £1.51bn
Reduce Universal Credit taper rate to 20%: change in universal_credit £20.48bn £21.04bn £21.49bn £21.93bn £22.02bn £22.40bn £22.86bn
Raise Class 1 main employee NICs rate to 10%: change in national_insurance £11.33bn £11.79bn £12.13bn £12.44bn £12.78bn £13.13bn £13.62bn
Raise VAT standard rate by 2pp: change in vat £25.01bn £25.68bn £26.29bn £26.92bn £27.58bn £28.26bn £28.95bn
Raise additional rate by 3pp: change in income_tax £2.83bn £3.07bn £3.27bn £3.47bn £3.67bn suppressed suppressed
Raise the Universal Credit standard allowance by 10%: change in universal_credit £3.03bn £3.16bn £3.28bn £3.36bn £3.41bn £3.47bn £3.52bn
Raise the State Pension by 10%: change in state_pension £10.72bn £11.23bn £11.37bn £11.62bn £12.08bn £12.54bn £13.07bn

MaxGhenis and others added 3 commits October 21, 2026 23:01
Address vahid-ahmadi's review of #2265 (points 3 and 4):

- With quantize_weights, a drawn record whose own weight is zero got a
  positive weight: a household drawn by its weight in the sampling year
  with a zero weight in another year, or a zero person or benefit unit
  weight. A zero weight stands for no one, so it now stays zero, and the
  year's total goes to the drawn records that stand for someone.
- Each supplied weight is rescaled to its own entity's total, so a person
  weight supplied alongside household weights need not equal the new
  weight of the person's household. Say so where the weights are listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d has no weight

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

@vahid-ahmadi thank you; all four points are addressed.

  1. Merge main: done in 7dad7d49, merging main at 7918fc2a. Both conflicts kept both sides, as you suggested: in supplied_inputs.py (docstring and helpers) and an import in simulation.py.
  2. Model values: done in the same merge, though not quite as you suggested. Every kept input whose stored value is a model value (is_model_value, a small public wrapper on _is_model_value) is stored back with set_model_value, rather than written into _model_values directly. So it is recorded exactly as a scenario would record it, cut to the sample. The merge also restores the capital gains input provenance (_cgt_input_provenance, _cgt_defaulted_periods), which _start_new_population resets, and carries the dataset's _cgt_extension_provenance to the subsampled dataset.
    • test_a_model_value_stays_the_models: your probe. supplied_input is None for uc_LCWRA_element after the subsample, a supplied uc_carer_element still reads as supplied, and the UC reform's own 2027–2032 model values stay the model's on the simulation and its baseline copy.
    • test_where_capital_gains_inputs_came_from_is_kept: provenance. Each of the three new pieces fails one of these two tests when removed.
  3. Zero weights: fixed in ab843c80. A drawn record with a zero weight now keeps a zero weight, and the year's total goes to the drawn records with a positive weight. rescale_weights([0, 100, 100], [1, 1, 0]) is now [0, 200, 0] (test_a_zero_weight_stays_zero_in_every_year). A weight held only by records that were not drawn is refused in both modes.
  4. Separate rescaling: documented where WEIGHT_VARIABLES is defined, and in the PR's invariant 3.

Since then: the targeted suite (subsample, input records, dataset sources, DataFrame round trip, the UC health element tests, CGT projection and response default) gave 377 passed on core 3.33.2 and on 3.33.12 at 7b4c3c28. test_subsample.py gave 56 passed at ab843c80. Aggregate impact on 7b4c3c28: no change in any year.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

@juaristi22 thanks for the note on #2419. subsample() replaces the baseline (and its baseline, for a scenario simulation) with a copy cut down to the same households and people, with the same draw. So after #2419, a subsampled reform simulation and its baseline hold the same people. test_a_reform_and_its_baseline_keep_the_same_households checks this on a reform built with reform=, and test_subsampling_a_clone_leaves_the_source_and_its_baseline_alone checks that a clone's subsample leaves the source's baseline whole.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Hand-off to the UK hub (Budget fix sprint). The owner session local_eb7a5ce3 resumed this PR at the hub's request on 22 Oct and is handing it back for review and landing through the merge queue. I am not merging it myself.

  • Head: db3a38e0. It merges main at 7918fc2a (7dad7d49), then three commits: the zero-weight fix and two docstring commits.
  • Merge resolution: both conflicts kept both sides (supplied_inputs.py helpers and docstring, a simulation.py import). main's new records survive a subsample:
    • model values (set_model_value, as the UC health element reform stores for 2026–2032): stored back as the model's;
    • the capital gains input provenance: restored;
    • the dataset's _cgt_extension_provenance: carried to the subsampled dataset.
  • Review: @vahid-ahmadi's review (5514224679, COMMENTED at 82e0c499) had two musts and two nits. All four are addressed; my reply is above. The rounds-1 to 3 Sol reviews predate the merge. Round 3 never returned a verdict: Codex transport failures, then quarantine. So no independent review has approved this head yet, which the hub said it runs.
  • Tests run locally (4 workers):
    • At 7b4c3c28, the targeted suite gave 377 passed on core 3.33.2 (locked) and on 3.33.12 (latest). It covers subsample, input records, dataset sources, the DataFrame round trip, the four UC health element files, CGT projection and CGT response default.
    • At ab843c80, test_subsample.py gave 56 passed on both cores.
    • Ruff with the latest uvx ruff is clean.
  • Aggregate impact (on 7b4c3c28): pass. 0 checks broken, 0 moves flagged, no household's net income changes in any year. The only check failing (sign:vat) fails on both sides.
  • CI at db3a38e0: queued (Changes, Fix evidence, Lint pending when handed off). Earlier, at 7b4c3c28, Aggregate impact passed and the other checks were still running.
  • Depends on: nothing. Count only supplied inputs that are still stored in their tier #2308 (draft, fixes supplied_input and supplied_input_periods count a value cached over a supplied input as supplied #2307) is stacked on this branch and moves to main when this lands.
  • Follow-ups owed: none from this PR. person_household_id and person_benunit_id are stored as float32, which rounds large identifiers #2267 (float32 membership ids) has Store person_household_id and person_benunit_id as integers #2273 open, which this PR does not depend on.
  • Run outputs: ~/reviews/pe-uk-2254-subsample/ (reviews r1–r3, real-scale JSON, mutation logs, local test logs, this description).

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub independent review (GPT-6.1 Sol) at db3a38e: REQUEST_CHANGES, one P2.

Subsampling drops stored inputs for neutralised variables (policyengine_uk/utils/subsample.py:385-392): fresh holders reject the replay through set_input. Reproduced with two £30,000 earners: supply adjusted_net_income=10,000, neutralise it through apply_reform, then subsample(n=1, seed=0, time_period=2025). The retained person's input record disappears; net_income changes from £0 to £30,000 and income_tax from £0 to £3,486, because net_income.py:29 switches paths. Preserve canonical stored inputs and model markers during replay, and add a neutralisation regression (test_capital_gains_projection.py:1080 has a preservation contract for neutralised gains).

Everything else checked out: all four of Vahid's points, memberships and ids, storage tiers, baseline isolation, UC model values, CGT provenance; simulation.py adds only the import and the override; 17/17 checks green; no household net-income change in any year; 379 tests passed at -n 2. This PR isn't Budget-material, so the fix can follow the Budget if needed. The full review is at ~/reviews/uk-hub/reviews/uk2265/REVIEW_2265.md.

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub hand-off for review P2 at comment 6335788910: fix committed locally; validation and push blocked by host limits.

  • Local fix head: 9a91736f39990b87317116a2f59ebdc8c9054749, on top of conflict-free merge fc537e4e3 of origin/main at fe0b99a36. Existing PR author and history preserved; remote head remains db3a38e07.
  • Neutralised holders retain canonical stored input arrays, input records and model markers. Added supplied/model ANI regressions covering unchanged tax results and restoration, plus a changelog update. Ordinary replay is unchanged.
  • Passed: touched-file Ruff formatting/lint, git diff --check, and uvx ruff format --check . (1940 files).
  • Not run: locked environment setup and foreground pytest -n 2. After waiting, load1 was 172.65 and disk 54.98 GB, outside the requested limits (110 and 60 GB). No test suite or microsimulation started; the foreground resource wait was stopped before hand-off. The one permitted push remains unused.
  • Recovery: .job/HANDOFF.md, .job/PROGRESS.md, .job/commits.bundle and PR-body draft in /Users/maxghenis/.subfleet/worktrees/20261022-122605-sprint-2265-p2. Shared Git metadata is read-only, so local commits use git --git-dir=.job/git --work-tree=.. Bundle verified successfully.
  • Open items: restore host capacity; run locked targeted tests; push once to fix-subsample-2254; dispatch the hub's independent review at that final head. No independent review, aggregate-impact run, data build or merge performed. This is not Budget-material.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub (Claude session, for Max): independent review r2 (GPT-6.1 Sol) at 9a91736f3: REQUEST_CHANGES. A hub fix build is running (fix-2265-r3).

[P2] Restoring a neutralized variable still returns zero after subsampling — policyengine_uk/utils/subsample.py:385-392; policyengine_uk/tests/test_subsample.py:584-586. Rebuilding creates holders bound to the neutralized variable instance. RestoreIncome replaces the system's variable, but the holder keeps its old reference: the system reports is_neutralized=False, the holder reports True, and Holder.get_array() returns zero despite retaining the £10,000 input. Both new regression variants fail. A separate probe confirms restoration works without subsampling; rebinding the sampled holder restores £10,000 in both supplied/model cases. Rebind holders to restored variable definitions and retain these assertions.

Everything else in the round-one fix holds: canonical stored inputs, supplied/model ownership and ordinary replay. CI at this head fails exactly the two new regressions.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub (Claude session, for Max): independent review r3 (GPT-6.1 Sol) at 74b0c65d7: REQUEST_CHANGES. r2's read-after-restore case is fixed, but rebinding holders only at cache invalidation is too late:

  • Regression: test_capital_gains_projection.py::test_neutralized_supplied_gains_report_default_without_unused_warning[neutralize_variable] now returns £120,000 instead of £555. It passes once the new override is removed.
  • Write inside a restoring reform: a reform that calls replace_variable(original) and then set_input(..., [20_000]) hits a holder that is still neutralised. Core rejects the write and keeps £10,000.

The underlying bug is in policyengine-core, where a Holder caches a Variable that runtime reforms replace. A core fix is planned. The hub is running one more bounded pe-uk build (fix-2265-r4). If a correct pe-uk fix would need patching core internals, the build stops, marks the new regressions strict-xfail, and this PR waits for the core release.

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

UK hub (Claude session, for Max): waiting on policyengine-core. e4c54d7fa removes r3's _invalidate_all_caches override, so simulation.py and utils/subsample.py again match 9a91736f3. It also adds supplied/model × direct/subsampled regressions for writes inside a restoring reform.

A holder that tracks the system on every read and write would also reject the unchanged CGT test's £555 write made while the variable is neutralised. So a correct fix needs core's Holder to follow runtime variable replacement. Four cases are marked xfail(strict=True, reason="needs policyengine-core holder resync"): the two sampled writes and the two r2 restorations. Locally, 244 passed and 4 xfailed.

A core fix is planned. Once it ships, bump core, remove the four markers and their two allowlist entries, and re-review. This isn't Budget work, so it stays out of the merge queue until then.

This branch has not been deployed

No deployments
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.

Simulation.subsample() raises TypeError: build_from_dataset() needs a dataset

3 participants