Repository navigation
feat: always front the engines with a router - #4940
Merged
Merged
Conversation
Every rl, sft and inference deployment now runs a router on server.port and its engines on backend_port. `[inference] router = "None"` is no longer accepted. One topology on every launcher: clients always talk to the router, admin calls always go to the engines, and the launchers and configs lose their no-router branches and the "multi-node needs a router" checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skpulipaka26
approved these changes
Dec 3, 2026
hallerite
approved these changes
Dec 3, 2026
hallerite
approved these changes
Dec 3, 2026
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
## Summary
**Why.** The llm-d router (EPP + Envoy) existed only inside the SLURM
templates. `uv run router` ran vllm-router only. The sbatch rendered the
EPP, Envoy and endpoint YAML from Jinja, then filled in node IPs with
`getent` and `sed`. So llm-d could not run locally, had no
`router.json`, and its configs could not be tested. If a host did not
resolve, the sbatch wrote an empty `address:` and raised no error.
**Idea.** `uv run router @ router.json` runs either backend. For llm-d,
the router process does three things:
1. It renders the three configs in Python, from `router.json` and the
engine URLs on its command line.
2. It resolves each engine host to an IPv4 address.
3. It runs `epp` and `envoy` and exits non-zero when either one exits.
Both backends start the same way:
```bash
# sbatch, inference node 0, for both backends
uv run router @ "$CONFIG_DIR/router.json" --worker-urls http://node-0:8100 http://node-1:8100
```
```json
// router.json for llm-d under P/D
{"router": {"type": "llm-d", "scorers": {...}, "decode_sidecar_port": 8300},
"host": "0.0.0.0", "port": 8000, "decode_port": 8200, "prometheus_port": 29000, ...}
```
- `components()` and `placement()` now include `router` for llm-d too.
- `RouterConfig.router` is the backend union. The new
`RouterConfig.decode_port` lets llm-d map each decode engine to its
pd-sidecar.
- The "llm-d needs a multi-node SLURM deployment" checks are gone.
- `templates/llmd/*.yaml.j2` is deleted. `launch_router` in the sbatch
is one line for both backends. The pd-sidecar launch stays on the decode
nodes.
- `uv run inference` writes `router.json` to its attempt's config dir
and starts the router from it.
- Out of scope: always running a router is #4940, stacked on this PR.
## Breaking
- **sbatch helper.** `launch_router` now takes `<worker_args> <log>`
instead of `<mode> <worker_args> <port> <log>`. `templates/llmd/` is
gone. A custom template that calls either one breaks. Call
`launch_router "$ROUTER_ARGS" <log>`.
- **llm-d EPP metrics port.** The EPP now serves metrics on the router's
`prometheus_port` (`server.port + 21000`, so 29000 by default), not
9090.
- **llm-d endpoint names.** Endpoints are now named `backend-<i>`,
`prefill-<i>` and `decode-<i>`, one per engine URL. Before, they were
`backend-<node>-rank-<k>`.
## Verification
**Same configs as before.** I rendered the deleted Jinja templates (from
`main`) and the new Python configs for a colocated case (2 nodes × 2
ranks) and a P/D case (1 prefill and 1 decode node, 2 ranks each). The
EPP, Envoy and endpoint configs are equal: same addresses, ports,
labels, plugins, profiles and scorer weights. Only the endpoint names
differ.
**Local runs on a 2-GPU box** (RTX PRO 6000; engine on GPU 0, trainer on
GPU 1). The setup is `dev/examples/reverse-text/rl.toml`, 20 steps, with
`--monitors.wandb None`. The vllm-router run also skips the final
checkpoint (`--ckpt None`). On 7885c87:
| Router | Exit | Wall time | Reward, step 10 | Reward, step 20 | Router
log | Router processes left after exit |
| --- | --- | --- | --- | --- | --- | --- |
| `vllm-router` | 0 | 205 s | 0.754 | 0.863 | 7,814 lines | 0 |
| `llm-d` (`--inference.router.type llm-d`) | 0 | 214 s | 0.743 | 0.850
| 7,808 "EPP received request" | 0 |
The llm-d router's temp config dir is gone after the run. I lost the
llm-d run's logs to a full disk on the box. The numbers come from the
run's output, which I read before the disk filled.
**Standalone inference with llm-d.** This ran on the stack tip, with
#4940 applied. #4940 does not change the llm-d path. `uv run inference
--vllm.model PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT --router.type
llm-d`:
- The engine is ready after 35 s.
- A chat completion through Envoy and EPP on port 8000 returns HTTP 200.
- `pkill -x envoy` makes the router exit with code 1, and `inference`
shuts down within 1 s. No `epp`, `envoy` or vLLM process is left.
**SLURM dry run.** `uv run inference --deployment.type disaggregated
--router.type llm-d --slurm.job-name x --dry-run` renders an sbatch that
runs `uv run router @ "$CONFIG_DIR/router.json" $worker_args` and still
starts the pd-sidecar on decode nodes. `router.json` holds the llm-d
settings and `decode_port = 8200`.
**The tests can fail.** Each row removes one piece of this PR:
| Change removed | Result |
| --- | --- |
| `router_config()` builds llm-d (back to `None` for non-vllm-router) |
`test_llmd_pd_router_sends_decode_requests_to_the_sidecar` fails |
| decode endpoints point at the pd-sidecar | same test fails |
| hosts resolve to IPv4 |
`test_llmd_router_runs_epp_and_envoy_from_its_config` fails |
| a clean `epp`/`envoy` exit fails the router |
`test_llmd_router_fails_when_epp_or_envoy_exits[exiting1]` fails |
| the router stops when `epp` or `envoy` exits |
`test_llmd_router_fails_when_epp_or_envoy_exits[exiting0]` fails |
I had no SLURM cluster for this PR. A multi-node or P/D llm-d run on
SLURM has not run yet.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches inference routing for every deployment shape and changes SLURM
launch contracts; misconfiguration could break multi-node/P-D routing
until validated on cluster.
>
> **Overview**
> **Unifies router startup** so `uv run router @ router.json` runs
either **vllm-router** or **llm-d** (EPP + Envoy). For llm-d, the router
process now **generates** `endpoints.yaml`, `epp.yaml`, and `envoy.yaml`
in Python from `router.json` plus CLI engine URLs, **resolves hosts to
IPv4**, and **supervises** `epp` and `envoy` until one exits (non-zero
on failure).
>
> **Removes** the old SLURM-only llm-d path: Jinja templates under
`templates/llmd/` and the branched `launch_router` shell logic. SLURM
now calls the same `uv run router @ "$CONFIG_DIR/router.json"
$worker_args` as local inference.
>
> **Config / validation:** drops validators that blocked llm-d on
single-node; `router_config()` and `components()` include llm-d; adds
`RouterConfig.decode_port` for P/D sidecar port mapping. Local `uv run
inference` writes `router.json` and starts the router subprocess instead
of inlining `vllm-router` argv.
>
> **Breaking:** `launch_router` signature is `<worker_args> <log>` only;
llm-d endpoint naming and EPP metrics port behavior change per PR notes.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7885c87. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
Why.
[inference] router = "None"gaverl,sftandinferencea second topology: a bare engine onserver.port. Configs and launchers carried both shapes:Noneon multi-node and P/D.if config.router_config() is not None.The multi-node and P/D launches already always run a router.
Idea. Every deployment runs a router on
server.port, with its engines onbackend_port.routeris no longer optional:InferenceConfig.components()andplacement()always holdrouter.rlandsfthold it whenever they have an[inference]block.rl,sftandinferencelaunchers always start the router.server.port, so their URLs do not change.Breaking
router = "None"is rejected in[inference]ofrlandsft, and ininference. Remove the line. Clients still connect onserver.port. To reach the engine directly, usebackend_port(server.port + 100by default).uv run inferenceon one node now starts a router onserver.portand the engine onbackend_port. Before,router = "None"served the engine itself onserver.port.model-factory-iacpasses--router Nonetoinference(roles.go). That flag now fails. The operator should runengine @ engine.jsoninstead. Itsinference @ inference.jsonlaunch already broke with the configs split, which merged in feat: resolve each config value in one place #4928.ServingSection.router_config()andInferenceSection.router_config()returnRouterConfig, notRouterConfig | None.Verification
Local runs on a 2-GPU box (RTX PRO 6000; engine on GPU 0, trainer on GPU 1). The setup is
dev/examples/reverse-text/rl.toml, 20 steps, with--monitors.wandb None --ckpt None. Both runs used this branch's tree on 3c366c9d5, which is 3ef3710 applied as a patch:vllm-router(default)llm-dStandalone inference.
uv run inference --router.type llm-don one GPU:inferenceshuts down within 1 s.routeracceptsNoneagaintest_every_engine_runs_behind_a_router_on_the_backend_portfails: did not raiseMerge order
Stacked on #4939 (
feat/llmd-router). Merge that first: it lets the always-on router be llm-d on one node.🤖 Generated with Claude Code
Note
Medium Risk
Changes inference topology and launch behavior (breaking for
router=None); client URLs onserver.portstay the same but operators and IAC that started bare engines need updates.Overview
Inference always uses a router:
[inference].routeris required (VllmRouterConfigby default);router = Noneis rejected. The engine always bindsbackend_portbehind the router onserver.port, androuter_config()/components()/placement()always include a router entry.Simpler wiring: Validators that mandated a router on multi-node SFT/RL/inference and conditional checks when setting
admin_base_urlor launching router processes are removed—those paths now assume a router is always present.Launchers: Local
inference,rl, and SFT always start the router subprocess (no optional bare-engine path). Standaloneuv run inferenceexposes the API on the router port, not directly on the engine.Breaking: Configs that disabled the router must drop
router = None; direct engine access usesbackend_portinstead ofserver.port.Reviewed by Cursor Bugbot for commit 3ef3710. Bugbot is set up for automated code reviews on this repo. Configure here.