Skip to content
Merged
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
4 changes: 2 additions & 2 deletions docs/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ non_cached_tokens = 16 # llm-d only: below this many non-cached prompt
"kv-cache-utilization-scorer" = 2.0
```

- **`vllm-router`** (default) — our fork of [vllm-router](https://github.com/PrimeIntellect-ai/router). Knob: `policy`. The only backend supported for single-node (local) deployments.
- **`llm-d`** — the upstream [llm-d](https://llm-d.ai) Endpoint Picker (EPP) + Envoy proxy (multi-node / disaggregated SLURM deployments only). Routing combines **prefix-cache affinity** (grouped rollouts reuse a cached prefix and skip prefill) with the **`active-request-scorer`** — an in-flight load balancer that spreads requests across ranks immediately, unlike the metrics-scraped `queue-scorer` / `kv-cache-utilization-scorer` / `load-aware-scorer` (which lag and concentrate bursts of same-prefix requests). The scorer weights follow the upstream llm-d P/D guide; tune via `scorers` (base) + `prefill_scorer_overrides` / `decode_scorer_overrides` (per-profile, P/D). Does not support `enable_return_routed_experts` (router replay).
- **`vllm-router`** (default) — our fork of [vllm-router](https://github.com/PrimeIntellect-ai/router). Knob: `policy`.
- **`llm-d`** — the upstream [llm-d](https://llm-d.ai) Endpoint Picker (EPP) + Envoy proxy. `uv run router @ router.json` renders their configs and runs both, so it works on one node, on several nodes and under P/D. With in-engine data parallelism on one node, vLLM balances the ranks behind the one engine URL. Routing combines **prefix-cache affinity** (grouped rollouts reuse a cached prefix and skip prefill) with the **`active-request-scorer`** — an in-flight load balancer that spreads requests across ranks immediately, unlike the metrics-scraped `queue-scorer` / `kv-cache-utilization-scorer` / `load-aware-scorer` (which lag and concentrate bursts of same-prefix requests). The scorer weights follow the upstream llm-d P/D guide; tune via `scorers` (base) + `prefill_scorer_overrides` / `decode_scorer_overrides` (per-profile, P/D). Does not support `enable_return_routed_experts` (router replay).

Both backends support the 2 most important things:
- Request routing - KV cache re-use and balanced routing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ def validate_scorers(self):
return self


# Discriminated on ``type`` so the launch path can pick the router backend.
RouterBackendConfig: TypeAlias = Annotated[VllmRouterConfig | LlmdRouterConfig, Field(discriminator="type")]


class RouterConfig(ComponentConfig):
"""Config of the router process: a vllm-router fronting the engines. The llm-d router has no router process;
the SLURM templates start it."""
"""Config of the router process: a vllm-router, or an llm-d EPP and Envoy, fronting the engines."""

router: VllmRouterConfig = VllmRouterConfig()
"""Settings of the vllm-router backend."""
router: RouterBackendConfig = VllmRouterConfig()
"""Router backend and its settings."""

host: str = "0.0.0.0"
"""Host the router binds."""
Expand All @@ -110,11 +108,15 @@ class RouterConfig(ComponentConfig):
"""Decode engine URLs of a disaggregated deployment. The launcher passes them at start (``--decode-urls``)."""

intra_node_data_parallel_size: int = Field(1, ge=1)
"""Data-parallel ranks behind each URL."""
"""Data-parallel ranks behind each URL. Only vllm-router addresses the ranks; llm-d sends to the URL."""

pd_bidirectional_ttl_s: int | None = Field(None, ge=1)
"""How long the router keeps a session's decode KV blocks for its next prefill. None disables
bidirectional KV transfer."""

decode_port: int | None = Field(None, ge=1, le=65535)
"""llm-d P/D only: first port of the decode engines on a node. The pd-sidecar of the engine on
``decode_port + k`` listens on ``router.decode_sidecar_port + k``, and llm-d routes decode requests to it."""

prometheus_port: int | None = Field(None, ge=1, le=65535)
"""Port of the router's Prometheus metrics endpoint (None = the vllm-router default)."""
"""Port of the router's Prometheus metrics endpoint (None = the backend's default)."""
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ def validate_deployment(self):
raise ValueError("Must use SLURM for multi-node deployment.")
return self

@model_validator(mode="after")
def validate_router_deployment(self):
"""The SLURM templates launch the llm-d router (EPP + Envoy) for the engines on dedicated nodes."""
router = self.inference.router if self.inference is not None else None
if router is not None and router.type == "llm-d" and self.deployment.type == "single_node":
raise ValueError("The llm-d router backend requires a multi-node SLURM deployment.")
return self

@model_validator(mode="after")
def validate_weight_broadcast_inference(self):
if self.weight_broadcast is not None and self.weight_broadcast.type != "filesystem" and self.inference is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
prefill_uses_deepep_high_throughput,
)
from prime_rl.configs.components.engine.kv_cache import KVCacheOffloadConfig
from prime_rl.configs.components.router import RouterBackendConfig, RouterConfig, VllmRouterConfig
from prime_rl.configs.components.router import LlmdRouterConfig, RouterBackendConfig, RouterConfig, VllmRouterConfig
from prime_rl.utils.config import find_package_resource

PDRole: TypeAlias = Literal["prefill", "decode"]
Expand Down Expand Up @@ -69,10 +69,10 @@ def engine_config(
)

def router_config(self, local: bool = True, **wired: Any) -> RouterConfig | None:
"""The router process's config, or None without a vllm-router. A ``local`` router fronts the one engine
"""The router process's config, or None without a router. A ``local`` router fronts the one engine
on its host. A router for engines on other nodes binds every interface, and its launcher passes the
engine URLs on the command line once it knows the hosts."""
if not isinstance(self.router, VllmRouterConfig):
if self.router is None:
return None
host = (self.server.host or "0.0.0.0") if local else "0.0.0.0"
worker_host = "localhost" if host == "0.0.0.0" else host
Expand Down Expand Up @@ -116,9 +116,7 @@ def validate_bidirectional_kv_transfer(self):

@model_validator(mode="after")
def validate_router_deployment(self):
"""The llm-d router (EPP + Envoy) is launched by the SLURM templates only; multi-node deployments need a router to front the per-rank engines."""
if self.router is not None and self.router.type == "llm-d" and self.deployment.type == "single_node":
raise ValueError("The llm-d router backend requires a multi-node or disaggregated SLURM deployment.")
"""Multi-node deployments need a router to front the per-rank engines."""
if self.router is None and self.deployment.type in ("multi_node", "disaggregated"):
raise ValueError("Multi-node / disaggregated deployments require a router fronting the per-rank engines.")
return self
Expand Down Expand Up @@ -242,8 +240,11 @@ def router_config(self, local: bool | None = None) -> RouterConfig | None:
"""The router process's config. The router is ``local`` to a single-node deployment."""
deployment = self.deployment
wired: dict[str, Any] = {}
if isinstance(deployment, DisaggregatedInferenceDeploymentConfig) and deployment.bidirectional_kv_transfer:
wired["pd_bidirectional_ttl_s"] = deployment.bidirectional_kv_transfer.effective_router_ttl_s
if isinstance(deployment, DisaggregatedInferenceDeploymentConfig):
if deployment.bidirectional_kv_transfer:
wired["pd_bidirectional_ttl_s"] = deployment.bidirectional_kv_transfer.effective_router_ttl_s
if isinstance(self.router, LlmdRouterConfig):
wired["decode_port"] = deployment.decode_port
return super().router_config(deployment.type == "single_node" if local is None else local, **wired)


Expand Down
4 changes: 2 additions & 2 deletions skills/install/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ Verify: `uv run python -c 'import deep_ep; print(deep_ep.__file__)'`.

### llm-d router backend

Multi-node / disaggregated deployments can route through the upstream llm-d Endpoint Picker instead of `vllm-router` (set `[inference.router] type = "llm-d"`). It needs three native binaries — install once:
Any deployment can route through the upstream llm-d Endpoint Picker instead of `vllm-router` (set `[inference.router] type = "llm-d"`). It needs three native binaries — install once:

```bash
bash scripts/install_llmd.sh # builds epp + pd-sidecar from a pinned llm-d-router commit (vendored Go), fetches envoy
```

Binaries land in `third_party/llmd/bin/{epp,envoy,pd-sidecar}` (a shared path, so SLURM nodes see them). `epp` is pinned to the commit that includes the `vllmhttp-parser` (PR #1248) so prime-rl's renderer/TITO `/inference/v1/generate` path routes correctly. Override the pin with `LLMD_ROUTER_REF=<sha>`. The EPP + Envoy + endpoints configs are rendered from `src/prime_rl/templates/llmd/*.yaml.j2` (included into the SLURM script); only the per-node IPv4 addresses are filled in inline at launch time.
Binaries land in `third_party/llmd/bin/{epp,envoy,pd-sidecar}` (a shared path, so SLURM nodes see them). `epp` is pinned to the commit that includes the `vllmhttp-parser` (PR #1248) so prime-rl's renderer/TITO `/inference/v1/generate` path routes correctly. Override the pin with `LLMD_ROUTER_REF=<sha>`. The router process (`src/prime_rl/components/router.py`) renders the EPP, Envoy and endpoints configs from `router.json` and the engine URLs, and starts `epp` and `envoy` from `third_party/llmd/bin`.

## Key files

Expand Down
Loading
Loading