Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/qrf-predict-workers-joblib-cpu-count.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Size the QRF draw's thread pool from the CPUs the process may use, and stop treating QRF thread counts as something a pool load or a resume must match. With `POPULACE_FIT_PREDICT_WORKERS` unset, the pool now has `joblib.cpu_count()` threads (`microcosm.fit.qrf.default_predict_workers`), the smallest of the machine's CPU count, the process's CPU affinity mask, a Linux cgroup CPU quota and `LOKY_MAX_CPU_COUNT`, and 1 when joblib has turned multiprocessing off, instead of `os.cpu_count()`, which counts only the machine's CPUs: a container whose quota appears in the cgroup files joblib reads (`cpu.max` or `cpu.cfs_quota_us`) no longer starts one thread per host CPU. The variable still overrides the default. Fit jobs keep `n_jobs=-1`, which joblib already resolves to `joblib.cpu_count()` threads, so chain states and run configurations record what they did before. A `LOKY_MAX_CPU_COUNT` that is not an integer is refused by joblib; the draw's pool sizing and the worker binding report it by name. Draws are unchanged: new tests require byte-identical draws for one and four prediction workers and for one and four fit jobs, for a single-forest target, a target with zero, positive and negative values, and a target-at-a-time chain.

The primary-QRF worker binding (`worker_identity.py`, now schema 2) records `POPULACE_FIT_N_JOBS` and `POPULACE_FIT_PREDICT_WORKERS` in a new `audit_thread_controls` field next to the interpreter paths in `audit_aliases`, and no longer in its semantic identity. Loading a pool for release or scoring, resuming the primary-QRF checkpoint, the pool's checkpoint identity and the spec engine's worker resolution compare only the semantic identity, so a difference in either count, whether it comes from the machine or from the two variables, no longer stops a pool from loading. The rest of the semantic identity, such as the interpreter and the installed distributions, must still match. Building the binding still refuses a malformed count. An unset prediction-worker count is recorded as `resolution: "joblib_cpu_count_fallback"`; `"os_cpu_count_fallback"` still validates. Schema-1 bindings still validate, and a pool that holds one is refused because its worker identity changed. The semantic identity is now cached per lock only. The spec template for the worker binding (`imputation.yaml` and `imputation.schema.json`) names schema 2 and the new field. The frozen schema-4 shape that the scoring-only relocation of schema-9 pools compares with their sealed records keeps the counts where that code recorded them, an unset count as the host's `os.cpu_count()`, so that comparison is unchanged and still includes the counts. The unused older binding in `stacked_spine.py` records the joblib default under the new label.

A resume no longer compares `POPULACE_FIT_N_JOBS`. `QRF.fit_draw_next` accepts a chain state that recorded another count, and `QRFChainState` equality ignores the count; the state still records the value in force when the chain started, so saved states keep their bytes. The ACS transfer target bank checks a saved target's predecessor digest with the count that target saved, so it reuses the target where it used to rebuild it; a first target that is rebuilt starts its chain again and records the live count. The PUF support base builder records both QRF thread variables in its run configuration and no longer compares them on resume (`StageRuntime`'s new `resume_ignored_run_config_paths`); the BLAS and OpenMP thread counts and `PYTHONHASHSEED` stay compared. A pool build interrupted before this change cannot resume after it, because its recorded worker identity hashes the edited `qrf.py`, `worker_identity.py` and `stacked_spine.py`; a base run cannot either, because its run configuration records a digest of the builder and the packaged source. A compatibility attestation written for the scoring-only relocation of a sealed pool before this change no longer validates, so that relocation needs a new one.
20 changes: 10 additions & 10 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1324,12 +1324,12 @@
],
"expected": {
"nodes": 38,
"sha256": "1b208fff4f6d878c522147fee617177544bda8963c940f98a4bfc37507cb955f"
"sha256": "ea67473e331b8849b3b48ecac89509661d904f2356ff2161a04715e569c79e91"
},
"failures": [],
"observed": {
"nodes": 38,
"sha256": "1b208fff4f6d878c522147fee617177544bda8963c940f98a4bfc37507cb955f"
"sha256": "ea67473e331b8849b3b48ecac89509661d904f2356ff2161a04715e569c79e91"
},
"status": "covered"
},
Expand Down Expand Up @@ -1642,13 +1642,13 @@
"compiler_ir.node_slices"
],
"expected": {
"map_sha256": "9fa0124345af93d0ce251e2fa09260aca5ff3c2fedc3921cfe21e0a64c71111f",
"protocol_sha256": "cbbb249d1a9b99627759f5433db12122e31f90d6e937742f6bf93898bd81333a"
"map_sha256": "530bdaf982c7ad2440db7b4b02f8de5843dac083c6e36c28385ce5d8bbb23e35",
"protocol_sha256": "f5cc748f1b9fbeaea54c18d9e2c1e6e74f2679c9cbf6cf7a09e7b548d2788d66"
},
"failures": [],
"observed": {
"map_sha256": "9fa0124345af93d0ce251e2fa09260aca5ff3c2fedc3921cfe21e0a64c71111f",
"protocol_sha256": "cbbb249d1a9b99627759f5433db12122e31f90d6e937742f6bf93898bd81333a"
"map_sha256": "530bdaf982c7ad2440db7b4b02f8de5843dac083c6e36c28385ce5d8bbb23e35",
"protocol_sha256": "f5cc748f1b9fbeaea54c18d9e2c1e6e74f2679c9cbf6cf7a09e7b548d2788d66"
},
"status": "covered"
},
Expand All @@ -1663,7 +1663,7 @@
"compiler_ir.seed_stream_map"
],
"expected": {
"implementation_sha256": "cbbb249d1a9b99627759f5433db12122e31f90d6e937742f6bf93898bd81333a",
"implementation_sha256": "f5cc748f1b9fbeaea54c18d9e2c1e6e74f2679c9cbf6cf7a09e7b548d2788d66",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand All @@ -1684,7 +1684,7 @@
},
"failures": [],
"observed": {
"implementation_sha256": "cbbb249d1a9b99627759f5433db12122e31f90d6e937742f6bf93898bd81333a",
"implementation_sha256": "f5cc748f1b9fbeaea54c18d9e2c1e6e74f2679c9cbf6cf7a09e7b548d2788d66",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "4f0c8f6406ec0e184d431d1fb772d7a8a7fc29982124db01d6ac04b4643f47cf"
"spec_sha256": "067676ed540f9a6d7981ce5df546e81384cf0409446b04b4cbc637db5a43ea22"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "4f0c8f6406ec0e184d431d1fb772d7a8a7fc29982124db01d6ac04b4643f47cf"
"spec_sha256": "067676ed540f9a6d7981ce5df546e81384cf0409446b04b4cbc637db5a43ea22"
},
"status": "pass"
}
16 changes: 10 additions & 6 deletions docs/us-modal-stage-runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -1161,11 +1161,14 @@ without checkpoints would lose the whole run. With them, `--stage all`
resumes from the last completed outer stage (`_run_staged_all`). The tool
locks its whole run config in `stage_run_context.json` (input paths and
digests, settings, its code identity and the thread variables it sees) and
refuses a resume whose config differs. Every path in it is the same in
refuses a resume whose config differs. Code newer than the pinned
`4b57d15a2` that contains the QRF thread-count change records
`POPULACE_FIT_N_JOBS` and `POPULACE_FIT_PREDICT_WORKERS` without comparing
them. Every path in the config is the same in
every attempt of the run, and so are the image, the plan's environment and
the class, so a relaunch of the same plan should resume. If Modal gave the
new container different thread variables, the tool would refuse, and the
run would need a new `run_id`. The cost has three parts:
new container different compared thread variables, the tool would refuse,
and the run would need a new `run_id`. The cost has three parts:

- one copy of about 46 GB when the tool stops, hashed as it is copied;
- the same pulled back by a resuming attempt, hashed and verified in that
Expand Down Expand Up @@ -1544,9 +1547,10 @@ archives.
- *CPU.* `full-staging-a3` in
`experiments/us-acs-local-hours-rebuild-20260922/run-resources-and-staging-excerpt.json`
measured 103,104.6 CPU-s over 7,218.1 s of wall, 14.3 cores on average.
The QRF forest uses `n_jobs=-1` when `POPULACE_FIT_N_JOBS` is unset, and
prediction sizes its pool from `os.cpu_count()` when
`POPULACE_FIT_PREDICT_WORKERS` is unset (`microcosm.fit.qrf`). Sixteen
The QRF forest uses `n_jobs=-1` when `POPULACE_FIT_N_JOBS` is unset. With
`POPULACE_FIT_PREDICT_WORKERS` unset, prediction sizes its pool from
`os.cpu_count()` at this plan's pinned commit `74f5e6123`, and from
`joblib.cpu_count()` in later code (`microcosm.fit.qrf`). Sixteen
cores accommodate the observed average with 1.7 cores of headroom; the
limit throttles use above sixteen. Neither the average nor the request
establishes the container's visible CPU count. The receipt records
Expand Down
32 changes: 19 additions & 13 deletions docs/us-multispine-operator-ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ by_origin_battery
contract 4, transition authority 2, and resource-semantics receipt 2. The
primary execution config is version 6 (it binds the recipient-share bound,
#1259), its portable worker identity is
version 1, and its checkpoint input sidecar is version 2. The companion pool
version 2, and its checkpoint input sidecar is version 2. The companion pool
manifest uses schema version 10.
Older outer authority or materializer payloads are stale; primary-QRF
version 6 remains current.
Expand Down Expand Up @@ -546,29 +546,30 @@ primary-QRF schema, manifest name, and exact target order; the physical
checkpoint directory basename must independently equal that bound identity.
The execution-config receipt resolves and hashes the actual predictor/output
sequences, all 65 optional allocation/passthrough reads, clone fraction/seed,
QRF seed/estimator count, worker module/interpreter/argv and reviewed fit
environment, strict-recipient and null-preserving doctrines, the once-resolved
QRF seed/estimator count, worker module/interpreter/argv and environment
policy, strict-recipient and null-preserving doctrines, the once-resolved
aggregate-disaggregation spec and SOI AGI-band bytes/semantics, every tail
selection/topcode/five-times/concentration control, and enabled audit sinks.
The same three receipts form an exact SHA-bound sidecar beside the primary-QRF
manifest; resume refuses a missing or different sidecar, including a
manifest; resume refuses a missing sidecar or one that differs in anything but
the worker's `audit_aliases` and `audit_thread_controls`, including a
same-row-count donor with changed bytes. This closes stale-bank reuse under a
newly claimed outer route.

#### Portable primary-QRF `worker_execution` identity

Worker identity schema v1 separates semantic authentication from launcher
aliases. `semantic_identity` binds the interpreter-launcher bytes, the exact
Worker identity schema v2 separates semantic authentication from launcher
aliases and thread counts. `semantic_identity` binds the interpreter-launcher bytes, the exact
loaded Python runtime library (or the executable for a static build), and a
digest of the source and extension bytes for stdlib modules observed during or
present after a clean worker import. It also binds implementation, version and
ABI, cache tag,
canonical `pyvenv.cfg` fields, worker-module source, the statically resolved
Python closure plus every Microcosm namespace file opened by that clean import,
the exact approved `uv.lock`, installed-distribution/RECORD and combined
transitive environment/code digests, arguments after `argv[0]` with `argv[0]`
replaced by `{python_interpreter}`, and configured/resolved fit-job and
prediction-worker controls. `TORCH_DEVICE_BACKEND_AUTOLOAD=0` is a forced,
transitive environment/code digests, and arguments after `argv[0]` with
`argv[0]` replaced by `{python_interpreter}`.
`TORCH_DEVICE_BACKEND_AUTOLOAD=0` is a forced,
bound worker-bootstrap override applied before the QRF runtime can import
Torch. Before the clean import, identity construction enumerates
all installed `torch.backends` entry-point declarations, refuses duplicate
Expand All @@ -577,8 +578,13 @@ binds declarations belonging to selected distributions. Authentication
compares that payload and its
`semantic_identity_sha256`, so byte-identical interpreters reached through
different worktrees remain the same worker. `audit_aliases` records absolute
`sys_executable`, `sys_prefix`, and raw `argv_template_0`, but those aliases are
never compared for authentication.
`sys_executable`, `sys_prefix`, and raw `argv_template_0`, and
`audit_thread_controls` records the configured and resolved fit-job and
prediction-worker counts. Neither field is compared for authentication: the
counts change no imputed value, and an unset prediction-worker count follows
the machine. Schema v1 records, which kept the counts in `semantic_identity`,
still validate, and a pool holding one is refused because its worker identity
changed.

A schema-9 gate-failed pool receives no implicit alias exception. Its only
relocation path is the scoring-only loader with an operator-supplied
Expand Down Expand Up @@ -949,7 +955,7 @@ the full payload SHA-256 is
Reversing registry iteration produces those same bytes.

The virtual-resource payload ledger is independently versioned: ACS-universe
config v2, primary execution config v5, source execution config v3, source
config v2, primary execution config v6, source execution config v3, source
finalizer config v2, and transfer model config v3. Donor content,
primary-checkpoint routing, source callback receipts, and transfer-bank routing
remain v1. The outer all-producer resource-semantics receipt is v2 and binds
Expand All @@ -971,7 +977,7 @@ and valid. Neither receipt authorizes an upstream null.
| PUF raw predictor sources | Every filing-status, count, and income component is observed in its declared source universe. Raw WAGP/SEMP authority is present and agrees with mapped leaves; a cross-grain source collision is rejected. A null on any eligible member fails before coercion. | Structure supplies status/count; ACS-native or ASEC-carried earnings supply earnings; early transfer supplies interest, dividends, and gains. | No. ACS under-15 WAGP/SEMP blanks are an exact source-universe state, not transfer starvation; all other source nulls fail. |
| PUF tax-unit features | Every clone-1 recipient has a finite feature vector. Post-aggregation NaN, `+inf`, and `-inf` are counted by named predictor and rejected before fitting; none is coerced or snapped to zero. | Universe-aware person sums plus tax-unit structural inputs. | No. Eligible member values must be complete; the only special case is an all-child unit whose numeric-zero predictor is explicitly owned and counted by the named universe-zero rule. |
| Primary QRF banks and chain | Donor/recipient banks are immutable; target order and RNG prefix are contiguous; all targets complete; live recipient identity, source-universe receipt, and feature digest match before finalization. | The processed full PUF donor and strict recipient checkpoint initialized above. | No. Mutation or missing receipt invalidates the bank; it cannot resume under legacy semantics. |
| Outer pool checkpoint identity and resume | Primary-QRF schema v6, primary execution config v5, portable worker identity v1, tail-manifest schema v2, late-registry schema v17/receipt contract v4, outer stacked materializer v13/authority v12, stacked pool-stage materializer v7, pool manifest schema v10, and the ACS-universe, QBI-mutation, tail-support, late-DAG, and signed virtual-resource-semantics identities must match exactly before any cached stage is discovered. The retiring legacy envelope remains manifest schema v4/materializer v3. | Fresh input pins, live stack receipt, scale controls, code identity, and all semantic contract identities. | No. An older stacked materializer or authority payload is stale; a self-consistent old receipt cannot reopen a checkpoint. Primary-QRF v6 remains current. |
| Outer pool checkpoint identity and resume | Primary-QRF schema v6, primary execution config v6, portable worker identity v2, tail-manifest schema v2, late-registry schema v17/receipt contract v4, outer stacked materializer v13/authority v12, stacked pool-stage materializer v7, pool manifest schema v10, and the ACS-universe, QBI-mutation, tail-support, late-DAG, and signed virtual-resource-semantics identities must match exactly before any cached stage is discovered. The retiring legacy envelope remains manifest schema v4/materializer v4. | Fresh input pins, live stack receipt, scale controls, code identity, and all semantic contract identities. | No. An older stacked materializer or authority payload is stale; a self-consistent old receipt cannot reopen a checkpoint. Primary-QRF v6 remains current. |
| Clone-2 capital-gains tail | Each filing status requires as many eligible recipient households as selected q99.5 donors. Eligibility requires unique single-tax-unit PUF-detail lineage and half-weight capacity for the global maximum assigned donor weight. An adequate status assigns every selected donor once; a thin status skips as a whole with a named, counted `insufficient_support` receipt. | Completed clone-1 QRF output and full PUF tail donors. At 1%, `SINGLE` and `HEAD_OF_HOUSEHOLD` attach, `JOINT` and `SEPARATE` skip, and zero-requirement `SURVIVING_SPOUSE` is `not_applicable`. | No widening or partial attachment is permitted. All 22 AGI bands provide nearest-first fallback only inside a status. Universe-aware PUF recipients remain eligible, including explicitly receipted empty-universe tax units. |
| Late producer DAG | Before any callback, all declared inputs are filled on their required scopes or carry an input-specific counted absence receipt; numeric inputs are finite. The exact derived order, readiness rows, once-only source finalizer, and bounded transfer receipts must validate. | ACS earnings-universe materialization, primary PUF/tail, 16 source producers, and 19 bounded transfer groups execute in six derived waves. | No. The refusing producer names the unfilled input and its declared producing stage. A cycle fails at import with its path. |
| Late transfer completion | Every declared PUF-clone or ASEC source-producer cell is nonnull; all complementary recipients are filled; the allowed count for both unmodeled and residual rows is zero. | Forty-five PUF and 29 source targets, with two overlaps, supply the 72-target late surface. | No. A missing producer or recipient value is terminal at this boundary. |
Expand Down
Loading
Loading