FE-1429: Run trial replicates through the shared experiment runtime - #9358
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
5b1a2c9 to
840d731
Compare
840d731 to
4ea66ab
Compare
4ea66ab to
8bae884
Compare
PR SummaryMedium Risk Overview Core pulls the worker loop into CLI adds Replicates still use pinned seeds and common random numbers; sharding only affects wall time. Invalid objectives are validated after all replicates finish (no fail-fast on the second seed). Reviewed by Cursor Bugbot for commit f123fc0. Bugbot is set up for automated code reviews on this repo. Configure here. |
rolldown-plugin-dts writes experiments.d.ts and webgpu.d.ts. The .d.d.ts names came from the previous toolchain's output and resolve to nothing for a published consumer.
The worker body moves to attachMonteCarloWorker(runtime), so Web Workers, Node worker_threads, and an in-process loopback all run the same protocol. Experiments accept explicit per-run configs (sliced per shard), and each run's final metric values come back as runResults — the per-seed objectives optimization replicates need.
Each trial becomes one Monte Carlo experiment: explicit run seeds keep replicate 0 on the base seed, worker_threads carry the shards under Node, and the in-process worker covers source runs and tests. Replicates no longer fail fast — they run in parallel and validate together.
The experiment stops sniffing navigator and defaults to one shard. The editor's provider passes getDefaultMonteCarloShardCount(); the CLI gains --threads, defaulting to one per core minus one, where --threads 1 spawns no workers and simulates on the calling thread.
aca1673 to
f123fc0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f123fc0. Configure here.
The merge-base changed after approval.

Summary
Before this PR, CLI ran a trial's seeded replicates sequentially, as FE-1408 left it. Parallelism waited until the CLI and the editor could share one worker story.
A trial now runs as one Monte Carlo experiment, sharded across
worker_threads, through the same runtime the editor uses. Replicate 0 keeps the base seed verbatim. Two identical trials return identical replicates, so the common-random-numbers contract holds end to end.Links
Changes
CLI
optimization.evaluatein@hashintel/petrinaut-clibuilds one experiment per trial--threads <n>flagsimulation-worker.jsbesidecli.jsPetrinautCompiledModelexposes its sanitizedsdcpnandhirArtifactsCore
attachMonteCarloWorker(runtime)in@hashintel/petrinaut-corerunsrunResultsstoreTest coverage
experiment.test.ts, four new tests:optimization.test.ts,simulation-threads.test.ts,protocol.test.ts:How to test
turbo run build --filter '@hashintel/petrinaut-cli'execution.seedsPerTrial: 4tonode dist/cli.js serve --optimization-stdin --stdioexecution.seed