Skip to content

fix(lib-cloudinfo): type CloudProduct.gpusPerVm as Float to keep fractional-GPU counts#98

Merged
pditommaso merged 2 commits into
masterfrom
fix-cloudinfo-fractional-gpu
Jul 24, 2026
Merged

fix(lib-cloudinfo): type CloudProduct.gpusPerVm as Float to keep fractional-GPU counts#98
pditommaso merged 2 commits into
masterfrom
fix-cloudinfo-fractional-gpu

Conversation

@pditommaso

Copy link
Copy Markdown
Contributor

What this changes

Types CloudProduct.gpusPerVm as Float instead of Integer.

CloudInfo reports fractional GPU counts for fractional-GPU instance families — e.g. AWS g6f.2xlarge reports gpusPerVm=0.25 (fractional NVIDIA L4). Decoding 0.25 into an Integer field truncated it to 0 (Jackson ACCEPT_FLOAT_AS_INT), so a genuine GPU instance became indistinguishable from a CPU-only one for any consumer checking gpusPerVm > 0. The neighbouring fractional fields (memPerVm, onDemandPrice) are already Float; gpusPerVm was the anomaly.

With Float, fractional counts survive and > 0 correctly flags any accelerator.

Evidence (live CloudInfo, amazon/compute/us-east-1)

type category gpusPerVm (wire) Integer (before) Float (after)
g6f.2xlarge GPU instance 0.25 0 0.25
g6f.large GPU instance 0.125 0 0.125
gr6f.4xlarge GPU instance 0.5 0 0.5
g6.2xlarge GPU instance 1 1 1.0

Tests

Added CloudProductTest cases asserting a fractional gpusPerVm survives JSON decode (0.25 stays 0.25, > 0), plus whole/absent values. ./gradlew :lib-cloudinfo:test passes.

Downstream note

This is a breaking type change for consumers that auto-unbox getGpusPerVm() to int (notably sched), which need a matching follow-up to consume Float and treat > 0 as GPU. AcceleratorFeatures.hasGpu(features) (token-based) is unaffected.

Closes #97

Impact context

Downstream in sched, the truncation let g6f.2xlarge be mixed into a CPU-only task's instance pool, contributing to a spot stock-out (seqeralabs/sched#789).

🤖 Generated with Claude Code

…tional-GPU counts

CloudInfo reports fractional GPU counts for fractional-GPU instance families
(e.g. AWS g6f.2xlarge reports gpusPerVm=0.25). The Integer field truncated
these to 0 on JSON decode, making genuine GPU instances indistinguishable from
CPU-only ones for consumers that check gpusPerVm > 0.

Type gpusPerVm as Float (consistent with memPerVm/onDemandPrice) so fractional
counts survive; > 0 then correctly flags any accelerator.

Fixes #97

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso
pditommaso requested a review from jordeu July 23, 2026 21:26
…pe change

- VERSION 1.2.2 -> 2.0.0 (breaking Integer->Float on published getter/setter)
- changelog entry flagged BREAKING
- README dependency snippet -> 2.0.0
- test: pin encode direction (whole counts serialise as 8.0)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pditommaso
pditommaso merged commit 624e528 into master Jul 24, 2026
3 checks passed
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.

lib-cloudinfo: CloudProduct.gpusPerVm is Integer — truncates fractional-GPU instances (g6f) to 0, misclassifying them as CPU

2 participants