name: compose-sweep-bind
description: fits[].from_sweep — bind the winning slot of a ranked Compose sweep as a named regression fit in the same batch, with its static signature, refusals and predict parity.
type: guide
kind: design
applies_to: compose, predict
covers: [FitSpec, FitFromSweep, ComposedRequest, sweep_axis]
requires: [capability:compose_sweep_bind]
Sweep-bound fits
A fits entry may bind the winner of the batch’s ranked sweep instead of running its own request: the rank-1 sweep slot’s regression, refitted on that slot’s rows, under the entry’s name. Explicit slots and optimize blocks then read it like any fit, so a search and its follow-up are one Compose call.
{
"sweep": {
"axes": [{"name": "cut", "values": [60, 90]}],
"request": {
"cohort": {"filename": "weekly.pulse"},
"filterers": [{"type": "<range filter>", "field": "week", "values": ["0", "{{cut}}"]}],
"regressions": [{"type": "<regression>", "name": "m", "target": "revenue", "predictors": ["tv"], "holdout": "week > 90"}]},
"rank": {"by": "regressions.m.holdout.rmse", "order": "asc"}
},
"fits": [{"name": "best", "from_sweep": {"regression": "m"}}],
"requests": [{"label": "scored", "cohort": {"filename": "weekly.pulse"}, "...": "reads best"}]
}
The binding
from_sweep.regressionis thenameof a regression in the sweep body. An entry setsrequestORfrom_sweep, never both.- The winner is
ranking[0]: ties go to the earliest slot, and a slot that failed on its data is not ranked. - The fit request is the winning slot’s rows (cohort, joins, filters, windows, features, attributes less fitted vector batteries, weight, params) plus that one regression. Groups, crosstab, aggregations, tests, matrices,
returnand the regression’s ownsaveare dropped. - The name joins the one fit namespace (
PULSE_MODEL_NAME_COLLISION); a slot reads it withcoef("best", "<term>")orATTR_REG_PREDICTparams: {fit: "best"}. saveon the entry writes the bound fit as a model file plus its winning axes (sweep_axes): a request loading it reads them throughsweep_axis().
Static signature
The regression’s type, target and predictors (and a model regression’s term catalog) must be identical in every sweep slot: vary a window, a filter or a param, never the model’s shape. Predict reads the signature off the first sweep slot, so coefficient terms, predictor fields and the names optimize reads validate with no data.
Refusals
PULSE_FIT_INVALID with details.fit (entry index), name and reason, before anything runs, identical in predict and runtime:
from_sweep_with_request— bothrequestandfrom_sweep.from_sweep_no_sweep— the batch has nosweep.from_sweep_no_rank— the sweep has norank, so no slot wins.from_sweep_regression_unknown— no body regression has thatname(details.regression,available).from_sweep_signature_varies— type, target or predictors differ in a slot (details.slot, the 0-based sweep index).from_sweep_cycle— a sweep slot reads the fit (a literalcoef("best", …),sweep_axis("best", …)or aparams.fit), but sweep slots run before it exists (details.slot).from_sweep_window_cycle— a sweep slot’s window reads the fit in a scalar param (adecayofsweep_axis("best", …);details.slot,window,param): sweep the param as an axis instead.
Winning axes
sweep_axis("best", "<axis>") reads the winner’s value of an axis in an explicit slot’s formula, filter or scalar window param ("decay": "sweep_axis(\"best\", \"tv\")" — one adstock window instead of a lag fan-out plus a Horner formula) and in optimize — or of a saved bound fit loaded by models (any request, materialize too): a number as a float (a string / bool values entry as is), e.g. the steady-state multiplier (1 - sweep_axis("best", "tv") ^ 8) / (1 - sweep_axis("best", "tv")). Refusals mirror coef(), predict too: unknown fit PULSE_MODEL_UNKNOWN; PULSE_MODEL_TERM_UNKNOWN with details.reason not_sweep_bound (a fit, or loaded file, without from_sweep) or axis_unknown (details.axes, sorted). A failed bound fit (no winner) nulls a formula (PULSE_FIT_UNAVAILABLE) and refuses a filter. The name is reserved: no embedder function may take it.
Run order
A batch with a binding runs sweep-first: authored fits, then the sweep slots (once; their responses are the batch’s), then the rank, then the bound fit refitted on the winner — figures identical to an authored fit of that body — then optimize and the explicit slots. Responses keep index order. The rank reads each sweep slot after its own multiplicity folds; a compose-family p_adjusted is not ready then, so ranking by it is refused.
Failure
A failed sweep slot stops the batch after the sweep slots: no explicit slot runs and the fit is not refitted. Serial Compose and fail-fast ComposeParallel return the slot’s own error (details.request). Without fail-fast the error is SERVICE_INTERNAL with failed_indices, first_error and skipped_indices (the slots that never ran); a later-phase failure has no skipped_indices.
No winner
When no slot is ranked (every value null), the fit binds failed: fits.best carries error PULSE_SWEEP_RANK_PATH (reason: "empty"), a PULSE_SLOT_FAILED warning names it in details.fit, and a slot scoring it reads null (PULSE_FIT_UNAVAILABLE). Strict fails the batch. There is no fallback to rank 2.
Predict
pulse_predict with composed (PredictCompose) lists the entry as {name, type, target, predictors, cohort, from_sweep: {regression}}. Which slot wins is unknown until the slots run.
Comparing
A compare side may be a bound fit. Predict judges it against every slot that could win: refused if all refuse, else valid with unresolved {slots, refused [{slot, label, reason}], varies} when some refuse (e.g. request_mismatch) or resolve another test. The run judges the winner; a refusal fails the comparison alone (PULSE_COMPARISON_INVALID, sweep_slot). Bind both sides from one sweep to compare in every slot.
See
compose-fits (fits, names, failures) · compose-sweeps (the sweep and its rank)