Support HAMi GPU core and memory allocation in cost calculations
Is your feature request related to a problem? Please describe. OpenCost does not appear to account for GPU fractions created by HAMi when workloads request fractional NVIDIA GPU resources through HAMi-specific resource names.
HAMi workloads commonly request resources such as:
resources:
limits:
nvidia.com/gpu: "1"
nvidia.com/gpucores: "25"
nvidia.com/gpumem-percentage: "25"
requests:
nvidia.com/gpu: "1"
nvidia.com/gpucores: "25"
nvidia.com/gpumem-percentage: "25"In this case, a pod may be allocated 25% of a physical GPU by HAMi, but OpenCost only sees nvidia.com/gpu: 1 and can report/charge the workload as if it requested a full GPU. This makes GPU cost allocation inaccurate for clusters that use HAMi for GPU core and memory partitioning.
Describe the solution you'd like Add native support for HAMi GPU allocation semantics in OpenCost.
Specifically, OpenCost should recognize HAMi resource names when calculating GPU request/allocation and cost:
nvidia.com/gpucoresnvidia.com/gpumemnvidia.com/gpumem-percentage- any related HAMi resource names or metrics needed for GPU core/memory allocation
For example, if a pod requests nvidia.com/gpu: 1 and nvidia.com/gpucores: 25, OpenCost should be able to treat the request as approximately 0.25 GPU for allocation and cost purposes, or expose enough fields for users to choose core-based or memory-based allocation.
Ideally this would work in allocation APIs such as /allocation/compute, support aggregation by pod/namespace/label, and expose the corrected GPU allocation/cost in gpuCount, gpuRequestAverage, gpuHours, and gpuCost or equivalent fields.
Describe alternatives you've considered The current workaround is to post-process OpenCost allocation results outside OpenCost:
- Query OpenCost allocation data by pod or workload label.
- Query Kubernetes/SciFlow/HAMi metadata to get the intended GPU fraction.
- Multiply OpenCost
gpuCostby the HAMi GPU fraction.
This works for product-specific billing, but it means OpenCost itself still shows inaccurate GPU costs for HAMi workloads and each user has to build their own correction layer.
Another alternative is to represent fractional GPUs directly as fractional nvidia.com/gpu values, but HAMi's documented/resource model uses nvidia.com/gpucores and GPU memory resources, so this is not a practical general solution for existing HAMi clusters.
Additional context Related OpenCost GPU/vGPU work:
- #3039 requested vGPU core and memory usage calculation support.
- #934 added support for fractional
nvidia.com/gpuvalues. - #2862 improved cost calculation with
nvidia.com/gpu.replicas. - #3061 exposed node labels in allocation workloads.
HAMi project: https://github.com/Project-HAMi/HAMi
HAMi resource examples commonly involve nvidia.com/gpucores, nvidia.com/gpumem, and nvidia.com/gpumem-percentage. Native support for these would make OpenCost usable for GPU cost allocation in HAMi-based multi-tenant clusters.
Source: opencost/opencost