FE-1263: Add lazily-computed parameter sweeps to Petrinaut experiments - #9093
Draft
kube wants to merge 2 commits into
Draft
FE-1263: Add lazily-computed parameter sweeps to Petrinaut experiments#9093kube wants to merge 2 commits into
kube wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🌟 What is the purpose of this PR?
Experiments currently force a single fixed value per scenario parameter. This prototypes the "inputs as ranges" direction from the Experiments & metrics RFC (FE-1045 §4.4): scenario parameters can be swept across a range of values, expanding into a grid of parameter combinations — and the grid is computed lazily, driven by what the user looks at. A seed pass gives every combination one run for an instant overview; after that, the combinations matching the currently-viewed parameter selection accumulate runs in progressively larger batches (1 → 10 → 50 → 100 → 500 → 1000 …) up to the requested run count. The results drawer's parameter navigator (toggle + slider per ranged parameter) doubles as the scheduler's focus, so exploring the metric space is instant (histogram merging) while compute concentrates exactly where the user is looking.
🔗 Related links
🔍 What does this change?
N combinations × R runs = T total runssummary — a budget, not an upfront cost. Hard cap of 200 combinations, warning above 50.parameter-grid.ts(new): range expansion, cartesian-grid construction, exact histogram merging (mergeMetricFramesAcrossCells), the run ladder (getNextRunTarget: 1, 10, 50, 100, 500, 1000, then ×5/×2), andpickNextRefinementCell(random among the combinations with the fewest runs, keeping merged distributions an evenly-weighted mixture).ExperimentsProvider: two orchestrations behind one interface. Range-less experiments keep the existing eager single-batch behaviour. Sweeps get a lazy scheduler: seed pass over all combinations (1 run each, always completes), then focus-driven refinement through a concurrency-capped worker pool. Batches accumulate per combination — batch seeds derive from the experiment seed plus the combination's accumulated run count, keeping streams distinct while combinations at equal progress stay paired (common random numbers). Moving the selection interrupts out-of-view batches (partial runs discarded, accumulated runs kept) with a 250 ms debounce so slider drags don't thrash workers; closing the drawer pauses refinement; each combination stops at the requested run count; a failing combination stops the sweep.setExperimentRunFocus). Charts merge accumulated + live in-flight frames of the matching combinations, a feedback line showsN combinations in view · X of Y runs accumulated (adding runs… / at target), and the Summary shows accumulated runs against the total budget. New Idle status (badge + docs) for sweeps whose refinement is paused; Cancel now also applies to idle sweeps and permanently stops accumulation.CreateExperimentInput.scenarioParameterValuestakes fixed-or-range inputs;ExperimentRecordgainsparameterAxesand per-combinationcells(withrunsCompletedandinFlightMetricFrames); the context gainssetExperimentRunFocus. Changeset included (minor).experiments.md) describe the lazy scheduling, the Idle status, and the navigator; story fixtures and a "Parameter sweep" Storybook story included.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
meanaggregation and approximate for the rest.🐾 Next steps
🛡 What tests cover this?
parameter-grid.test.ts: range expansion, cartesian-grid order, histogram-merge semantics, the run ladder (climbing, clamping, saturation, ×5/×2 extension), and least-runs-first refinement picking.provider.test.tsx: all pre-existing single-batch tests unchanged and passing, plus lazy-sweep tests — seed pass through a single-worker pool with per-combinationparameterValues, idle-when-unviewed, focus-driven ladder batches with the expectedrunCount/seedper batch, exact accumulation of merged distributions, saturation stopping, unpinned levelling, in-flight batch interruption on focus change (partials discarded, worker terminated, compute redirected), and permanent stop on cancel.❓ How to test this?
yarn workspace @hashintel/petrinaut devand open theSimulate / SimulateView / Run SIR experimentstory.infected_ratioto Range (0.01–0.05 × 3 values), set Runs to e.g. 1000 and Max time to 30, add a place-tokens metric, and Run.infected_ratioand drag the slider: compute redirects to the pinned value (the previous one stops), and the pinned distribution sharpens the longer you stay. Unpinned, all values are sampled evenly.📹 Demo
The
Simulate / SimulateView / Parameter sweepStorybook story demonstrates the navigator on a completed 5 × 2 sweep with synthetic data; theRun SIR experimentstory exercises the live lazy scheduler.🤖 Generated with Claude Code