Space-filling sweeps (Sobol, Latin Hypercube)

View as Markdown

When grid is too dense and adaptive search is too goal-directed, quasi-Monte-Carlo (QMC) sweeps draw a fixed budget of variations that cover the parameter space evenly. Use them for characterization — getting a representative scatter you can plot — rather than optimization.

When to use which

SobolLatin Hypercube
Marginal axis coveragevery goodperfect (one bin per axis)
Joint 2D / 3D coverageexcellentrandom-ish
Best atcontinuous dims, plotting paired comparisonsall-discrete dims, small budgets
Sample-count sweet spotpowers of 2any
Resumableyes (extend by adding samples)no

Default to Sobol unless you have all-discrete dims or want exact per-bin balance.

Use case 1 — Perf surface across realistic input shapes

1sweep:
2 type: sobol
3 samples: 64
4 seed: 42
5 dimensions:
6 - {path: concurrency, lo: 1, hi: 256, scale: log, kind: int}
7 - {path: datasets.default.prompts.isl, lo: 128, hi: 32768, scale: log, kind: int}
8 - {path: datasets.default.prompts.osl, lo: 16, hi: 4096, scale: log, kind: int}
9 - {path: rate, lo: 1, hi: 100, scale: log, kind: real}
10multi_run:
11 num_runs: 3

64 samples × 3 trials = 192 cells. A 5⁴ grid would be 625 cells — you save ~70% with comparable scatter coverage.

Use case 2 — A/B build comparison on a fixed workload distribution

Run identical YAML on build A, then build B. The same seed makes Sobol pick identical 32 points both runs, giving you paired comparisons — much better variance than independent sweeps.

1sweep:
2 type: sobol
3 samples: 32
4 seed: 42
5 scramble: true
6 dimensions:
7 - {path: concurrency, lo: 1, hi: 128, scale: log, kind: int}
8 - {path: datasets.default.prompts.isl, lo: 256, hi: 8192, scale: log, kind: int}
9 - {path: datasets.default.prompts.osl, lo: 64, hi: 2048, scale: log, kind: int}

Use case 3 — Latin Hypercube on discrete dims

LHS guarantees each model appears samples / len(choices) times — its niche over Sobol when all dims are discrete.

1sweep:
2 type: latin_hypercube
3 samples: 12
4 seed: 7
5 dimensions:
6 - path: model
7 choices:
8 - meta-llama/Llama-3.1-8B-Instruct
9 - mistralai/Mixtral-8x7B-Instruct-v0.1
10 - Qwen/Qwen2-72B
11 - path: concurrency
12 choices: [1, 4, 16, 64]
13 - path: datasets.default.prompts.isl
14 choices: [256, 1024, 4096]

Reproducibility

Every QMC run writes <artifacts>/sweep_aggregate/sampling_design.json containing the mapped sample values (samples_mapped), the dimension specs, the sampler type/seed, and sampler options (scramble for Sobol, optimization for LHS). Re-runs with the same seed and scipy version produce byte-identical points. Pin scipy in pyproject.toml if you need cross-machine reproducibility over time.

Edge cases

samples=10 for Sobolwarns; Sobol balances best at powers of 2 (8, 16, 32, 64, …)
samples=1rejected; QMC needs ≥ 2
lo >= hirejected; pointless or inverted dim
scale: log and lo <= 0rejected; log requires positive lo
Both lo/hi and choices setrejected; use one

See also