name: compose-sweep-sampling
description: The compose sweep's seeded sampling modes — random and lhs (Latin hypercube) draw `samples` slots from continuous axis ranges instead of listing values. When to sample rather than enumerate, the range and scale rules, how the seed is derived, echoed and replayed, the slot limit, predict and the refusals.
type: guide
kind: design
applies_to: compose, predict
covers: [SweepSpec, SweepRange, integer range, profile_bins, random sweep, Latin hypercube, lhs, samples, rng_seed, sweep_seed, hyperparameter search]
requires: [capability:compose_sweep, capability:compose_sweep_sampling]
Compose sweep sampling
A grid lists every value; its size multiplies per axis (30 values on 4 axes is 810,000 slots). A sampling sweep draws a fixed number of slots from continuous ranges instead, so the cost is samples whatever the axis count. Use it for continuous parameters (an adstock decay, a ridge penalty, a window width) or more than two axes; use a grid for a few discrete values (compose-sweeps).
{
"sweep": {
"mode": "lhs",
"samples": 200,
"axes": [
{"name": "decay", "range": {"min": 0.0, "max": 0.95}},
{"name": "lambda", "range": {"min": 0.001, "max": 10, "scale": "log"}},
{"name": "lag", "range": {"min": 1, "max": 12, "integer": true}}
],
"request": {"...": "the body, reading {\"$var\": \"decay\"} / {{lambda}}"},
"rank": {"by": "regressions.mmm.holdout.rmse"}
}
}
Modes
random: every slot draws every axis independently and uniformly.lhs: each axis is cut intosamplesequal-probability strata and every stratum is drawn exactly once, paired across axes by a seeded permutation. Even coverage of every axis at any sample count; prefer it torandom.samples(>= 1) is required. Every axis carries arange{min, max, scale}instead ofvalues: finite bounds,min < max, draws inside[min, max].scalelinear(default) orlog(log-uniform, for a parameter spanning decades; needsmin > 0).integer: truedraws whole numbers (a lag, a window width): every integer in[min, max]reachable, rendered3not3.0; under lhs each stratum maps to a run of integers.- Draws are numbers in shortest round-trip form; placeholders substitute them as in a grid. Default labels are
sample=<i>_<axis>=<value>(ifrom 0), unique by construction. A ranked slot’s draws come back as numbers in itsrankingentry’saxes(its index inslot): read them there, not off the label. Underrank.profileeach range axis is binned:rank.profile_bins(default 10) equal-width bins over[min, max], equal log-width underlog. One entry per bin a ranked slot fell into, ascending, withlo/hiedges,bestandlabelthe bin’s best slot,valueits draw andnthe ranked slots in the bin; empty bins are absent.
To FIND an optimum rather than map the space, an adaptive mode (de, bo) spends a budget in rounds steered by the ranked values (compose-sweep-adaptive).
Seed
- The draws are a pure function of the spec and the seed, identical across architectures, serial and parallel.
rng_seedabsent or 0: the seed is derived from the wholesweepblock exceptrng_seed—axes,mode,samples,label,request,overlaysandrank(a changedrank.topdraws anew;rank.profile/profile_binsnever do) — never from the data, the clock or the batch’s other slots. The same request draws the same points on any cohort.- The derivation reads the
requestandoverlaysbodies with object keys sorted at every depth and whitespace dropped; numbers and strings keep their text. Bodies differing only in key order or spacing draw identically; any value change (0.1vs0.10included) draws anew. - The effective seed comes back as
sweep_seedon the response (outside the composereturn;--streamwrites one{"sweep_seed": N}line) and assweep.rng_seedin predict. Pin it asrng_seedto replay a run exactly; set another value to draw a fresh set.
Limits and predict
samplescounts towardMaxComposeSlotswith the explicit slots (default in the manifestlimits; raiseLimits.MaxComposeSlots, CLI root--limit max_compose_slots=N, for a large search). Over the limit isPULSE_LIMIT_EXCEEDEDbefore anything runs.- Predict expands exactly:
expanded_count=samples, each axis reportscountand itsrange, and the labels match the run.
Refusals
PULSE_SWEEP_MODE_MISMATCH(details.reason): avaluesaxis under random / lhs, arangeaxis under grid / zip, an axis with both,samplesorrng_seedunder grid / zip.PULSE_SWEEP_RANGE_INVALID: missing range or bound, non-finite bound,min >= max, unknown scale,logwithmin <= 0, anintegerrange holding no integer (integer_range_empty).PULSE_SWEEP_INVALID:profile_binsbelow 1 or withoutprofile: true.PULSE_SWEEP_SAMPLES_INVALID:samplesmissing or below 1.- An item
for_eachnever samples: random / lhs or arangethere isPULSE_FOR_EACH_INVALID.
Decay search pattern
Replace a decay grid with an lhs over [0, 0.95] and rank on the holdout error. The best slots cluster around the true decay; read the top few, not only the first, and check the winner is stable under a second rng_seed. fits[].from_sweep binds the winner as a fit and sweep_axis() reads its draws, so the search, the fit and an optimize are one call (compose-sweep-bind); media mix: mmm-workflow.
See
compose-sweeps (axes, placeholders, labels, rank, limits) · compose-sweep-adaptive (de / bo search) · compose-requests (slots and parallel runs) · regression-model-options (the media-mix decay pattern).