Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions v1/providers/launchpad/instance_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"context"
"net"
"strings"

"github.com/brevdev/cloud/internal/collections"
"github.com/brevdev/cloud/internal/errors"
Expand All @@ -13,8 +14,9 @@ import (
)

const (
brevExperienceID = "43123766-35ec-4eb4-a5ba-3f2945228445"
minimalExperienceID = "a5d93f56-bbdb-44db-a1ae-6b1ad7d3c6df"
brevExperienceID = "43123766-35ec-4eb4-a5ba-3f2945228445"
minimalExperienceID = "a5d93f56-bbdb-44db-a1ae-6b1ad7d3c6df"
brevGH200ExperienceID = "d12c37eb-270a-4471-be45-48e4d1fdb764"
)

func (c *LaunchpadClient) CreateInstance(ctx context.Context, attrs v1.CreateInstanceAttrs) (*v1.Instance, error) {
Expand Down Expand Up @@ -99,9 +101,18 @@ func instanceTypeToLaunchpadExperience(instanceTypeInfo instanceTypeInfo) string
if instanceTypeInfo.cloud == "nebius" {
return minimalExperienceID
}
if matchesGH200Experience(instanceTypeInfo) {
return brevGH200ExperienceID
}
return brevExperienceID
}

func matchesGH200Experience(info instanceTypeInfo) bool {
return info.cloud == dmzCloud &&
strings.EqualFold(info.gpuName, "gh200") &&
strings.EqualFold(info.gpuNetworkDetails, "sxm")
}

type launchpadCreateAttrs v1.CreateInstanceAttrs

func (l launchpadCreateAttrs) validate() error {
Expand Down
48 changes: 48 additions & 0 deletions v1/providers/launchpad/instance_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ func TestLaunchpadClient_CreateInstance(t *testing.T) {

t.Logf("instance: %v", instance)
}

func Test_instanceTypeToLaunchpadExperience(t *testing.T) {
t.Parallel()

tests := []struct {
name string
info instanceTypeInfo
expected string
}{
{
name: "nebius uses the minimal experience",
info: instanceTypeInfo{cloud: "nebius"},
expected: minimalExperienceID,
},
{
name: "gh200 SXM uses the gh200 experience",
info: instanceTypeInfo{cloud: dmzCloud, gpuName: "gh200", gpuNetworkDetails: "sxm", gpuCount: 1},
expected: brevGH200ExperienceID,
},
{
name: "gh200 SXM selection is count-agnostic",
info: instanceTypeInfo{cloud: dmzCloud, gpuName: "gh200", gpuNetworkDetails: "sxm", gpuCount: 8},
expected: brevGH200ExperienceID,
},
{
name: "gh200 PCIe does not match the SXM-only gh200 experience",
info: instanceTypeInfo{cloud: dmzCloud, gpuName: "gh200", gpuNetworkDetails: "pcie", gpuCount: 1},
expected: brevExperienceID,
},
{
name: "non-gh200 GPU on SXM uses the default experience",
info: instanceTypeInfo{cloud: dmzCloud, gpuName: "h100", gpuNetworkDetails: "sxm", gpuCount: 1},
expected: brevExperienceID,
},
{
name: "gh200 SXM on a non-dmz cloud uses the default experience",
info: instanceTypeInfo{cloud: "oci", gpuName: "gh200", gpuNetworkDetails: "sxm", gpuCount: 1},
expected: brevExperienceID,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, tt.expected, instanceTypeToLaunchpadExperience(tt.info))
})
}
}
Loading