Skip to content

Sizing: on a price tie, prefer the smallest type that fits (hpc7g cpu=16 → hpc7g.16xlarge) #610

Closed

Description

@scttfrdmn

What happened

A spec asking for 16 vCPU in the hpc7g family was sized to hpc7g.16xlarge (64 vCPU) — 4× the request. Three separate specs asking for 16, 32 and 64 vCPU all resolved to the same hpc7g.16xlarge.

"resources": { "cpu": 16, "memory_gib": 128, "architecture": "arm64", "families": ["hpc7g"] }

→ hpc7g.16xlarge (64 vCPU, 128 GiB)

Why it is not a pricing bug

Every hpc7g size costs exactly the same — verified against the AWS Price List:

type vCPU memory $/hr
hpc7g.4xlarge 16 128 GiB 1.6832
hpc7g.8xlarge 32 128 GiB 1.6832
hpc7g.16xlarge 64 128 GiB 1.6832

On hpc7g you rent the socket, not the cores (AWS markets this as selectable cores per node for per-core licensing). So "cheapest type that fits" has no preference among the three, and the tie appears to resolve toward the largest.

truffle available hpc7g.4xlarge --regions us-east-1 also reports $1.6832/hr, so truffle's data is right — this is purely the tie-break.

Why it matters

Two reasons beyond tidiness:

  1. Blast radius. A request for 16 vCPU silently becoming 64 is 4× the cores. Here the price is identical so the bill is unchanged, but that is a property of hpc7g specifically — the same tie-break on any family with genuinely equal-priced sizes would over-provision at cost.
  2. It makes a measurement unreachable. I was measuring memory bandwidth per core across hpc7g sizes (8 / 4 / 2 GB per core on a constant socket). That experiment needs the three sizes distinguished, and there is no way to express it: cpu/memory cannot discriminate (all three have 128 GiB), and the tie sends everything to the largest.

Suggested

  • Prefer the smallest type that fits when price ties. It matches what the spec asked for and minimises blast radius; nothing is lost when the rate is equal.
  • Allow a spec to pin an exact instance type — e.g. resources.instance_type, the way --ami pins the image. There is already a precedent for overriding auto-selection, and a cross-size sweep needs it by construction. Today the only escape is to stop using the sizing path.

Workaround

Swept thread counts on a single hpc7g.16xlarge socket instead of renting three sizes — which turned out to be the better experiment (one instance, and it isolates cores-on-a-constant-socket cleanly) and cheaper. So this is a rough edge rather than a blocker.

Found while measuring SIMD and memory bandwidth across Graviton generations for the scientific-codes-cookbook; spawn version in use was 0.111.1.

Activity

  1. scttfrdmn commented on Sep 25, 2026

    @scttfrdmn
    ContributorAuthor

    Investigated both asks. One is a real bug with a sneakier cause than either of us assumed; the other already exists and we simply never told you.

    The tie-break isn't biased toward the largest — it's lexicographic

    taskproto.Size ranks by price and then:

    // Tie-break deterministically by type name.
    return matched[i].InstanceType < matched[j].InstanceType

    Plain string comparison. And:

    $ printf '%s\n' hpc7g.4xlarge hpc7g.8xlarge hpc7g.16xlarge | sort
    hpc7g.16xlarge
    hpc7g.4xlarge
    hpc7g.8xlarge
    

    hpc7g.16xlarge wins because '1' < '4', not because it's the biggest. The distinction matters: on a family whose sizes are 2xlarge/4xlarge/8xlarge this same code picks the smallest and looks entirely correct. The bug only manifests when a family mixes a 1-prefixed double-digit size (10/12/16/24/48xlarge) with single-digit ones — which is why it went unnoticed, and why a regression test has to use a 16xlarge-style family or it passes vacuously.

    Your suggested fix is the right one: on a price tie, prefer the smallest that fits. Candidate already carries VCPUs and MemoryGiB, so the comparator becomes vCPU → memory → name (name retained last, purely for determinism).

    resources.instance_type already exists — sorry, that's on our docs

    You can pin an exact type today, and it does precisely what you wanted:

    "resources": { "instance_type": "hpc7g.4xlarge" }

    Size() short-circuits a pin as its first action, before any truffle or pricing call (pkg/taskproto/sizer.go, added in #413 for nf-spawn's ext.instanceType); family/cpu/memory are ignored when it's set. So the three-size sweep was expressible, and you didn't need to leave the sizing path.

    The reason you couldn't find it is a genuine failure on our side: instance_type is documented only in design docs (docs/pooled-task-execution-design.md, docs/workflow-adapter-protocol-rfc.md) and appears nowhere user-facing — not in docs-gen/task.md, not in task run --help. A capability that exists but is only described in an internal design note is, for practical purposes, missing. That gets fixed alongside the tie-break.

    (For what it's worth, your workaround was still the better experiment — one socket, cores varied — so nothing was lost.)

    Fixing both: the comparator, and documenting the pin where someone sizing a task would actually look.

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