Repository navigation
fix(slurm): price estimates from truffle's live rates, not a stale table (#447) - #449
Merged
Merged
Conversation
…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 Report❌ Patch coverage is
📢 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
p4d.24xlargep5.48xlargeg5.16xlargep3.*Two things the verification pass turned up that shaped the fix:
p3is genuinely retired.DescribeInstanceTypeOfferings --location-type regionreturns nop3offering in us-east-1, us-east-2, us-west-2 or eu-west-1. A--gres=gpu:v100script was selecting an instance type that cannot launch, surfacing as an opaqueRunInstancesfailure 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 aPricerinterface sopkg/slurmstays unit-testable without AWS. spawn keeps no rate table.slurm.EstimateCost(job)→slurm.EstimateCostWithPricer(ctx, job, pricer, region), plusslurm.TotalInstanceHours(job)for the credential-free half of the arithmetic.--regionon bothestimateandsubmit. Precedence:--region, then#SPAWN --region, then the resolved AWS config region.$/hrbehind each total, the region priced, and the computed spot discount — so the figure is checkable against the console.SpotUnavailable), not rendered as$0.00; newly-launched accelerator types routinely have no spot market and the On-Demand answer still stands.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:
truffle's default wraps the Price List pricer in a
fallbackPricerbacked by thelibs/pricingtable, 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.96xlargeisn't offered in us-west-2, so the Price List query correctly failed; the fallback swallowed that error andestimatePriceByFamilyreturned$0.10 × 2.0 = $0.20/hragainst 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
normalizeGPUTypeaccepting the plausible gres spellings (nvidia_h100,h200-141gb,rtx_pro_6000, …).p5.4xlargematters 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.p3rows 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 — soretiredGPUSuccessorsmapsv100to 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.Priceis renamedRelativeCost, documented as a ranking input that is never multiplied by hours and never shown to a user. TheSelectInstanceTypesort 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 checkpasses. 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):
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.gosupplies rates through afakePricerand asserts only on how the estimate uses them — never on what a real rate is. A test pinning$55.04would 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 longeron-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.gocovers 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 failTestSelectInstanceTypePicksCheapestMatch. The assertion states the intended contract; it can't force an unstable sort to disagree.Breaking change
slurm.EstimateCostis removed rather than shimmed — a shim would have to keep reading the drifted table, which is the bug. WithInstanceTypeSpec.Price→RelativeCost, that's a breaking exported-signature change: pre-1.0, a MINOR bump. No in-repo callers remain.CHANGELOG.mdis updated in this PR per CLAUDE.md.