Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
23 changes: 14 additions & 9 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ class SweepOrchestrator(WorkerStageMixin, FrontendStageMixin, BenchmarkStageMixi
def run(self) -> int:
"""Run the complete benchmark sweep."""
# Stage 1: Start head infrastructure (NATS, etcd)
# (skipped for frontend.type: vllm or trtllm_serve)
# Stage 2: Start backend workers
# Stage 3: Start frontends
# Stage 3: Start frontends (no-op for frontend.type: vllm — worker owns the port)
# Stage 4: Run benchmark
# Cleanup
```
Expand Down Expand Up @@ -356,6 +357,8 @@ src/srtctl/frontends/
|-- base.py # FrontendProtocol definition
|-- dynamo.py # DynamoFrontend (NATS/etcd)
|-- sglang.py # SGLangFrontend (direct router)
|-- trtllm_serve.py # TRTLLMServeFrontend (disagg TRT-LLM orchestrator)
|-- vllm.py # VLLMFrontend (direct aggregate vllm serve)
```

#### FrontendProtocol
Expand Down Expand Up @@ -444,14 +447,14 @@ src/srtctl/core/
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| FRONTEND LAYER |
+------------------------------------------------------------------+
| FrontendProtocol | DynamoFrontend | SGLangFrontend|
| - start_frontends() | - /health | - /workers |
| - parse_health() | - NATS/etcd | - Direct conn |
| - health_endpoint | | |
+------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------+
| FRONTEND LAYER |
+----------------------------------------------------------------------------------------------+
| FrontendProtocol | DynamoFrontend | SGLangFrontend | TRTLLMServe | VLLMFrontend |
| - start_frontends() | srun process | srun process | srun process | (no process) |
| - parse_health() | NATS/etcd | direct workers | /health | /health |
| - health_endpoint | /health | /workers | /health | agg leader node |
+----------------------------------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
Expand Down Expand Up @@ -1070,6 +1073,8 @@ src/srtctl/
| |-- base.py # FrontendProtocol definition
| |-- dynamo.py # DynamoFrontend (NATS/etcd)
| |-- sglang.py # SGLangFrontend (direct router)
| |-- trtllm_serve.py # TRTLLMServeFrontend (disagg orchestrator)
| |-- vllm.py # VLLMFrontend (direct aggregate vllm serve)
|
|-- cli/ # CLI entry points
| |-- __init__.py
Expand Down
102 changes: 100 additions & 2 deletions docs/config-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Frontend/router configuration.

```yaml
frontend:
# Frontend type: "dynamo" (default), "sglang", or "trtllm_serve"
# Frontend type: "dynamo" (default), "sglang", "trtllm_serve", or "vllm"
type: dynamo

# Scaling
Expand All @@ -294,7 +294,7 @@ frontend:

| Field | Type | Default | Description |
| --------------------------- | ---- | ------------- | ----------------------------------- |
| `type` | str | dynamo | Frontend type: "dynamo", "sglang", or "trtllm_serve" |
| `type` | str | dynamo | Frontend type: "dynamo", "sglang", "trtllm_serve", or "vllm" |
| `enable_multiple_frontends` | bool | true | Scale with nginx + multiple routers |
| `num_additional_frontends` | int | 9 | Additional routers beyond master |
| `nginx_container` | str | nginx:1.27.4 | Custom nginx container image |
Expand All @@ -319,6 +319,104 @@ supported). A recipe can be switched between the two TRT-LLM serving stacks by
changing only `frontend.type` between `dynamo` and `trtllm_serve`. See the sample
recipe `recipes/trtllm/b200-fp8/1k1k/stp/ctx1_gen3_tp8_batch1024_eplb0_mtp0_4_trtllm_serve.yaml`.

### vllm frontend

`type: vllm` runs aggregate vLLM jobs **without Dynamo**. The OpenAI-compatible
HTTP server is the aggregate `vllm serve` worker itself — there is no separate
router/frontend process, and srtctl skips NATS/etcd startup.

Use this for aggregate throughput benchmarks where Dynamo orchestration is not
needed. Disaggregated prefill/decode layouts still require a real router such as
Dynamo (`frontend.type: dynamo`).

**Requirements**

| Constraint | Value |
| ---------- | ----- |
| `backend.type` | `vllm` |
| Job layout | Aggregate only; no prefill/decode workers |
| `agg_workers` | Exactly `1` — scale across nodes with `agg_nodes`, not with replicas |
| `enable_multiple_frontends` | `false` (nginx + multi-router path is unsupported) |

Nothing load-balances between aggregate endpoints here, so `agg_workers: 2` is
rejected at load time: the extra replica would either idle behind the single
public address or collide on the port. Use `frontend.type: dynamo` when you want
several aggregate replicas behind one endpoint.

**Single-node example**

```yaml
frontend:
type: vllm
enable_multiple_frontends: false

resources:
agg_nodes: 1
agg_workers: 1
gpus_per_node: 8

backend:
type: vllm
vllm_config:
aggregated:
tensor-parallel-size: 8
```

**Multi-node example (TP/PP across nodes)**

```yaml
frontend:
type: vllm
enable_multiple_frontends: false

resources:
agg_nodes: 2
agg_workers: 1
gpus_per_node: 8

backend:
type: vllm
vllm_config:
aggregated:
tensor-parallel-size: 8
pipeline-parallel-size: 2
```

srtctl launches one `vllm serve` process per node. The endpoint leader
(`node_rank=0`) binds the public OpenAI port; follower ranks run headless engine
workers. Multi-node coordination flags (`--master-addr`, `--nnodes`,
`--node-rank`, `--headless`) are derived from the allocated topology — **do not
set them in the recipe**.

`master-port` / `master_port` remains an optional recipe override and is passed
to every node rank. Set it when jobs may share a leader node and need distinct
vLLM rendezvous ports; otherwise vLLM's default is used.

**Topology-managed `vllm_config` keys**

The following keys are owned by srtctl and are stripped at runtime if present in
`vllm_config.{aggregated,prefill,decode}`:

- `headless`
- `host`, `port`
- `master-addr` / `master_addr`
- `nnodes`
- `node-rank` / `node_rank`

Existing recipes that still contain these keys generally continue to work
because the values are ignored. One exception is `headless` combined with
`dp_launch_mode: per_node` and `data-parallel-size`: backend validation rejects
that combination before direct-vLLM command construction, so remove `headless`
from such recipes. `srtctl dry-run` emits a **WARNING** for each accepted key so
operators can clean up recipes over time.

Health checks, benchmark clients, and `SRT_FRONTEND_HOST` target the **aggregate
endpoint leader** (the node running the public `vllm serve`), not necessarily the
Slurm head node.

Compare with `frontend.type: dynamo` + `backend.type: vllm`, which keeps Dynamo as
the request router and uses `python3 -m dynamo.vllm` workers with NATS/etcd.

---

## backend
Expand Down
147 changes: 118 additions & 29 deletions src/srtctl/backends/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,79 @@

logger = logging.getLogger(__name__)

# vLLM CLI flags srtslurm derives for the direct vLLM frontend. Recipes may
# still set these for backward compatibility; dry-run warns and direct-vLLM
# command building strips them so user values cannot override allocation.
_VLLM_ORCHESTRATION_FLAGS = frozenset(
{
"headless",
"host",
"port",
"master-addr",
"nnodes",
"node-rank",
}
)


# vLLM CLI flags that only apply where the OpenAI API server runs. Headless node
# ranks host engine workers only, and vLLM rejects a positive --api-server-count
# there instead of ignoring it.
_VLLM_API_SERVER_ONLY_FLAGS = frozenset({"api-server-count"})


def normalize_vllm_config_key(key: str) -> str:
"""Normalize a vllm_config dict key to kebab-case CLI flag form."""
return str(key).replace("_", "-")


def _pop_flags(config: dict[str, Any], flags: frozenset[str]) -> list[str]:
found: list[str] = []
for key in list(config.keys()):
normalized = normalize_vllm_config_key(key)
if normalized in flags:
config.pop(key)
if normalized not in found:
found.append(normalized)
return found


def pop_vllm_orchestration_flags(config: dict[str, Any]) -> list[str]:
Comment thread
arpera marked this conversation as resolved.
Resolved
"""Remove topology-managed vLLM flags from a mode config dict.

Returns normalized flag names that were present.
"""
return _pop_flags(config, _VLLM_ORCHESTRATION_FLAGS)


def pop_vllm_api_server_flags(config: dict[str, Any]) -> list[str]:
"""Remove API-server-only vLLM flags from a mode config dict.

Returns normalized flag names that were present.
"""
return _pop_flags(config, _VLLM_API_SERVER_ONLY_FLAGS)


def find_vllm_orchestration_recipe_flags(backend: VLLMProtocol) -> list[tuple[str, str]]:
"""Return ``(mode, flag)`` pairs set in recipe ``vllm_config``."""
if backend.vllm_config is None:
return []

findings: list[tuple[str, str]] = []
for mode_name, mode_config in (
("prefill", backend.vllm_config.prefill),
("decode", backend.vllm_config.decode),
("aggregated", backend.vllm_config.aggregated),
):
if not mode_config:
continue
for key in mode_config:
normalized = normalize_vllm_config_key(key)
if normalized in _VLLM_ORCHESTRATION_FLAGS:
findings.append((mode_name, normalized))
return findings


# Filename for the mooncake-store JSON config srtslurm writes to log_dir at job
# start. log_dir is mounted into every worker at /logs, so workers read the JSON
# from MOONCAKE_STORE_CONFIG_CONTAINER_PATH.
Expand Down Expand Up @@ -205,10 +278,10 @@ class VLLMProtocol:

Schema: ClassVar[builtins.type[Schema]] = Schema

def __post_init__(self) -> None:
"""Validate flags whose behavior is fixed by the per-node launch topology."""
def find_dp_modes(self) -> list[tuple[str, dict[str, Any]]]:
"""Return ``(mode, config)`` pairs whose recipe config sets data-parallel-size."""
if self.vllm_config is None:
return
return []

dp_mode_configs: list[tuple[str, dict[str, Any]]] = []
for mode_name, mode_config in (
Expand All @@ -221,17 +294,15 @@ def __post_init__(self) -> None:
for key, value in mode_config.items()
):
dp_mode_configs.append((mode_name, mode_config))
return dp_mode_configs

if not dp_mode_configs:
return
def __post_init__(self) -> None:
"""Validate flags whose behavior is fixed by the per-node launch topology."""
dp_mode_configs = self.find_dp_modes()

if self.dp_launch_mode == "per_gpu":
modes = ", ".join(mode_name for mode_name, _ in dp_mode_configs)
logger.warning(
"vLLM DP mode(s) %s use dp_launch_mode=per_gpu. per_node is the recommended topology "
"and will become the default in a future release; set backend.dp_launch_mode: per_node now",
modes,
)
# The per_gpu advisory lives in SrtConfig, which can tell whether the
# setting applies at all: a direct vLLM frontend ignores it.
if not dp_mode_configs or self.dp_launch_mode == "per_gpu":
return

hybrid_lb_modes: list[str] = []
Expand Down Expand Up @@ -689,8 +760,13 @@ def build_worker_command(
endpoint_nodes = list(dict.fromkeys(p.node for p in endpoint_processes))
is_multi_node = len(endpoint_nodes) > 1

# Get leader IP for distributed init
leader_ip = get_hostname_ip(endpoint_nodes[0])
# Direct vLLM rendezvous must use the configured interface. Keep the
# existing Dynamo resolution path unchanged to avoid affecting jobs
# outside the scope of the direct-vLLM frontend.
if frontend_type == "vllm":
leader_ip = get_hostname_ip(endpoint_nodes[0], runtime.network_interface)
else:
leader_ip = get_hostname_ip(endpoint_nodes[0])

# Determine model path: HF model ID or container mount path
# For HF models (hf:prefix), model_path contains the HF model ID (e.g., "facebook/opt-125m")
Expand All @@ -717,25 +793,38 @@ def build_worker_command(
if frontend_type == "vllm":
if mode != "agg":
raise ValueError("frontend.type: vllm supports aggregate vLLM jobs only")
if is_multi_node:
raise ValueError("frontend.type: vllm currently supports single-node aggregate jobs only")

config.pop("host", None)
config.pop("port", None)
pop_vllm_orchestration_flags(config)
config.pop("connector", None)
config.setdefault("served-model-name", served_model_name)

cmd.extend(
[
"vllm",
"serve",
model_arg,
"--host",
"0.0.0.0",
"--port",
str(runtime.frontend_port),
]
)
node_rank = endpoint_nodes.index(process.node)
cmd.extend(["vllm", "serve", model_arg])
if node_rank == 0:
cmd.extend(["--host", "0.0.0.0", "--port", str(runtime.frontend_port)])
if is_multi_node:
# vLLM-native multi-node serve (torchrun-style): the leader owns
# the OpenAI server; other node ranks run headless engine workers.
cmd.extend(
[
"--master-addr",
leader_ip,
"--nnodes",
str(len(endpoint_nodes)),
"--node-rank",
str(node_rank),
]
)
if node_rank > 0:
cmd.append("--headless")
dropped = pop_vllm_api_server_flags(config)
if dropped:
logger.info(
"Dropping %s on headless node rank %d (%s); API-server flags apply to rank 0 only",
", ".join(f"--{flag}" for flag in dropped),
node_rank,
process.node,
)
if not self.set_cuda_visible_devices:
device_ids = ",".join(str(i) for i in sorted(process.gpu_indices))
if device_ids:
Expand Down
6 changes: 3 additions & 3 deletions src/srtctl/cli/do_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def _print_connection_info(self) -> None:
logger.info("=" * 60)
logger.info("Connection Commands")
logger.info("=" * 60)
logger.info("Frontend URL: http://%s:%d", self.runtime.nodes.head, FRONTEND_PUBLIC_PORT)
logger.info("Frontend URL: http://%s:%d", self._public_api_node(), FRONTEND_PUBLIC_PORT)
logger.info("")
logger.info("To connect to head node (%s):", self.runtime.nodes.head)
logger.info(
Expand Down Expand Up @@ -548,7 +548,7 @@ def _run_post_eval(self, stop_event: threading.Event) -> int:
hc = self.config.health_check
logger.info("EVAL_ONLY: Waiting for server health before eval...")
if not wait_for_model(
host=self.runtime.nodes.head,
host=self._public_api_node(),
port=FRONTEND_PUBLIC_PORT,
n_prefill=n_prefill,
n_decode=n_decode,
Expand All @@ -561,7 +561,7 @@ def _run_post_eval(self, stop_event: threading.Event) -> int:
logger.error("Server did not become healthy for eval")
return 1
else:
if not wait_for_port(self.runtime.nodes.head, FRONTEND_PUBLIC_PORT, timeout=30):
if not wait_for_port(self._public_api_node(), FRONTEND_PUBLIC_PORT, timeout=30):
logger.error("Server health check failed before eval - skipping")
return 1

Expand Down
Loading
Loading