diff --git a/changelog.d/calibration-arm-wording.fixed.md b/changelog.d/calibration-arm-wording.fixed.md new file mode 100644 index 0000000000..2882e35ac5 --- /dev/null +++ b/changelog.d/calibration-arm-wording.fixed.md @@ -0,0 +1 @@ +The US builder's dense SSI fence text, which builds write into their manifests, and the `us_ssi_take_up_delivery_gate` docstring now name the builder's arms by flag: the fences apply to `--dense-default-dataset`, and the L0+refit arm (neither flag) and `--exact-k` keep hard enforcement. They no longer call the dense arm "diagnostic" or the L0+refit arm "the sparse certified default". The `calibrate_l0_refit` and `L0RefitResult` docstrings, and the rest of `solve.py`'s wording about the refit stage, say what the function returns instead of calling it the production path or its weights shipped. The generated US calibration contract's release modes are renamed to the builder's `dataset.default.method` values: `default_sparse_l0_refit` becomes `l0_refit`, `dense_diagnostic` becomes `dense_no_l0`, and `refit_contracts.default_sparse` becomes `refit_contracts.l0_refit`. The US release build rule now says which code uses `microcosm.build.holdout`, and that no held-out test compares a US national candidate with the incumbent. No flag, default, calibration, draw or dataset changes. diff --git a/docs/evidence/spec-engine/us-f0-coverage.json b/docs/evidence/spec-engine/us-f0-coverage.json index 9b3624c2e6..348354e26c 100644 --- a/docs/evidence/spec-engine/us-f0-coverage.json +++ b/docs/evidence/spec-engine/us-f0-coverage.json @@ -109,7 +109,7 @@ "mode": "legacy_behavior", "pointer_class": "all", "pointer_count": 320, - "pointer_sha256": "49a153b065b59950d910f9e2bcfcd7005e5babaecf9b41b1cc9704a7f20dcc5b", + "pointer_sha256": "5336f77a10b2f0aa03f6bc221f3c5b8390adccaeed8ee3e7251292606a83a7fd", "rationale": null, "relative_sink_prefix": "/calibration_contract", "source_prefix": "/authored/spec~1calibration.yaml", @@ -771,7 +771,7 @@ "legacy_behavior": 14269 }, "multiple_primary_use_field_count": 0, - "pointer_inventory_sha256": "7765ab26649d67e3ae69a8b10af462fc7e7921ed88f681503aa766640f6cf821", + "pointer_inventory_sha256": "65c75e48867b39bc443891c2bada2fcc6eed80b2c1fa1bf5ced14ae862bad47f", "resolved_binding_field_count": 9786, "unused_field_count": 0 }, @@ -1642,13 +1642,13 @@ "compiler_ir.node_slices" ], "expected": { - "map_sha256": "6474719c2fbd765114d104118fc9f265df4694c25fab6ddde6cf5974d069b522", - "protocol_sha256": "d3a0baf888c2ac5a9d10980ec725f6cb4d1ca7de5f5e6624297858341c1a2035" + "map_sha256": "d756dc67535c04788e605bedb4cd6721cf715e5f5ce4be73d9b27420a61b3d50", + "protocol_sha256": "2c57cbfb9dd0f132f9b5751eb8bc303f4b7e37430cd5e0b155aac0b0b8eaa42e" }, "failures": [], "observed": { - "map_sha256": "6474719c2fbd765114d104118fc9f265df4694c25fab6ddde6cf5974d069b522", - "protocol_sha256": "d3a0baf888c2ac5a9d10980ec725f6cb4d1ca7de5f5e6624297858341c1a2035" + "map_sha256": "d756dc67535c04788e605bedb4cd6721cf715e5f5ce4be73d9b27420a61b3d50", + "protocol_sha256": "2c57cbfb9dd0f132f9b5751eb8bc303f4b7e37430cd5e0b155aac0b0b8eaa42e" }, "status": "covered" }, @@ -1663,7 +1663,7 @@ "compiler_ir.seed_stream_map" ], "expected": { - "implementation_sha256": "d3a0baf888c2ac5a9d10980ec725f6cb4d1ca7de5f5e6624297858341c1a2035", + "implementation_sha256": "2c57cbfb9dd0f132f9b5751eb8bc303f4b7e37430cd5e0b155aac0b0b8eaa42e", "protocol": "legacy-v1", "streams": [ "build_model", @@ -1684,7 +1684,7 @@ }, "failures": [], "observed": { - "implementation_sha256": "d3a0baf888c2ac5a9d10980ec725f6cb4d1ca7de5f5e6624297858341c1a2035", + "implementation_sha256": "2c57cbfb9dd0f132f9b5751eb8bc303f4b7e37430cd5e0b155aac0b0b8eaa42e", "protocol": "legacy-v1", "streams": [ "build_model", @@ -2585,7 +2585,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "4e2b6c19661079b1c75ab694d043c76d22f52465e7b01d37dc499a3611ca6d8c" + "spec_sha256": "372858d059a129d7b3bcbd7ac2dbdc314742345bd35aaff8d53943e737c98f84" } }, "report_schema_version": 3, @@ -2595,7 +2595,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "4e2b6c19661079b1c75ab694d043c76d22f52465e7b01d37dc499a3611ca6d8c" + "spec_sha256": "372858d059a129d7b3bcbd7ac2dbdc314742345bd35aaff8d53943e737c98f84" }, "status": "pass" } diff --git a/docs/us-release-build-rule.md b/docs/us-release-build-rule.md index 0b0629020f..6ea4f3ed17 100644 --- a/docs/us-release-build-rule.md +++ b/docs/us-release-build-rule.md @@ -21,10 +21,23 @@ frozen comparison register, both rescored on it, with strict improvement `tools/build_us_fiscal_refresh_release.py`). That gate runs on the `--exact-k` arm only, and that arm takes a pool manifest, which the release tool refuses to combine with `--base-h5`. A `--base-h5` release runs no improvement gate. -Main has no US held-out test: the rotated-fold holdout in -`microcosm.build.holdout` is imported by the UK runtime and UK tools only. So a -US release says it beats the incumbent on the frozen register, and says it beats -it on held-out cells only once a US holdout exists and has run. +Main has no held-out test that compares a US national candidate with the +incumbent. Among the packages and tools, only the UK runtime +(`uk_runtime/local_rowwise.py`) runs the rotated folds in +`microcosm.build.holdout`; an ACS local-area experiment +(`experiments/us-acs-local-l2-basis-20260928/prepare.py`) also uses them. US +package and tool code imports only the module's keyed-hash helpers. The ACS +local-area tools (`tools/us_acs_local_cd_surface.py` and +`tools/us_acs_local_county_surface.py`) use them to keep blocks of district and +county SOI targets out of the local-area solve, then score those blocks against +a pro-rata baseline; the scores are marked report-only and refuse nothing. +`us_runtime/support_mix.py` uses them to split targets and to order ACS +households for the support-mix bake-off. The national builder imports neither +helper. Its three +`*_holdout.json` reports compare one build with outside benchmarks and never +refuse a release. So a US national release says it beats the incumbent on the +frozen register, and says it beats it on held-out cells only once a national +holdout exists and has run. Publication stays a human step. Since the US repository's switch to `releases.json`, the release tool writes each build to diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py index 3edc052cab..2546782666 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py @@ -362,7 +362,7 @@ def _path_inventory(rows: Sequence[tuple[str, object]]) -> tuple[int, str]: ), "calibration": ( 320, - "49a153b065b59950d910f9e2bcfcd7005e5babaecf9b41b1cc9704a7f20dcc5b", + "5336f77a10b2f0aa03f6bc221f3c5b8390adccaeed8ee3e7251292606a83a7fd", ), "catalog_columns": ( 1_593, diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py index 85b3c3ae0a..fff542b87b 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py @@ -399,8 +399,11 @@ # move both again; no valid input's draw changes. microcosm#1617's refusal # of a weightless class in the balanced gate's weights moves both again; # no fit reached it, and no draw changes. - "seed_map": "6474719c2fbd765114d104118fc9f265df4694c25fab6ddde6cf5974d069b522", - "seed_protocol": "d3a0baf888c2ac5a9d10980ec725f6cb4d1ca7de5f5e6624297858341c1a2035", + # microcosm#1641 moves both again: it rewords docstrings and a comment in + # solve and the delivery gate's docstring in ssi_take_up, which now names + # the builder's arms by flag; no draw, RNG rule, QRF target or solve changes. + "seed_map": "d756dc67535c04788e605bedb4cd6721cf715e5f5ce4be73d9b27420a61b3d50", + "seed_protocol": "2c57cbfb9dd0f132f9b5751eb8bc303f4b7e37430cd5e0b155aac0b0b8eaa42e", "source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6", "take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35", "tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0", diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json index 5bc064fe0c..efaac418e4 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json @@ -22,9 +22,9 @@ "refit_contracts": { "type": "object", "additionalProperties": false, - "required": ["default_sparse", "exact_k"], + "required": ["l0_refit", "exact_k"], "properties": { - "default_sparse": {"$ref": "#/$defs/refit_contract"}, + "l0_refit": {"$ref": "#/$defs/refit_contract"}, "exact_k": {"$ref": "#/$defs/refit_contract"} } }, @@ -577,12 +577,12 @@ "type": "object", "additionalProperties": false, "required": [ - "default_sparse_l0_refit", - "dense_diagnostic", + "l0_refit", + "dense_no_l0", "exact_k_or_full_pool_refit" ], "properties": { - "default_sparse_l0_refit": { + "l0_refit": { "type": "object", "additionalProperties": false, "required": ["kernel", "solver_ref", "selection_contract_ref", "refit_contract_ref"], @@ -590,10 +590,10 @@ "kernel": {"const": "kernel:calibrate_l0_refit"}, "solver_ref": {"const": "solver"}, "selection_contract_ref": {"const": "solver.l0_contract"}, - "refit_contract_ref": {"const": "refit_contracts.default_sparse"} + "refit_contract_ref": {"const": "refit_contracts.l0_refit"} } }, - "dense_diagnostic": { + "dense_no_l0": { "type": "object", "additionalProperties": false, "required": ["kernel", "solver_ref", "l0_mode", "refit_contract_ref"], diff --git a/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml b/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml index e16aea188b..f659af868a 100644 --- a/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml +++ b/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml @@ -195,7 +195,7 @@ solver: l1_lambda: 0.0 l2_anchor_weights: null refit_contracts: - default_sparse: + l0_refit: support: selection_weight_above_prune_relative_atol subset_source: selection_stage_frame starting_weights: selection_stage_calibrated_weights @@ -222,12 +222,12 @@ refit_contracts: source: run_request default: null release_modes: - default_sparse_l0_refit: + l0_refit: kernel: kernel:calibrate_l0_refit solver_ref: solver selection_contract_ref: solver.l0_contract - refit_contract_ref: refit_contracts.default_sparse - dense_diagnostic: + refit_contract_ref: refit_contracts.l0_refit + dense_no_l0: kernel: kernel:calibrate solver_ref: solver l0_mode: none diff --git a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py index 3c133614d4..c8f7334eed 100644 --- a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py @@ -1640,16 +1640,20 @@ def us_ssi_take_up_delivery_gate( per-target knob (microcosm#492). The under-18 band stays fenced pending microcosm#453/#509 and is reported in the details, never enforced. - ``enforcement_fences`` fences normally-enforced bands for a specific - ARM with a documented adjudication (the under-18 pattern extended): - on the dense full-pool arm, microcosm#508 delivered-weight recomputes - have not landed the adult pair in band on either observed frame — + ``enforcement_fences`` fences normally-enforced bands for one builder + arm with a documented adjudication (the under-18 pattern extended). + The US builder passes them on its ``--dense-default-dataset`` arm + only: on that arm's two observed full-pool frames, microcosm#508 + delivered-weight recomputes have not landed the adult pair in band — P2's clean one-retry record, and P3's delivered-basis chain that ``ssi_take_up_prior_basis_from_artifact`` now refuses outright (microcosm#566/#567) — so its adult bands ship in the scorecard as - known boundaries rather than enforced contracts. The fence text - rides each fenced row; the sparse certified default passes no - fences and keeps hard enforcement. + known boundaries rather than enforced contracts. The builder keys + the fences on the flag alone, so a dense run whose selection source + first cuts the pool is fenced too. The fence text rides each fenced + row. The L0+refit arm (neither ``--exact-k`` nor + ``--dense-default-dataset``) and the ``--exact-k`` arm pass no fences + and keep hard enforcement. """ expected_targets = _normalize_targets(targets) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py index 79aec84704..a50c62825b 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py @@ -31,7 +31,7 @@ ROOT = _TEST_PATHS.repository US_ROOT = ROOT / "packages/microcosm-build/src/microcosm/build/us" CANONICAL_LEGACY_PROJECTION_SHA256 = ( - "b289d8a5dd4d82ba311f71bc9909e2f2c4829566e7ff6226e517ef5f74eceeba" + "025ed1037145ceb73230352560f045e58f610995bc6b21bcf8b3f835b727fb33" ) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py index 6e9832a3b2..56e430cbe6 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py @@ -30,8 +30,10 @@ def test_semantic_hash_has_golden_vector_and_surface_separation(tmp_path) -> Non # attested bytes. # The fit input checks from the microimpute bug-parity audit move the fit # kernels' bytes too. + # microcosm#1641's docstring and comment wording in solve and ssi_take_up + # moves it again. assert first.spec_sha256 == ( - "d4fc68aa1ceee27700b15e89f668b3368d361ce9f9adbc5e506aed00ee9b27bc" + "cb9742d5089eddb8783ee1cb890206b33a35efe5ff572656dbd58a1b95ea1e28" ) second_root = _rich_minimal(tmp_path / "xy", note="second", store="local:b") diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py b/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py index feda21a8dd..29f437d2b5 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py @@ -379,8 +379,9 @@ def test_the_run_refuses_skipped_checks_left_files_before_any_side_effect() -> N def test_dense_ssi_fences_cover_the_enforced_bands_and_cite_the_adjudication() -> None: """microcosm#566/#567: the dense-arm fence table must cover exactly the normally-enforced bands, and every fence must carry the recompute - adjudication, its re-adjudication trigger, and the sparse contrast — - a fence without its documented reason is forbidden.""" + adjudication, its re-adjudication trigger, and the arms that keep hard + enforcement, each named by its builder flag — a fence without its + documented reason is forbidden.""" from microcosm.build.us_runtime.ssi_take_up import ( US_SSI_TAKE_UP_ENFORCED_BAND_KEYS, ) @@ -392,7 +393,12 @@ def test_dense_ssi_fences_cover_the_enforced_bands_and_cite_the_adjudication() - assert "microcosm#566/#567" in text, band assert "microcosm#508" in text, band assert "Re-adjudicates" in text, band - assert "sparse certified" in text, band + assert "--dense-default-dataset arm" in text, band + assert "The L0+refit and --exact-k arms pass no fences" in text, band + # The text names arms by builder flag, not by the retired + # "dense diagnostic" and "sparse certified default" labels. + assert "diagnostic arm" not in text, band + assert "sparse certified" not in text, band # The adjudication must claim only what the artifacts support: # recomputes failed to land the pair in band — NOT a proven # periodic map (sol round-1 blocker 3). The refusal scans the diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py b/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py index dc9531076e..e3cb214331 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py @@ -935,8 +935,8 @@ def test_delivery_gate_fences_override_enforcement_with_their_adjudication() -> **{"18_64": 80.0, "65_plus": 90.0}, # both far outside the envelope ) fences = { - "18_64": "Fenced for the dense diagnostic arm (microcosm#566/#567).", - "65_plus": "Fenced for the dense diagnostic arm (microcosm#566/#567).", + "18_64": "Fenced for the --dense-default-dataset arm (microcosm#566/#567).", + "65_plus": "Fenced for the --dense-default-dataset arm (microcosm#566/#567).", } gate = us_ssi_take_up_delivery_gate( delivered, targets=_TARGETS, enforcement_fences=fences @@ -959,7 +959,7 @@ def test_delivery_gate_fences_override_enforcement_with_their_adjudication() -> def test_delivery_gate_partial_fence_keeps_the_other_band_enforced() -> None: _, _, _, diagnostics = _assigned() - fences = {"65_plus": "Fenced for the dense diagnostic arm (microcosm#566)."} + fences = {"65_plus": "Fenced for the --dense-default-dataset arm (microcosm#566)."} # The un-fenced band still hard-fails on a miss... missed = _delivered(diagnostics, **{"18_64": 80.0, "65_plus": 90.0}) gate = us_ssi_take_up_delivery_gate( diff --git a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py index 123733f49e..a22f1927d5 100644 --- a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py +++ b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py @@ -361,7 +361,9 @@ def capture_equality(expected: object, actual: object) -> None: # microcosm#922's county facts pin, two declared legacy resources, # moves it. # microcosm#1543's fit input checks in microcosm.fit.qrf move it again. - "spec_sha256": "4e2b6c19661079b1c75ab694d043c76d22f52465e7b01d37dc499a3611ca6d8c", + # microcosm#1641 moves it again: docstring and comment wording in + # solve and ssi_take_up, and the calibration contract's renamed modes. + "spec_sha256": "372858d059a129d7b3bcbd7ac2dbdc314742345bd35aaff8d53943e737c98f84", }, } diff --git a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py index 31f7c56e69..e55a42a470 100644 --- a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py +++ b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py @@ -51,7 +51,8 @@ ``mass="conserve"``; ``max_weight_ratio`` remains the hard safety bound. This penalty is only implemented by ``method="adam"``. In the two-stage :func:`calibrate_l0_refit` path it applies to both stages unless - ``refit_l2_lambda`` overrides the refit stage — the stage whose weights ship. + ``refit_l2_lambda`` overrides the refit stage, whose weights that function + returns. - ``l2_basis`` selects the penalty's functional form. ``"record"`` (default) is the record-weighted ``mean(r ** 2)`` above, ``r = w / anchor``. Under ``mass="conserve"`` its target-free minimizer is ``w ∝ anchor ** 2``, and @@ -450,8 +451,8 @@ class L0RefitResult: hard-concrete L0 gates. The :attr:`refit` stage keeps either the legacy weight-threshold support or a caller-supplied exact-k support, removes the gates and L0 penalty, and runs ordinary calibration on the resulting frame. - Convenience properties delegate to :attr:`refit`, because the refit frame - and weights are the production artifact. + Convenience properties delegate to :attr:`refit`, because the refit stage + produces the calibrated frame and weights. """ selection: CalibrationResult @@ -548,7 +549,7 @@ def fraction_within_10pct(self) -> float: @property def effective_sample_size(self) -> float: - """Kish ESS of the post-L0 refit weights (the shipped vector).""" + """Kish ESS of the post-L0 refit weights (the returned vector).""" return self.refit.effective_sample_size @property @@ -568,7 +569,7 @@ def chi_square_distance(self) -> float: @property def options(self) -> Mapping[str, object]: - """Combined production options and selection provenance.""" + """Combined refit options and selection provenance.""" return { **dict(self.refit.options), "post_l0_refit": True, @@ -1640,7 +1641,7 @@ def _optimize_proximal( final = (torch.clamp(ratio, min=0.0) * w0_t).detach().numpy().astype(np.float64) # Make sub-threshold residuals exact zeros so the reported n_nonzero and the - # shipped dataset agree on which records survived. + # returned weights agree on which records survived. final[final <= prune_atol] = 0.0 if max_weight_ratio is not None: final = np.minimum(final, max_weight_ratio * w0) @@ -3414,21 +3415,21 @@ def refit_l0_selection( explicitly selects the existing thresholded path and leaves its starting weights unchanged. ``l2_lambda`` applies the soft concentration penalty to the refit itself — - the stage that produces the shipped weights; the default ``0.0`` keeps the - refit unpenalized. + the stage whose weights this function returns; the default ``0.0`` keeps + the refit unpenalized. On the legacy path, the refit's starting weights are the *selection stage's calibrated weights*, which are already concentrated — so with ``l2_anchor="initial"`` a strong penalty pulls toward their square (more concentration, lower ESS). Pass ``l2_anchor="uniform"`` when the penalty's - job is to spread the shipped weights, or ``l2_anchor="design"`` to anchor at + job is to spread the returned weights, or ``l2_anchor="design"`` to anchor at the *pre-selection* initial weights of the surviving records — "stay near the survey design", the natural choice when the candidate frame carries real design weights rather than a uniform reset. On the explicit exact-k path, the starting weights and design anchor instead use the original-frame design weights after the same normalized Horvitz--Thompson projection. ``l2_basis`` selects the refit penalty's form (see :func:`calibrate`); - ``"chi_square"`` with the ``"design"`` anchor pulls the shipped weights + ``"chi_square"`` with the ``"design"`` anchor pulls the returned weights toward the survivors' design weights themselves rather than their square. ``mass_parametrization`` applies to the refit, which has no gates (see :func:`calibrate`). @@ -3617,11 +3618,12 @@ def calibrate_l0_refit( ) -> L0RefitResult: """Select a sparse support with L0 gates, then refit ordinary calibration. - This is the production "generate big, then prune" path when the final - artifact should be a sparse calibrated frame rather than the raw gated L0 - weights. The first stage is exactly :func:`calibrate` with L0 pruning - enabled by ``target_records`` or a positive fixed ``l0_lambda``. The second - stage delegates to :func:`refit_l0_selection`. + Use it for a "generate big, then prune" solve whose result should be a + sparse calibrated frame rather than the raw gated L0 weights. The first + stage is exactly :func:`calibrate` with L0 pruning enabled by + ``target_records`` or a positive fixed ``l0_lambda``. The second stage + delegates to :func:`refit_l0_selection`, and the result's frame and + weights are the refit stage's. ``l2_lambda`` applies the soft concentration penalty to both stages. ``refit_l2_lambda`` overrides the refit stage only (the ``refit_epochs`` / @@ -3630,7 +3632,7 @@ def calibrate_l0_refit( override) penalties are both expressible. ``l2_anchor`` / ``refit_l2_anchor`` follow the same inherit-or-override pattern; note the refit starts from the selection stage's concentrated weights, so a - penalized refit whose goal is spreading the shipped weights should anchor + penalized refit whose goal is spreading the returned weights should anchor ``"uniform"`` (see :func:`refit_l0_selection`). ``l2_basis`` / ``refit_l2_basis`` follow the same pattern for the penalty's form. ``refit_mass_parametrization`` applies to the refit stage only: the diff --git a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py index abc542b09d..7b52e4ccd8 100644 --- a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py +++ b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py @@ -917,7 +917,7 @@ def test_l0_refit_returns_refit_on_selected_support(feasible_frame) -> None: assert result.frame.n("household") == result.selection.n_nonzero assert len(result.selected_entity_ids) == result.selection.n_nonzero assert result.n_nonzero == result.selection.n_nonzero - # The production weights are the ordinary no-L0 refit on the L0-selected + # The returned weights are the ordinary no-L0 refit on the L0-selected # support, not the raw gated selection weights. assert result.final_loss <= result.selection.final_loss + 0.02 @@ -1476,10 +1476,10 @@ def test_calibration_result_reports_weight_concentration(feasible_frame) -> None def test_refit_l0_selection_threads_l2_lambda_to_refit() -> None: - """The refit stage — the weights that ship — receives its own L2 penalty. + """The refit stage, which sets the returned weights, receives its own L2 penalty. The refit previously hardcoded ``l2_lambda=0.0``, so a concentration - penalty could shape support selection but never the published weights. + penalty could shape support selection but never the returned weights. The regression contract is *threading*, pinned via the recorded solver options: exactly what the hardcoded zero would have violated. @@ -1750,9 +1750,9 @@ def test_refit_design_anchor_uses_pre_selection_weights() -> None: Provenance must show the refit ran with an explicit anchor labelled 'design' while the selection stage recorded the equivalent 'initial' - anchor, so a design-weighted production run can regularize the shipped - weights toward the survey design rather than toward the selection - stage's concentrated output. + anchor, so a design-weighted run can regularize the returned weights + toward the survey design rather than toward the selection stage's + concentrated output. """ frame, targets, _ = _l2_concentration_fixture() result = calibrate_l0_refit( @@ -1775,7 +1775,7 @@ def test_refit_design_anchor_uses_pre_selection_weights() -> None: def test_l0_refit_result_delegates_summary_metrics_to_refit() -> None: - """The two-stage result reports the refit's (shipped) summary metrics.""" + """The two-stage result reports the refit's summary metrics.""" frame, targets, _ = _l2_concentration_fixture() result = calibrate_l0_refit( frame, diff --git a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json index a33ecd8cca..da0abddedc 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json +++ b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json @@ -1 +1 @@ -{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"07e4330f69e7d909027ae5ec1e474b45fb38d4461ac4ad349970e03be9cbfeb6","kernel":"calibrate.adam@1","node":"calibrate","node_key":"2972c813b95a3b6d117a3795692804e89e388578d6e142a18cea8d0624999896","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"2972c813b95a3b6d117a3795692804e89e388578d6e142a18cea8d0624999896"}},"seed":0} +{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"3df328c2d5f449de45a543be8b5f4caf0cf2ff417542b0dc1251c7e4bfd33e64","kernel":"calibrate.adam@1","node":"calibrate","node_key":"98df2301f04fc79ffe90a07306a51d4fa8ad0cda6777d480ae6c172adef20dfe","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"98df2301f04fc79ffe90a07306a51d4fa8ad0cda6777d480ae6c172adef20dfe"}},"seed":0} diff --git a/tools/build_us_fiscal_refresh_release.py b/tools/build_us_fiscal_refresh_release.py index 68f368a9bb..8e05283457 100644 --- a/tools/build_us_fiscal_refresh_release.py +++ b/tools/build_us_fiscal_refresh_release.py @@ -543,9 +543,9 @@ # The L0+refit and --exact-k arms pass no fences and keep hard enforcement. # RE-ADJUDICATES when microcosm#566's damped fixed-point protocol lands. _US_DENSE_SSI_FENCE_ADJUDICATION = ( - "Fenced for the dense diagnostic arm (microcosm#566/#567): " + "Fenced for the --dense-default-dataset arm (microcosm#566/#567): " "microcosm#508 delivered-weight recomputes have not landed the adult " - "band pair in the envelope on either observed frame (P2, current-" + "band pair in the envelope on either observed full-pool frame (P2, current-" "frame attempt then its one permitted recompute: +5.8%/+24.8% -> " "+8.2%/+20.0%; P3, attempts already anchored on delivered bases: " "65+ +34.6%, then +8.3%/+19.8% after recomputing again — a chain " @@ -553,7 +553,8 @@ "deleted microcosm#463-class loop. This band's miss ships in the " "scorecard as a known boundary — never as an enforced contract. " "Re-adjudicates when the microcosm#566 damped fixed-point protocol " - "lands. The sparse certified default keeps hard enforcement." + "lands. The L0+refit and --exact-k arms pass no fences and keep hard " + "enforcement." ) US_DENSE_SSI_TAKE_UP_ENFORCEMENT_FENCES: dict[str, str] = { "18_64": _US_DENSE_SSI_FENCE_ADJUDICATION, diff --git a/tools/spec_engine_coverage.py b/tools/spec_engine_coverage.py index 8900285d0e..4a7ea7b5e8 100644 --- a/tools/spec_engine_coverage.py +++ b/tools/spec_engine_coverage.py @@ -41,7 +41,7 @@ REPORT_SCHEMA_VERSION = 3 EXPECTED_POINTER_INVENTORY_SHA256 = ( - "7765ab26649d67e3ae69a8b10af462fc7e7921ed88f681503aa766640f6cf821" + "65c75e48867b39bc443891c2bada2fcc6eed80b2c1fa1bf5ced14ae862bad47f" ) DEFAULT_REPORT_PATH = ( Path(__file__).resolve().parents[1] diff --git a/tools/us_bundle_generation/contracts.py b/tools/us_bundle_generation/contracts.py index bfaed87e3d..4cf286ecd3 100644 --- a/tools/us_bundle_generation/contracts.py +++ b/tools/us_bundle_generation/contracts.py @@ -1466,7 +1466,7 @@ def build_calibration_contract() -> dict[str, object]: }, }, "refit_contracts": { - "default_sparse": { + "l0_refit": { "support": "selection_weight_above_prune_relative_atol", "subset_source": "selection_stage_frame", "starting_weights": "selection_stage_calibrated_weights", @@ -1493,14 +1493,24 @@ def build_calibration_contract() -> dict[str, object]: "seed": {"source": "run_request", "default": None}, }, }, + # One mode per builder arm. The first two keys are the + # dataset.default.method values the builder writes for its arms: + # l0_refit when the caller sets neither --exact-k nor + # --dense-default-dataset, and dense_no_l0 for + # --dense-default-dataset. The third is the --exact-k arm. Every + # mode shares the solver block. Its kernel and l0_contract.default_mode + # are set by hand to the l0_refit arm's, and + # _fiscal_release_cli_defaults reads its other defaults from a builder + # parse with neither flag set. solver.l0.mode keeps the approved binding + # literal exact_k_projection, which neither of those sets. "release_modes": { - "default_sparse_l0_refit": { + "l0_refit": { "kernel": _kernel_ref(solve.calibrate_l0_refit), "solver_ref": "solver", "selection_contract_ref": "solver.l0_contract", - "refit_contract_ref": "refit_contracts.default_sparse", + "refit_contract_ref": "refit_contracts.l0_refit", }, - "dense_diagnostic": { + "dense_no_l0": { "kernel": _kernel_ref(solve.calibrate), "solver_ref": "solver", "l0_mode": "none",