Skip to content

Commit f6d5b76

Browse files
authored
fix: Calculate Verda GPU VRAM as Per GPU (#144)
1 parent 630bc36 commit f6d5b76

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

v1/providers/verda/client_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ func TestWrapVerdaInsufficientResourcesError(t *testing.T) {
5656
assert.False(t, errors.Is(err, v1.ErrServiceUnavailable))
5757
}
5858

59+
func TestVerdaInstanceTypeUsesPerGPUMemory(t *testing.T) {
60+
instanceType, err := verdaInstanceTypeToInstanceType(verdago.InstanceTypeInfo{
61+
InstanceType: "8V100.128G",
62+
Model: "V100 16GB",
63+
GPU: verdago.InstanceGPU{
64+
NumberOfGPUs: 8,
65+
},
66+
GPUMemory: verdago.InstanceMemory{
67+
SizeInGigabytes: 128,
68+
},
69+
PricePerHour: 1,
70+
Currency: "usd",
71+
}, "FIN-01")
72+
require.NoError(t, err)
73+
require.Len(t, instanceType.SupportedGPUs, 1)
74+
75+
gpu := instanceType.SupportedGPUs[0]
76+
assert.Equal(t, int32(8), gpu.Count)
77+
assert.Equal(t, v1.NewBytes(16, v1.Gigabyte), gpu.MemoryBytes)
78+
}
79+
5980
func TestGetInstanceTypesAndLocations(t *testing.T) { //nolint:funlen // One catalog fixture exercises all shared validations.
6081
server := newVerdaTestServer(t, func(w http.ResponseWriter, r *http.Request) {
6182
switch r.URL.Path {

v1/providers/verda/instancetype.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ func verdaInstanceTypeToInstanceType(verdaType verdago.InstanceTypeInfo, locatio
9494
}
9595

9696
if verdaType.GPU.NumberOfGPUs > 0 {
97-
gpuMemory, gpuMemoryBytes := byteSizes(int64(verdaType.GPUMemory.SizeInGigabytes), v1.Gigabyte)
97+
// The Verda API does not expose the GPU memory per GPU, so we need to calculate it
98+
gpuMemoryGB := int64(verdaType.GPUMemory.SizeInGigabytes) / int64(verdaType.GPU.NumberOfGPUs)
99+
gpuMemory, gpuMemoryBytes := byteSizes(gpuMemoryGB, v1.Gigabyte)
98100
gpuModel := strings.ToUpper(strings.TrimSpace(verdaType.Model))
99101
instanceType.SupportedGPUs = []v1.GPU{{
100102
Count: int32(verdaType.GPU.NumberOfGPUs), //nolint:gosec // ok

0 commit comments

Comments
 (0)