Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Refactors GPUConfig struct to use Kubernetes resource.Quantity for GPU memory instead of raw integers, providing better type safety and alignment with K8s resource management patterns.

Changes

  • Core struct update: Changed GPUMemGiB field type from int to resource.Quantity
  • Helper function: Added NewGPUMemGiB(gib int64) to construct Quantity values in bytes from GiB integers
  • SKU definitions: Updated all GPU configurations across Azure (30), AWS (59), and Arc (10) providers to use NewGPUMemGiB()
  • Validation logic: Updated GPU memory comparisons to use .Cmp() method and .Value() for byte-level calculations
  • Estimators: Modified memory calculations in basic and advanced node estimators to work with Quantity values
  • Utilities: Updated GetGPUConfigFromNodeLabels() to convert MiB node labels to Quantity in bytes
  • Tests: Updated all test cases to use new type and comparison methods

Example

// Before
gpuConfig := &sku.GPUConfig{
    GPUMemGiB: 80,  // Plain integer
}

// After  
gpuConfig := &sku.GPUConfig{
    GPUMemGiB: sku.NewGPUMemGiB(80),  // resource.Quantity in bytes
}

// Comparisons now use Quantity methods
if gpuConfig.GPUMemGiB.Cmp(otherConfig.GPUMemGiB) != 0 {
    // Handle difference
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Convert GPUMemory type from int to resource.Quantity</issue_title>
<issue_description>Can be a follow-up but it's probably better to refactor GPUConfig struct to use resource.Quantity instead of int for GPU memory

Originally posted by @chewong in #1536 (comment)
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 23, 2025
Copilot AI changed the title [WIP] Refactor GPUConfig to use resource.Quantity for memory type Convert GPUConfig.GPUMemGiB from int to resource.Quantity Dec 23, 2025
Copilot AI requested a review from andyzhangx December 23, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Convert GPUMemory type from int to resource.Quantity

2 participants