Skip to content

Feature: heterogeneous parameter sweeps (vary instance-type per sweep entry) #372

Closed

Description

@scttfrdmn

Use case: a price-performance benchmark that runs the same workload across different instance types — e.g. GROMACS on c8i / c8a / c8g / g6 / g6e / g7e, each on its own instance, then compares ns/$. This is a natural 'sweep', but each entry needs a different --instance-type.

Today: spawn launch --param-file / --cartesian sweeps and --count job arrays are homogeneous — one --instance-type for the whole sweep, varying only workload params passed to --command. autoscale launch is likewise single-type. So a heterogeneous matrix can't be expressed as one spawn sweep; the caller must fall back to N independent spawn launch calls and orchestrate concurrency/teardown themselves.

Ask: let the param-file/sweep vary instance_type (and ideally ami, spot) per entry, so a single sweep can fan out across instance families. Concretely, a param-file row like:

[
  {"instance_type": "c8g.24xlarge", "IMG": "...:arm-sve"},
  {"instance_type": "c8a.24xlarge", "IMG": "...:amd-avx512"},
  {"instance_type": "g7e.2xlarge",  "IMG": "...:cuda"}
]

where instance_type (if present) overrides the top-level --instance-type for that entry, and the rest are --command template vars as today.

Why it belongs in spawn: spawn already owns the hard parts — concurrent provisioning, per-instance IAM/VPC/SG, budget caps (--budget), Lambda-detached orchestration, lifecycle teardown. A caller reimplementing fan-out in a local thread pool loses all of that and hits contention (I deadlocked a 12-wide ThreadPoolExecutor of spawn connect sessions; the autonomous --command pattern works but I'm hand-rolling the matrix orchestration spawn could own).

Workaround in use: autonomous cells via spawn launch --command <job> per instance type + poll for completion out-of-band (S3). Works, but a native heterogeneous sweep would replace the hand-rolled coordinator entirely.

Context: benchmark harness at https://github.com/scttfrdmn/aws-gromacs (see run_matrix.py).

Activity

  1. scttfrdmn commented on Jul 19, 2026

    @scttfrdmn
    ContributorAuthor

    Looked into this — good news: the per-entry override is already mostly implemented, and it's closer to done than the issue assumes. Here's the assessment.

    What already works

    buildLaunchConfigFromParams (cmd/sweep.go) already reads instance_type, ami, spot, region, az (and ~20 other fields) per param entry and sets them on that entry's LaunchConfig. So a param-file row like:

    [{"instance_type": "c8g.24xlarge", "IMG": "...:arm-sve"},
     {"instance_type": "g7e.2xlarge",  "IMG": "...:cuda"}]

    already produces per-entry instance types today. The parser is map[string]interface{}, so no schema change is needed.

    Two real gaps that make it not actually work heterogeneously

    1. Heterogeneous AMIs are broken (the blocker). launchParameterSweep (cmd/launch_sweep.go:174) detects the AMI once from firstConfig.InstanceType and applies it to every config that lacks one:

      ami, err := awsClient.GetRecommendedAMI(ctx, firstConfig.Region, firstConfig.InstanceType)
      for _, cfg := range launchConfigs { if cfg.AMI == "" { cfg.AMI = ami } }

      GetRecommendedAMI is arch/GPU-aware (DetectArchitecture + DetectGPUInstance), but it's only called for the first entry. So a c8g (arm64) or g7e (GPU) entry in a sweep led by an x86 c8i gets an x86 non-GPU AMI → fails to boot / wrong arch. Fix: call GetRecommendedAMI per-config (keyed by each cfg.InstanceType), only for configs with no explicit ami. Cache by (region, arch, gpu) to avoid redundant SSM lookups.

    2. No top-level --instance-type fallback for entries that omit it. The loop copies baseConfig.Region/Name onto entries that lack them, but not InstanceType (cmd/launch_sweep.go:123-129). So a mixed file where some rows set instance_type and some rely on the CLI default would give the defaulted rows an empty type. Fix: if config.InstanceType == "" { config.InstanceType = baseConfig.InstanceType } alongside the existing Region fallback. Same for TargetOS, which is likewise resolved once from firstConfig.

    Also worth checking

    • launchSweepDetached (the Lambda-orchestrated path) groups by region and may have the same single-AMI assumption — needs the same per-entry AMI fix.
    • OS resolution (resolveTargetOS from firstConfig) — fine as long as a sweep doesn't mix Windows+Linux; worth a guard/doc note rather than support.

    Scope to close this

    Small, contained: (a) per-config AMI detection with a memo cache, (b) InstanceType/TargetOS base fallback, (c) same in the detached path, (d) a heterogeneous example in guides/parameter-sweeps.md (the price-performance-benchmark use case), (e) tests with a mixed x86/arm64/GPU param file asserting each config gets an arch-appropriate AMI. No new flags, no param-file format change.

    Happy to implement if you want it prioritized.

  2. added a commit that references this issue on Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions