Skip to content

feat(sweep): native grid/matrix expansion for param files (#390) - #394

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/390-sweep-grid
Jul 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/390-sweep-grid

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Implements #390 (docs-review follow-up).

What

A sweep --param-file can now declare a grid: block that spawn expands into the cartesian product — one parameter set per combination:

defaults:
  instance_type: g5.xlarge
grid:
  learning_rate: [0.001, 0.01, 0.1]
  batch_size: [32, 64, 128]

→ 9 instances, no more pre-generating the params list with a Python script (which the docs previously had to recommend).

  • grid and an explicit params list can be combined (explicit sets first).
  • Keys expand in sorted order, each key's values in file order → the combinations, and the sweep index assigned to each, are deterministic across runs.
  • --estimate-only reflects the expanded instance count.

Where

Expansion lives in pkg/params (finalize() / expandGrid()), shared by the JSON and YAML parsers — so both the local and detached (Lambda) sweep launch paths pick it up for free, since both consume params.ParseParamFile. No change to buildLaunchConfigFromParams.

Tests

pkg/params/parser_test.go: 3×3 → 9 expansion, deterministic ordering (repeated runs identical), grid+params combined, and the empty-both error. Manually verified spawn launch … --param-file grid.yaml --estimate-only reports the 9-instance cost without launching.

Notes

  • No docs-gen change (grid is a param-file field, not a CLI flag).
  • gofmt/vet/go test ./pkg/params/ clean.

Closes #390

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/params/parser.go 92.30% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…#390)

A sweep --param-file can now declare a `grid:` of named value lists,
which spawn expands into the cartesian product — one parameter set per
combination — instead of requiring the user to pre-generate the full
`params` list with a script.

grid and an explicit params list may be combined (explicit sets first).
Keys expand in sorted order and each key's values in file order, so the
generated combinations — and the sweep index assigned to each — are
deterministic across runs. Expansion happens in pkg/params.finalize(),
shared by the JSON and YAML parsers, so both local and detached sweep
launch paths pick it up. --estimate-only reflects the expanded count.

Closes #390
@scttfrdmn
scttfrdmn force-pushed the feat/390-sweep-grid branch from 4cc9c9e to 4b18831 Compare July 19, 2026 16:19
@scttfrdmn
scttfrdmn merged commit f28e79c into main Jul 19, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/390-sweep-grid branch July 19, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameter sweep: native grid/matrix (cartesian) expansion

1 participant