-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: Filter backend gallery by system capabilities #7950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
e2b588d
f57ca0e
c0ea11f
d9f2c5a
f37f6d9
a8a075a
de8a984
ee7e8d2
e762e75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,78 @@ var _ = Describe("Gallery Backends", func() { | |
| Expect(nilMetaBackend.IsMeta()).To(BeFalse()) | ||
| }) | ||
|
|
||
| It("should check IsCompatibleWith correctly for meta backends", func() { | ||
| metaBackend := &GalleryBackend{ | ||
| Metadata: Metadata{ | ||
| Name: "meta-backend", | ||
| }, | ||
| CapabilitiesMap: map[string]string{ | ||
| "nvidia": "nvidia-backend", | ||
| "amd": "amd-backend", | ||
| "default": "default-backend", | ||
| }, | ||
| } | ||
|
|
||
| // Test with nil state - should be compatible | ||
| Expect(metaBackend.IsCompatibleWith(nil)).To(BeTrue()) | ||
|
|
||
| // Test with NVIDIA system - should be compatible (has nvidia key) | ||
| nvidiaState := &system.SystemState{GPUVendor: "nvidia", VRAM: 8 * 1024 * 1024 * 1024} | ||
| Expect(metaBackend.IsCompatibleWith(nvidiaState)).To(BeTrue()) | ||
|
|
||
| // Test with default (no GPU) - should be compatible (has default key) | ||
| defaultState := &system.SystemState{} | ||
| Expect(metaBackend.IsCompatibleWith(defaultState)).To(BeTrue()) | ||
| }) | ||
|
|
||
| It("should check IsCompatibleWith correctly for concrete backends", func() { | ||
| // MLX backend should only be compatible on darwin | ||
| mlxBackend := &GalleryBackend{ | ||
| Metadata: Metadata{ | ||
| Name: "mlx", | ||
| }, | ||
| URI: "quay.io/go-skynet/local-ai-backends:latest-metal-darwin-arm64-mlx", | ||
| } | ||
|
|
||
| if runtime.GOOS == "darwin" { | ||
|
||
| Expect(mlxBackend.IsCompatibleWith(&system.SystemState{})).To(BeTrue()) | ||
| } else { | ||
| Expect(mlxBackend.IsCompatibleWith(&system.SystemState{})).To(BeFalse()) | ||
| } | ||
|
|
||
| // CPU backend should be compatible on all systems | ||
| cpuBackend := &GalleryBackend{ | ||
| Metadata: Metadata{ | ||
| Name: "cpu-llama-cpp", | ||
| }, | ||
| URI: "quay.io/go-skynet/local-ai-backends:latest-cpu-llama-cpp", | ||
| } | ||
| Expect(cpuBackend.IsCompatibleWith(&system.SystemState{})).To(BeTrue()) | ||
|
|
||
| // CUDA backend should only be compatible on nvidia systems | ||
| cudaBackend := &GalleryBackend{ | ||
| Metadata: Metadata{ | ||
| Name: "cuda12-llama-cpp", | ||
| }, | ||
| URI: "quay.io/go-skynet/local-ai-backends:latest-gpu-nvidia-cuda-12-llama-cpp", | ||
| } | ||
| if runtime.GOOS != "darwin" { | ||
| // On non-darwin, cuda backend requires nvidia GPU | ||
| Expect(cudaBackend.IsCompatibleWith(&system.SystemState{})).To(BeFalse()) | ||
| Expect(cudaBackend.IsCompatibleWith(&system.SystemState{GPUVendor: "nvidia", VRAM: 8 * 1024 * 1024 * 1024})).To(BeTrue()) | ||
| } | ||
|
|
||
| // ROCm backend should only be compatible on AMD systems | ||
| rocmBackend := &GalleryBackend{ | ||
| Metadata: Metadata{ | ||
| Name: "rocm-llama-cpp", | ||
| }, | ||
| URI: "quay.io/go-skynet/local-ai-backends:latest-gpu-rocm-hipblas-llama-cpp", | ||
| } | ||
| Expect(rocmBackend.IsCompatibleWith(&system.SystemState{})).To(BeFalse()) | ||
| Expect(rocmBackend.IsCompatibleWith(&system.SystemState{GPUVendor: "amd", VRAM: 8 * 1024 * 1024 * 1024})).To(BeTrue()) | ||
| }) | ||
|
|
||
| It("should find best backend from meta based on system capabilities", func() { | ||
|
|
||
| metaBackend := &GalleryBackend{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -617,6 +617,12 @@ func RegisterUIAPIRoutes(app *echo.Echo, cl *config.ModelConfigLoader, ml *model | |
| installedBackendsCount = len(installedBackends) | ||
| } | ||
|
|
||
| // Get the detected system capability | ||
| detectedCapability := "" | ||
| if appConfig.SystemState != nil { | ||
| detectedCapability = appConfig.SystemState.DetectedCapability() | ||
| } | ||
|
|
||
| return c.JSON(200, map[string]interface{}{ | ||
| "backends": backendsJSON, | ||
| "repositories": appConfig.BackendGalleries, | ||
|
|
@@ -629,6 +635,7 @@ func RegisterUIAPIRoutes(app *echo.Echo, cl *config.ModelConfigLoader, ml *model | |
| "totalPages": totalPages, | ||
| "prevPage": prevPage, | ||
| "nextPage": nextPage, | ||
| "systemCapability": detectedCapability, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot now let's make use of this and display in the webui view the capability that was detected of the system
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added display of the detected system capability in the webui. The hero section now shows "System: {capability}" with a microchip icon, fetching the |
||
| }) | ||
| }) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot keep the capabilities business logic in
capabilities.go. use common constants ( defined and/or to be defined in pkg/system) instead of hardcoded stringsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the backend compatibility business logic to
pkg/system/capabilities.goand exported constants for use across packages. TheIsCompatibleWithmethod now delegates toSystemState.IsBackendCompatible(name, uri string). Added backend detection tokens as constants (BackendTokenDarwin,BackendTokenMLX,BackendTokenCUDA, etc.). See commit d9f2c5a.