diff --git a/.nextchanges/cli/ssh-connect-gpu-accelerator.md b/.nextchanges/cli/ssh-connect-gpu-accelerator.md new file mode 100644 index 00000000000..7108dd1a55d --- /dev/null +++ b/.nextchanges/cli/ssh-connect-gpu-accelerator.md @@ -0,0 +1 @@ +* `databricks ssh connect --accelerator` now accepts every AI Runtime GPU type the CLI knows, including `GPU_1xH100`, `GPU_8xB300` and `GPU_1xRTX6000`. ([#7833](https://github.com/databricks/cli/pull/7833)) diff --git a/cmd/air/compute.go b/cmd/air/compute.go index f223d9fd4dc..f085cd2137d 100644 --- a/cmd/air/compute.go +++ b/cmd/air/compute.go @@ -3,6 +3,7 @@ package aircmd import ( "errors" "fmt" + "slices" "strings" ) @@ -18,12 +19,24 @@ const ( gpuType1xRTX6000 gpuType = "GPU_1xRTX6000" ) +// KnownGPUTypes lists the accelerator types this CLI accepts, in the order they are shown +// to users. `ssh connect --accelerator` validates against the same list, so the two entry +// points to AI Runtime GPUs agree on the types they offer. +func KnownGPUTypes() []string { + return []string{ + string(gpuType1xA10), + string(gpuType1xH100), + string(gpuType8xH100), + string(gpuType8xB300), + string(gpuType1xRTX6000), + } +} + // parseGPUType resolves a YAML accelerator_type string to a gpuType. The match is // exact: the server's lookup is case-sensitive. The error lists no types because // which ones a workspace can use comes from the server, not this CLI. func parseGPUType(value string) (gpuType, error) { - switch gpuType(value) { - case gpuType1xA10, gpuType8xH100, gpuType1xH100, gpuType8xB300, gpuType1xRTX6000: + if slices.Contains(KnownGPUTypes(), value) { return gpuType(value), nil } return "", fmt.Errorf("%q is not a recognized accelerator type", value) diff --git a/experimental/ssh/cmd/connect.go b/experimental/ssh/cmd/connect.go index d2040ad760f..b9191995ffc 100644 --- a/experimental/ssh/cmd/connect.go +++ b/experimental/ssh/cmd/connect.go @@ -1,8 +1,10 @@ package ssh import ( + "strings" "time" + aircmd "github.com/databricks/cli/cmd/air" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/experimental/ssh/internal/client" "github.com/databricks/cli/libs/cmdctx" @@ -71,7 +73,7 @@ Connect to a dedicated cluster: cmd.Flags().BoolVar(&keepDetachedProcesses, "keep-detached-processes", false, "Keep the SSH server and detached processes (tmux, setsid, nohup) running while detached work remains, bounded by --server-timeout") cmd.Flags().StringVar(&connectionName, "name", "", "Connection name to reuse across sessions (serverless only)") - cmd.Flags().StringVar(&accelerator, "accelerator", "", "Serverless GPU accelerator type (GPU_1xA10 or GPU_8xH100)") + cmd.Flags().StringVar(&accelerator, "accelerator", "", "Serverless GPU accelerator type ("+strings.Join(aircmd.KnownGPUTypes(), ", ")+")") cmd.Flags().StringVar(&ide, "ide", "", "Open remote IDE window (vscode or cursor)") cmd.Flags().StringVar(&usagePolicyID, "usage-policy-id", "", "Usage policy ID for the serverless SSH server job (serverless only)") diff --git a/experimental/ssh/internal/client/client.go b/experimental/ssh/internal/client/client.go index 5afd212131f..c3260f4f231 100644 --- a/experimental/ssh/internal/client/client.go +++ b/experimental/ssh/internal/client/client.go @@ -17,11 +17,13 @@ import ( "os/signal" "path/filepath" "regexp" + "slices" "strconv" "strings" "syscall" "time" + aircmd "github.com/databricks/cli/cmd/air" "github.com/databricks/cli/experimental/ssh/internal/keys" "github.com/databricks/cli/experimental/ssh/internal/proxy" "github.com/databricks/cli/experimental/ssh/internal/sshconfig" @@ -165,8 +167,9 @@ func (o *ClientOptions) Validate() error { if o.UsagePolicyID != "" && o.ClusterID != "" { return errors.New("--usage-policy-id flag can only be used with serverless compute (--name flag)") } - if o.Accelerator != "" && o.Accelerator != "GPU_1xA10" && o.Accelerator != "GPU_8xH100" { - return fmt.Errorf("invalid accelerator value: %q, expected %q or %q", o.Accelerator, "GPU_1xA10", "GPU_8xH100") + // The same GPU types `databricks air` accepts; the workspace still decides which it offers. + if o.Accelerator != "" && !slices.Contains(aircmd.KnownGPUTypes(), o.Accelerator) { + return fmt.Errorf("invalid accelerator value: %q, expected one of %s", o.Accelerator, strings.Join(aircmd.KnownGPUTypes(), ", ")) } if o.ConnectionName != "" && !connectionNameRegex.MatchString(o.ConnectionName) { return fmt.Errorf("connection name %q must consist of letters, numbers, dashes, and underscores", o.ConnectionName) diff --git a/experimental/ssh/internal/client/client_test.go b/experimental/ssh/internal/client/client_test.go index 20bc56d0115..f21168e7b08 100644 --- a/experimental/ssh/internal/client/client_test.go +++ b/experimental/ssh/internal/client/client_test.go @@ -58,10 +58,19 @@ func TestValidate(t *testing.T) { name: "valid connection name with GPU_8xH100 accelerator", opts: client.ClientOptions{ConnectionName: "my-conn_1", Accelerator: "GPU_8xH100"}, }, + { + name: "valid connection name with GPU_1xRTX6000 accelerator", + opts: client.ClientOptions{ConnectionName: "my-conn_1", Accelerator: "GPU_1xRTX6000"}, + }, + { + name: "well-formed but unknown accelerator value", + opts: client.ClientOptions{ConnectionName: "my-conn", Accelerator: "GPU_2xA10"}, + wantErr: `invalid accelerator value: "GPU_2xA10", expected one of GPU_1xA10, GPU_1xH100, GPU_8xH100, GPU_8xB300, GPU_1xRTX6000`, + }, { name: "invalid accelerator value", opts: client.ClientOptions{ConnectionName: "my-conn", Accelerator: "CPU_1x"}, - wantErr: `invalid accelerator value: "CPU_1x", expected "GPU_1xA10" or "GPU_8xH100"`, + wantErr: `invalid accelerator value: "CPU_1x", expected one of GPU_1xA10, GPU_1xH100, GPU_8xH100, GPU_8xB300, GPU_1xRTX6000`, }, { name: "both cluster ID and connection name",