Repository navigation
feat(server): support per-model backend device selection - #973
Merged
Merged
Conversation
Owner
|
@railep Thanks for adding this great extension! PR merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deviceoverride for configured and dynamically loaded server modelsGET /v1/modelsThe field is opt-in. Existing configurations without
models[].devicecontinue to use the server-widedevice.This allows multi-GPU systems to keep different models resident on different devices—for example, a large synthesis model on one GPU and smaller supporting models on another. It improves VRAM utilization, avoids unnecessary unload/reload cycles, and lets independent models use the available GPUs concurrently.
Example
{ "backend": "cuda", "device": 0, "max_loaded_models": 0, "models": [ {"id": "speech", "family": "kokoro_tts", "path": "models/kokoro.gguf", "device": 0}, {"id": "music", "family": "stable_audio", "path": "models/stable-audio", "device": 1} ] }This assigns each complete model to one backend device. It does not split a single model across GPUs, and
max_loaded_modelsremains a server-wide limit.Validation
Tested on Windows with CUDA 13.1 using:
Full CUDA build:
Successful tests:
The multi-device CUDA test alternates
0 -> 1 -> 0 -> 1on one serving thread and covers allocation, reuse, release, and reallocation of device-specific buffers. The server lifecycle test covers global-device fallback, per-model override propagation toSessionOptions, effective-device model listings, assignment-preserving reloads, and rejection of negative dynamic device indices.A CUDA Release server build also completed successfully before the final rebase; the full Debug build and all tests above were repeated after rebasing onto current
main.Compatibility and scope
GET /v1/modelsgains the additivedevicefield