Skip to content

feat: run the llm-d router from router.json - #4939

Merged
mikasenghaas merged 1 commit into
mainfrom
feat/llmd-router
Dec 3, 2026
Merged

mikasenghaas merged 1 commit into
mainfrom
feat/llmd-router

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

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:

# sbatch, inference node 0, for both backends
uv run router @ "$CONFIG_DIR/router.json" --worker-urls http://node-0:8100 http://node-1:8100
// 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 feat: always front the engines with a router #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


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.

Reviewed by Cursor Bugbot for commit 7885c87. Bugbot is set up for automated code reviews on this repo. Configure here.

`uv run router @ router.json` now runs either backend. For llm-d it
renders the EPP, Envoy and endpoint configs in Python from the config
and the engine URLs on its command line, then supervises epp and
envoy. Any exit of either is a router failure.

So llm-d works wherever the router runs: locally, on several nodes
and under P/D. The sbatch templates launch both backends with the
same line and lose the Jinja YAML and the getent/sed address fill. A
host that does not resolve now fails the router instead of writing an
empty address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikasenghaas
mikasenghaas added this pull request to stack #4941 December 3, 2026 22:20
@mikasenghaas
mikasenghaas merged commit adb5936 into main Dec 3, 2026
17 of 18 checks passed
@mikasenghaas
mikasenghaas deleted the feat/llmd-router branch December 3, 2026 22:26
mikasenghaas added a commit that referenced this pull request Dec 3, 2026
## Summary

**Why.** `[inference] router = "None"` gave `rl`, `sft` and `inference`
a second topology: a bare engine on `server.port`. Configs and launchers
carried both shapes:
- The engine port depended on the router.
- The admin URLs were set only with a router.
- Three validators rejected `None` on multi-node and P/D.
- Each launcher started the router behind `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 on `backend_port`. `router` is no longer optional:

```python
# before
router: RouterBackendConfig | None = Field(default_factory=VllmRouterConfig)
def router_config(...) -> RouterConfig | None
# after
router: RouterBackendConfig = VllmRouterConfig()
def router_config(...) -> RouterConfig
```

- `InferenceConfig.components()` and `placement()` always hold `router`.
- `rl` and `sft` hold it whenever they have an `[inference]` block.
- The local `rl`, `sft` and `inference` launchers always start the
router.
- Clients keep `server.port`, so their URLs do not change.

## Breaking

- **`router = "None"` is rejected** in `[inference]` of `rl` and `sft`,
and in `inference`. Remove the line. Clients still connect on
`server.port`. To reach the engine directly, use `backend_port`
(`server.port + 100` by default).
- **`uv run inference` on one node** now starts a router on
`server.port` and the engine on `backend_port`. Before, `router =
"None"` served the engine itself on `server.port`.
- **Operator.** `model-factory-iac` passes `--router None` to
`inference` (`roles.go`). That flag now fails. The operator should run
`engine @ engine.json` instead. Its `inference @ inference.json` launch
already broke with the configs split, which merged in #4928.
- `ServingSection.router_config()` and
`InferenceSection.router_config()` return `RouterConfig`, not
`RouterConfig | 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:

| Router | Exit | Wall time | Reward, step 10 | Reward, step 20 | Router
processes left after exit |
| --- | --- | --- | --- | --- | --- |
| `vllm-router` (default) | 0 | 198 s | 0.752 | 0.838 | 0 |
| `llm-d` | 0 | 196 s | 0.750 | 0.866 | 0 |

**Standalone inference.** `uv run inference --router.type llm-d` on one
GPU:
- The engine on port 8100 is ready after 35 s.
- A chat completion through the router on port 8000 returns HTTP 200.
- When the router dies, `inference` shuts down within 1 s.

| Change removed | Result |
| --- | --- |
| `router` accepts `None` again |
`test_every_engine_runs_behind_a_router_on_the_backend_port` fails: did
not raise |

## Merge 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](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes inference topology and launch behavior (breaking for
`router=None`); client URLs on `server.port` stay the same but operators
and IAC that started bare engines need updates.
> 
> **Overview**
> **Inference always uses a router:** `[inference].router` is required
(`VllmRouterConfig` by default); `router = None` is rejected. The engine
always binds `backend_port` behind the router on `server.port`, and
`router_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_url` or
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). Standalone `uv run
inference` exposes the API on the router port, not directly on the
engine.
> 
> **Breaking:** Configs that disabled the router must drop `router =
None`; direct engine access uses `backend_port` instead of
`server.port`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3ef3710. 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants