Skip to content

Shared calibration machinery for local areas: L2 anchor, target-weight rule, loss cap for each target and one area support gate #1729

In progress

Description

@juaristi22

Why

The UK local build uses solver options that the US local build does not use. Most of them are already in the shared solver (microcosm.calibrate). The rest is country code on both sides.

This issue moves each piece to shared code, with the country's choice as data. No item changes an output until a build turns it on. No item adds a check that can block a release.

Where each piece is today

Piece Shared code UK local build US local build
L2 penalty, chi-square basis Yes, since #1078 On (refit stage) Flags exist (--l2-lambda, --l2-basis). Default λ is 0
L2 anchor Yes: l2_anchor and l2_anchor_weights in calibrate uniform Not exposed. Always initial
Target-weight rule across levels and families No nation_grain_family_equal_sqrt_count in uk_runtime/local_doctrine.py us_runtime/target_loss_weights.py: weights by value and concept. No balance across levels
Loss cap One number for the run One number One number. The county profile changes it for the whole joint run
Area support gate microcosm.build.gates.area_support_gate (rows, ESS, distinct sources) Used Own gate in the tool (district_ess_collapse_gate), plus two copies of the ESS code
Weight bound max_weight_ratio, relative to each row's own starting weight Used Used. A donor row starts about 27 times heavier than an ACS row, so its bound is 27 times higher

Work

  1. Expose the L2 anchor in the US local tool.
    • Add --l2-anchor and an option for anchor weights.
    • With the initial anchor, the penalty pulls toward the starting weights, so ESS cannot pass their ESS.
    • Anchor weights let the penalty pull toward a declared design, without a change to the starting weights.
  2. Move the target-weight rule to shared code.
    • Today the UK rule reads a UK-only row carrier. The US function already takes plain row arrays.
    • Write one shared rule that takes the level, family, basis and value of each target.
    • Each country declares the rule name and its parameters.
    • On the September surface, state SOI rows hold 90.2% of the US loss weight.
  3. Allow a loss cap for each target or family.
    • Today the county profile sets the cap to 10 and the weight ratio to 5 for the whole joint run.
    • A vector of caps keeps the state and district caps as they are when county rows join the solve.
  4. Use one area support gate.
  5. State one contract for the weight bound (max_weight_ratio anchors differently per arm: 5x vs design (dense) but ~25x effective (sparse refit re-anchors) — declare one stretch contract #493). Consider a bound relative to a declared reference weight, so that a heavy starting row does not get a larger bound.
  6. Add a diagnostic for each spine and target.

Parked

Done when

  • Items 1 to 4 and 6 are in shared code with tests, and each country's choice is a declaration.
  • A US local build with the default declarations gives the same weights as before.
  • The US tools hold no copy of the ESS or gate code.

Related

#1078, #1104, #1163, #1124, #1585, #611, #493, #458, #578.

Activity

  1. added a commit that references this issue on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions