[RFC][Serve][LLM] Pluggable Model-Level Routing for Multi-Model Applications
Summary
Ray Serve LLM supports serving multiple models behind one OpenAI-compatible endpoint, but the client currently needs to choose a concrete model.
There is increasing demand for the serving layer to make that choice automatically. For example, an application may want to send simple requests to a smaller model and harder requests to a larger model without putting another gateway in front of Ray. NVIDIA NeMo Switchyard implements this pattern externally.
This RFC proposes a small, pluggable model-routing layer:
request model="auto"
|
v
ModelRoutingPolicy
|
| selects concrete model
v
existing model resolution
|
v
DeploymentHandle
|
v
RequestRouter
|
| selects replica
v
ReplicaThe important distinction is:
- Model routing: which concrete model/deployment should handle the request?
- Replica routing: which replica of that deployment should handle it?
The existing RequestRouter remains responsible for replica routing.
Use case
Consider an application serving:
qwen-8b
qwen-70bToday the client chooses: model="qwen-8b"or: model="qwen-70b"
Instead, the application may want to expose: model="auto" and apply an application-defined policy:
auto
|
+-- simple request ---> qwen-8b
|
+-- complex request --> qwen-70bUsers can implement this today with a custom ingress deployment or an external router such as Switchyard, but that creates a second routing layer outside the standard Serve LLM path.
The proposal is to make this decision a first-class Serve LLM primitive while continuing to use existing deployment and replica-routing mechanisms after the model is selected.
Relationship to Serve model multiplexing
Ray already has an important model-routing primitive: @serve.multiplexed.
Multiplexing solves a different problem. With multiplexing, many model variants share the same Serve deployment and replica pool:
Deployment
|
+-- replica 1: model-A loaded
+-- replica 2: model-B loaded
+-- replica 3: model-A loadedA request contains a multiplexed_model_id, and MultiplexMixin prefers replicas that already have that model loaded.
Serve LLM uses this mechanism for dynamically loaded LoRA adapters. OpenAiIngress resolves a LoRA model to its base-model deployment and sets:
handle.options(
multiplexed_model_id=lora_model_id,
)The proposed model router operates one layer above this:
ModelRoutingPolicy
|
choose concrete model/deployment
|
v
DeploymentHandle
|
existing multiplexing
when applicable
|
v
RequestRouter
|
v
ReplicaSo these abstractions are complementary:
ModelRoutingPolicy
chooses across model deployments
Multiplexing
chooses/loads a model variant within one deployment's replica pool
RequestRouter
chooses the replicaV1 would route among configured top-level Serve LLM models. Dynamic LoRA selection continues through the existing multiplexing path and is not replaced by this RFC. Also, if the client specifies a concrete model ID, the existing resolution path is unchanged, model routing runs only for explicitly configured logical routes.
Questions for discussion
- Does this abstraction makes sense, given generic cost of SOTA models is increasing and smaller models can handle small task faster and cheaper.
- Does a model-selection abstraction above RequestRouter make sense, or is there an existing Serve primitive this should build on instead?
- Should this live in Serve LLM rather than generic Serve?
Source: ray-project/ray