Skip to content

fix(slurm): price estimates from truffle's live rates, not a stale table (#447) - #449

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/447-live-pricing-for-slurm-estimates
Jul 28, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/447-live-pricing-for-slurm-estimates

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #447.

The problem, verified

Every number in the issue checked out against the live Price List API (us-east-1, 2026-07-27), and the issue slightly understated it:

type table said actual
p4d.24xlarge 32.77 21.957642 49% over
p5.48xlarge 98.32 55.04 79% over
g5.16xlarge 3.672 4.096 10% under (not in the issue)
p3.* listed not offered retired

Two things the verification pass turned up that shaped the fix:

  1. All ~48 non-GPU rows were still exactly correct. Only the accelerator rows drift. That's the argument against maintaining rates here at all — the rows that matter most are the ones that go stale fastest.
  2. p3 is genuinely retired. DescribeInstanceTypeOfferings --location-type region returns no p3 offering in us-east-1, us-east-2, us-west-2 or eu-west-1. A --gres=gpu:v100 script was selecting an instance type that cannot launch, surfacing as an opaque RunInstances failure far from the cause.

Beyond the drift, the table can't represent the problem: On-Demand GPU rates swing ~70% between regions, and spot was modeled as a flat on-demand × 0.3. Measured in us-east-1, the real discount ranged from 38% (p5.48xlarge) to 62% (c5.4xlarge) — wrong in both directions.

The fix

Rates come from truffle, the suite's pricing authority (Client.HourlyRate → Price List + Spot history, cached), reached through a Pricer interface so pkg/slurm stays unit-testable without AWS. spawn keeps no rate table.

  • slurm.EstimateCost(job) → slurm.EstimateCostWithPricer(ctx, job, pricer, region), plus slurm.TotalInstanceHours(job) for the credential-free half of the arithmetic.
  • --region on both estimate and submit. Precedence: --region, then #SPAWN --region, then the resolved AWS config region.
  • Output states the $/hr behind each total, the region priced, and the computed spot discount — so the figure is checkable against the console.
  • A missing spot price is reported (SpotUnavailable), not rendered as $0.00; newly-launched accelerator types routinely have no spot market and the On-Demand answer still stands.
  • A missing On-Demand rate is an error. This figure gates slurm submit, which launches billable instances; quoting a guess is the worst available outcome.

One thing worth a reviewer's attention

To make that last point true, this opts out of truffle's default static fallback:

tc.SetOnDemandPricer(truffleaws.NewAWSOnDemandPricer(awsClient.Config()))

truffle's default wraps the Price List pricer in a fallbackPricer backed by the libs/pricing table, so a Price List outage degrades to an estimate instead of zeroed savings. That's the right call for a savings percentage. It's the wrong call here — and it's not hypothetical. hpc7a.96xlarge isn't offered in us-west-2, so the Price List query correctly failed; the fallback swallowed that error and estimatePriceByFamily returned $0.10 × 2.0 = $0.20/hr against a real $7.20. Same defect class as #447, one layer down. With the Price List pricer alone, an unpriceable type says so. (Filed as spore-host/truffle#114 — spawn opting out doesn't fix it for other embedders.)

GPU selection re-sourced

Added g6 (L4), g6e (L40S), g7 (RTX PRO 4500), g7e (RTX PRO 6000), p4de (A100 80GB), p5e/p5en (H200), p6-b200/p6-b300 (Blackwell) — with normalizeGPUType accepting the plausible gres spellings (nvidia_h100, h200-141gb, rtx_pro_6000, …).

p5.4xlarge matters on its own: it's the only H100 size that doesn't require renting all 8 GPUs, so its absence made single-GPU H100 work look 8× more expensive ($6.88 vs $55.04) than it is.

p3 rows removed. Removing them alone would have been a regression — it converts "picks a dead type" into a hard "no instance type found" for a still-valid script — so retiredGPUSuccessors maps v100 to current GPUs with at least as much VRAM. T4 is deliberately excluded: it matches on VRAM but is a large step down in compute, and silently making a job much slower is its own wrong answer.

InstanceTypeSpec.Price is renamed RelativeCost, documented as a ranking input that is never multiplied by hours and never shown to a user. The SelectInstanceType sort also gained a name tie-break, because several types share a rank (c5/c6i are priced identically at 4xlarge/12xlarge/24xlarge) and slice order shouldn't decide which one a user gets.

Verification

make check passes. Six of the new guards were mutation-tested — the fix reverted, the test confirmed failing.

Verified live against real AWS (read-only pricing APIs; no instances launched):

$ spawn slurm estimate h100.sbatch --region us-east-1
  Instance type:       p5.4xlarge          # was p5.48xlarge, 8× the GPUs
  On-demand cost:      $27.52  ($6.8800/hr)  # matches Price List exactly
  Spot cost:           $10.52  ($2.6295/hr, 62% off on-demand)

$ spawn slurm estimate odd.sbatch --region us-east-2   # #SPAWN --instance-type=hpc7a.96xlarge
  On-demand cost:      $7.20  ($7.2000/hr)   # was $0.20 before opting out of the fallback

$ spawn slurm estimate odd.sbatch --region us-west-2   # type not offered there
  failed to estimate cost: on-demand rate for hpc7a.96xlarge in us-west-2: no on-demand price found

An l40s job also prices 25% higher in eu-central-1 than us-east-1 — the regional spread the old single number couldn't express.

Tests

pkg/slurm/estimate_test.go supplies rates through a fakePricer and asserts only on how the estimate uses them — never on what a real rate is. A test pinning $55.04 would be the same stale-table failure wearing a different hat. It covers: live rates in both totals (with an explicit assertion that spot is no longer on-demand × 0.3), the type and region actually reaching the pricer, a missing spot price surviving as an On-Demand answer, and a missing On-Demand rate erroring.

pkg/slurm/resources_test.go covers the table's factual claims and ordering: no retired types, a retired-GPU request still resolving, cheapest-match selection computed independently of the selection code, every new family reachable, GPU counts respected, internal spec consistency, no duplicates.

One honesty note carried in a comment rather than papered over: with the current table, sort.Slice's unstable order happens to agree with the new name tie-break, so deleting the tie-break does not fail TestSelectInstanceTypePicksCheapestMatch. The assertion states the intended contract; it can't force an unstable sort to disagree.

Breaking change

slurm.EstimateCost is removed rather than shimmed — a shim would have to keep reading the drifted table, which is the bug. With InstanceTypeSpec.Price → RelativeCost, that's a breaking exported-signature change: pre-1.0, a MINOR bump. No in-repo callers remain. CHANGELOG.md is updated in this PR per CLAUDE.md.

…ble (#447)

`spawn slurm estimate` and `slurm submit` quoted costs from a hardcoded
$/hr table in pkg/slurm. Checked against the Price List API on 2026-07-27,
p4d was overstated 49% and p5 79%, spot was assumed a flat 70% off when the
real discount ranges 38-62%, and a single number can't express the ~70%
On-Demand swing between regions at all. Notably all ~48 non-GPU rows were
still exactly correct — only the accelerator rows drift, which is the
argument for not keeping rates here at all.

spawn now takes both rates from truffle, the suite's pricing authority,
via a Pricer seam so pkg/slurm stays testable without AWS. `--region` is
added to both commands (--region, else #SPAWN --region, else the AWS config
region) and the output states the $/hr, the region, and the real spot
discount so a user can check it against the console.

The estimate now errors when no On-Demand rate can be read, rather than
quoting a guess: it gates a billable launch. That also means opting out of
truffle's default static fallback, whose table has no entry for newer
families and answered hpc7a.96xlarge at $0.20/hr against a real $7.20.

GPU selection re-sourced from current hardware: added g6, g6e, g7, g7e,
p4de, p5e/p5en and p6-b200/p6-b300, plus p5.4xlarge — the only H100 size
that doesn't require renting all 8 GPUs. Removed p3/V100, which AWS no
longer offers in us-east-1/us-east-2/us-west-2/eu-west-1, so selecting it
produced a type that could not launch; --gres=gpu:v100 now resolves to a
current successor instead of failing.

BREAKING (library, pre-1.0 -> MINOR): slurm.EstimateCost is removed in
favor of EstimateCostWithPricer + TotalInstanceHours, and
InstanceTypeSpec.Price is renamed RelativeCost. No shim: any shim would
have to keep reading the drifted table.
@codecov

codecov Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 88 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/slurm.go 8.00% 69 Missing ⚠️
pkg/slurm/resources.go 89.47% 16 Missing ⚠️
pkg/slurm/convert.go 91.89% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…ot the guess

truffle#114 removed the family-guess fallback, so the comment's justification
("answers with a family estimate") no longer describes current truffle. The
opt-out still stands, for the narrower reason that a stale-but-real rate is
also wrong to quote as current when the number gates a billable launch.
@scttfrdmn
scttfrdmn merged commit 2e6fff3 into main Jul 28, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/447-live-pricing-for-slurm-estimates branch July 28, 2026 02:51
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.

pkg/slurm hardcoded GPU prices are stale (p4d off 49%, p5 off 79%) and miss g6e/g7/g7e/p6

1 participant