Skip to content

Latest commit

 

History

History
494 lines (400 loc) · 24.2 KB

llm-d.md

File metadata and controls

494 lines (400 loc) · 24.2 KB

llm-d Deployment Guide

Benchmark llm-d — a Kubernetes-native distributed inference stack — from madengine.

Overview

llm-d serves a model with vLLM/SGLang model servers behind a Gateway API Inference Extension: an InferencePool plus an Endpoint Picker (EPP) that routes requests with awareness of prefix cache and prefill/decode disaggregation.

madengine's job here is benchmarking, not serving. The benchmark client is an ordinary single-pod, CPU-only Kubernetes Job — the same Job machinery as the k8s target, with the llm-d endpoint injected into its environment. The GPUs belong to the llm-d model servers, not to the client.

flowchart LR
    subgraph cluster["Kubernetes cluster"]
        C["madengine benchmark Job<br/>(1 pod, no GPU)"]
        G["Gateway<br/>+ InferencePool + EPP"]
        P["prefill pods<br/>(GPU)"]
        D["decode pods<br/>(GPU)"]
        C -->|"HTTP /v1/completions"| G
        G --> P
        G --> D
        P -.->|"KV transfer"| D
    end
    C --> R[(perf.csv)]
Loading

Two modes

attach managed
Trigger llm_d.endpoint_url is set llm_d.endpoint_url is null
Who stands the stack up you madengine, via helm
Needs helm on PATH no yes
Tears the stack down never yes, unless teardown: false

Attach mode is the safe default for a shared cluster: madengine cannot install or delete anything belonging to a stack it did not create.

Prerequisites

Both modes:

  • Kubeconfig configured (~/.kube/config or in-cluster)
  • The target namespace must already exist. madengine never creates or deletes a namespace.

Managed mode additionally:

  • A Kubernetes cluster with a GPU device plugin (AMD / NVIDIA). Attach mode has no GPU-node requirement of its own: the GPUs belong to a stack madengine did not install, possibly not even in this cluster; only cluster connectivity and the namespace are checked.

  • helm on PATH

  • Gateway API and Gateway API Inference Extension CRDs, plus a gateway controller watching your gatewayClassName. These are cluster-admin installs; madengine detects them and prints an install hint, but does not install them:

    kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/latest/download/standard-install.yaml
  • Pinned chart versions (see Chart versions)

  • If the model is gated, a Hugging Face token the benchmark client and the cache Job can read. Either create a Secret in the namespace and pass its name as llm_d.model.hf_token_secret (key HF_TOKEN), or set MAD_SECRETS_HFTOKEN or HF_TOKEN on the madengine process. The environment value is stored in a Secret named <job>-hf-token and mounted into the client pod. That Secret is deleted when deployment cleanup runs (a failed run, or Ctrl-C after a deployment id exists); a successful run leaves it in the namespace. The token itself never reaches a values file or a helm command line.

Quick start — attach mode

Point madengine at a gateway you already have:

madengine run --tags my_llm_d_benchmark --additional-context '{
  "k8s": {"namespace": "llm-d-bench", "gpu_count": 0},
  "llm_d": {
    "endpoint_url": "http://llm-d-inference-gateway.llm-d-bench.svc.cluster.local:80",
    "model": {"name": "Qwen/Qwen3-32B"}
  }
}'

MAD_LLM_D_MODEL (and the OpenAI request model field) come from llm_d.model.name. When the selected MAD card has --model_repo <hf_id>, madengine copies that id into llm_d.model.hf_repo and llm_d.model.name if you leave them unset. If you set either field yourself, it must match the card's --model_repo exactly — a short alias such as "Qwen3-32B" with a card that says --model_repo Qwen/Qwen3-32B is rejected. Cards without --model_repo (for example dummy_llm_d) still need an explicit model.name.

The perf.csv Model column stays the MAD card name (for example vllm_disagg_llmd/pyt_vllm_disagg_llmd_qwen3-8b); MAD_LLM_D_MODEL is the served HF id.

The examples on this page use Qwen/Qwen3-32B, deepseek-ai/DeepSeek-R1-0528 and meta-llama/Llama-3.1-8B-Instruct — repos MAD already tracks for standalone vLLM benchmarking (scripts/vllm/models.json). llm-d benchmarks the same repos, served through an external gateway instead of inside the benchmark container.

Quick start — managed mode

madengine run --tags my_llm_d_benchmark --additional-context '{
  "k8s": {"namespace": "llm-d-bench", "gpu_count": 0},
  "llm_d": {
    "model": {"hf_repo": "Qwen/Qwen3-32B", "name": "Qwen/Qwen3-32B", "size": "80Gi", "hf_token_secret": "hf-token"},
    "gateway": "agentgateway",
    "prefill": {"replicas": 2, "tensor_parallel": 8, "gpu_count": 8},
    "decode":  {"replicas": 1, "tensor_parallel": 8, "gpu_count": 8},
    "charts": {
      "infra":        {"version": "<pin>"},
      "gaie":         {"version": "<pin>"},
      "modelservice": {"version": "<pin>"}
    }
  }
}'

What happens:

  1. validate() checks cluster access, GPU nodes, helm, pinned chart versions and CRDs.
  2. prepare() ensures the madengine-shared-data PVC exists if model.uri names it, populates it with model.hf_repo if model.cache_pvc is set (see Model weights: hf_repo vs uri), installs three helm releases in order — *-infra, *-gaie, *-modelservice — then waits for the model-server Deployments and reads the gateway address off the live Gateway resource.
  3. The benchmark client Job is rendered with that endpoint and submitted.
  4. On the way out — success or failure — the three releases are uninstalled.

Which container serves the model

prefill.image/decode.image default to the same image the --tags-selected model builds for every other target — madengine run --tags <model> determines what serves the model here exactly as it does for k8s, not just what benchmarks it. Point --tags at a model whose Dockerfile is itself a serving container (vLLM/SGLang baked in and tuned, pyt_vllm_*-style in scripts/vllm/models.json), and that image — pinned to a digest when require_pinned_image is set, same as every other target — is what the prefill/decode pods run. model.uri/hf_repo still tell that image which weights to load; the Dockerfile supplies the serving stack, not the weights.

Set prefill.image/decode.image explicitly to override this, e.g. to benchmark an upstream vLLM image unrelated to any madengine model build.

If you leave them defaulted, validate() prints a warning naming the image the prefill/decode pods will run. From madengine's side a real serving image and a client-only image are indistinguishable, so it says so rather than guessing.

Model weights: hf_repo vs uri

model.uri is the literal artifact URI the modelservice chart reads. model.hf_repo is shorthand for the common case: set it to an HF repo id and madengine builds hf://<hf_repo> itself. Either way, plain hf:// downloads the model fresh on every standup — the chart's hf:// scheme has no caching of its own.

The chart's pvc:///pvc+hf:// schemes look like a caching mechanism but are not one: they only mount an already-populated PVC by claim name — they contain no download logic. Set model.cache_pvc to a PVC name alongside hf_repo to get real caching: madengine downloads the repo onto that PVC itself, in a one-off Job it runs before helm install (bounded by model.cache_timeout, default 7200 seconds), then points the chart at pvc+hf://<cache_pvc>/hf_hub_cache/<hf_repo>. Re-runs against the same PVC are fast — the download Job still starts, but huggingface_hub.snapshot_download's own per-file check means it re-verifies rather than re-downloads. If cache_pvc is madengine-shared-data, madengine creates the PVC itself (the same PVC the k8s target already manages for datasets; see k8s_pvc.py) so there is something to populate; anything else must already exist. model.cache_job_image overrides the download Job's image (default python:3.11-slim); model.hf_token_secret is reused for the download Job's own HF_TOKEN env var (same Secret and key, HF_TOKEN, the chart itself reads).

An explicit model.uri always wins over hf_repo/cache_pvc, so a raw hf:// or pvc:// URI still works unchanged — set it directly if you'd rather pre-populate a PVC out-of-band (see llm-d-modelservice's own examples/pvc/README.md) instead of using madengine's own download Job.

Always dry-run first

helm template the whole stack and inspect it before spending cluster GPUs:

madengine run --tags my_llm_d_benchmark --additional-context '{
  "k8s": {"namespace": "llm-d-bench", "output_dir": "./k8s_manifests"},
  "llm_d": {"dry_run": true, "model": {...}, "charts": {...}}
}'

This writes llm-d-<component>-values.yaml and llm-d-<component>-manifests.yaml to k8s.output_dir, installs nothing, and submits no Job. It is the way to check the generated values against the chart versions you pinned.

A dry run deliberately runs none of validate()'s cluster checks — the point is to work before the cluster is ready. It needs only a loadable kubeconfig, helm on PATH, and chart versions it can pull. Unpinned versions are still refused.

A managed run that is not a dry run writes the same llm-d-<component>-values.yaml files to k8s.output_dir before installing, so you can always see exactly what was handed to helm.

The benchmark contract

madengine injects these into the client pod; your model's run.sh reads them:

Variable Meaning
MAD_LLM_D_ENDPOINT Base URL of the gateway (OpenAI-compatible)
MAD_LLM_D_MODEL Model name to send in requests
MAD_LLM_D_NAMESPACE Namespace the stack runs in
MAD_LLM_D_PREFILL_REPLICAS Prefill replicas (0 = aggregated serving)
MAD_LLM_D_DECODE_REPLICAS Decode replicas
MAD_LLM_D_TP Decode tensor-parallel size
MAD_LLM_D_RELEASE_PREFIX Helm release stem for this run (the sanitized model name included), not the release_prefix config key alone. Releases are <stem>-infra, <stem>-gaie, <stem>-modelservice. Managed mode only; attach mode sets no releases and so does not set it

The script drives load however it likes — vllm bench serve, guidellm, inference-perf, or plain HTTP — and emits results the way every other madengine model does:

performance: 1234.5 tokens_per_second

or a multiple_results CSV. When the card sets multiple_results, that CSV is preferred over performance: lines in the log (same rule as local Docker and plain Kubernetes).

Reporting stamps llm-d-specific identity on each row: deployment_type=llm-d, launcher=vllm (the model server), and serving_mode=disaggregated|aggregated, plus live prefill/decode topology in the node/GPU columns. See What perf.csv records.

A minimal client:

#!/bin/bash
set -euo pipefail
: "${MAD_LLM_D_ENDPOINT:?not set}"
: "${MAD_LLM_D_MODEL:?not set}"

vllm bench serve \
  --base-url "$MAD_LLM_D_ENDPOINT" \
  --model "$MAD_LLM_D_MODEL" \
  --num-prompts 200 | tee bench.log

throughput=$(grep -oP 'Output token throughput.*?\K[0-9.]+' bench.log)
echo "performance: ${throughput} tokens_per_second"

The client image needs no GPU and no ROCm — a python:3.11-slim base is enough — in attach mode, and in managed mode whenever prefill.image/decode.image are set explicitly. Left defaulted in managed mode, that same image also serves the model and must be a serving container: see Which container serves the model. For the same reason the llm-d preset sets generate_sys_env_details: false: collecting ROCm environment details in a pod with no GPU would only record an empty environment. Set it back to true if you want it anyway.

Configuration reference

Every key below lives under llm_d. Defaults come from src/madengine/deployment/presets/llm-d/defaults.json and are deep-merged under your config, so you only specify what differs.

Key Default Meaning
endpoint_url null Set → attach mode
dry_run false Render values + helm template, install nothing
release_prefix "madengine" Leading segment of the helm release stem. The stem is <prefix>-<sanitized model> when that fits in 40 characters, otherwise <prefix>-llmd-<model tail>. Helm releases are <stem>-infra, <stem>-gaie, and <stem>-modelservice. MAD_LLM_D_RELEASE_PREFIX is that stem
gateway "agentgateway" gatewayClassName and GAIE provider
model.uri null Artifact the servers load, e.g. hf://Qwen/Qwen3-32B. Required in managed mode unless hf_repo is set
model.hf_repo null Simpler alternative to uri: an HF repo id, e.g. Qwen/Qwen3-32B. Resolves to hf://<hf_repo> (re-downloaded every run), or to pvc+hf://<cache_pvc>/hf_hub_cache/<hf_repo> if cache_pvc is also set. Ignored if uri is set
model.cache_pvc null PVC to cache hf_repo onto. madengine downloads it there once, in a Job run before standup, instead of re-downloading every run
model.cache_timeout 7200 Bounds the cache-population Job, seconds
model.cache_job_image null Image for the cache-population Job. Defaults to python:3.11-slim
model.name null Model string in inference requests (MAD_LLM_D_MODEL). Filled from the card's --model_repo when unset; otherwise required. Must match --model_repo when both are set. The perf.csv Model column remains the MAD card name
model.hf_token_secret null Name of an existing Secret holding the HF token (key HF_TOKEN). Also used by the cache-population Job. MAD_SECRETS_HFTOKEN or HF_TOKEN on the madengine process is a separate path: it is copied into <job>-hf-token for the benchmark client
model.size null Size of the model-artifact volume. Required when uri uses the hf:// scheme — the chart sizes an emptyDir download volume from it, and its own default (5Mi) is unusable. Set it comfortably above the model's on-disk size
prefill.replicas 1 0 disables the prefill role (aggregated serving)
prefill.tensor_parallel 1 --tensor-parallel-size
prefill.gpu_count 1 GPUs per prefill pod
prefill.image the --tags-selected model's own built image Override the model-server image
decode.* same shape Decode role
charts.<c>.ref OCI refs Chart location; override for an air-gapped mirror
charts.<c>.version null Must be pinned in managed mode
standup_timeout 1800 Per-release helm --wait timeout, seconds
readiness_timeout 1800 Model-server readiness poll timeout, seconds
teardown true false leaves releases running for debugging
extra_values {} Escape hatch, deep-merged into chart values last

The GPU resource name (amd.com/gpu vs nvidia.com/gpu) comes from k8s.gpu_resource_name, shared with the ordinary Kubernetes target.

One k8s key behaves differently under llm-d: k8s.gpu_count defaults to 0, not 1. The GPUs belong to the llm-d model servers; the benchmark client is a CPU-only load generator, and a client Job that reserves a GPU it never uses competes with the very stack it is measuring. Setting k8s.gpu_count yourself still wins, as do the usual runtime GPU overrides.

That default is applied when the llm_d deployment is constructed and your k8s block does not already contain gpu_count. madengine build merges the ordinary Kubernetes profile first, and that profile sets gpu_count to 1. The saved build_manifest.json then carries 1, and a later madengine run --manifest-file treats the saved value as explicit. Set "gpu_count": 0 in the k8s block you build with, or pass it again on the run command.

Chart versions

Chart versions ship as null and managed mode refuses to run until you pin them. This is deliberate: floating chart versions make benchmark numbers non-reproducible, and let an upstream release change your results without a madengine change.

"charts": {
  "infra":        {"version": "1.3.1"},
  "gaie":         {"version": "1.0.1"},
  "modelservice": {"version": "0.2.9"}
}

Find current versions with helm show chart <ref>.

extra_values

madengine generates the minimum set of chart values that expresses its own config surface. Anything else — and anything madengine models differently than the chart version you pinned — goes in extra_values, which is deep-merged last and therefore wins:

"extra_values": {
  "modelservice": {"modelArtifacts": {"size": "200Gi"}},
  "gaie": {"inferenceExtension": {"replicas": 2}}
}

Nested dicts merge; lists are replaced wholesale. That matters for prefill.containers / decode.containers, which madengine generates as a one-element list holding the image, the --tensor-parallel-size flag and the GPU resource limits. Overriding it replaces all of that, so restate everything you still want:

"extra_values": {
  "modelservice": {
    "decode": {
      "containers": [{
        "name": "vllm",
        "modelCommand": "vllmServe",
        "args": ["--tensor-parallel-size", "8", "--max-model-len", "16384"],
        "resources": {
          "limits":   {"amd.com/gpu": "8"},
          "requests": {"amd.com/gpu": "8"}
        }
      }]
    }
  }
}

Dry-run and read the generated llm-d-modelservice-values.yaml to confirm the result is what you meant.

A bare dict (no infra/gaie/modelservice key) is applied to modelservice, the usual target:

"extra_values": {"routing": {"servicePort": 9000}}

Aggregated (non-disaggregated) serving

Set prefill.replicas to 0. madengine then tells the chart not to create the prefill role at all, and all traffic goes to decode pods:

"prefill": {"replicas": 0},
"decode":  {"replicas": 4, "tensor_parallel": 8, "gpu_count": 8}

What perf.csv records

The benchmark client is one CPU pod, so its own launch settings are not the result. An llm-d row records the serving stack:

Column Value Meaning
deployment_type llm-d Helm-managed llm-d stack. A plain Kubernetes Job stays kubernetes.
launcher vllm Model server. Managed llm-d currently generates modelCommand: vllmServe.
serving_mode disaggregated or aggregated disaggregated when prefill replicas are above 0. aggregated when prefill is disabled. Also shown in the CLI Mode column.

launcher here is the runtime, the same kind of value as torchrun or sglang on a plain Kubernetes job. It is not distributed.launcher, and vllm-disagg is not a launcher name. Topology (4N×1G and so on) stays in the node and GPU columns.

The benchmark client Job uses the shared Kubernetes naming rule: Job metadata.name is capped at 63 characters and equals the pod job-name label (Batch Jobs require that parity). Long MAD card names are hashed/truncated; PVC and ConfigMap names may still append a short suffix under the 253-character subdomain limit.

MI250 / AMD path constraints

Hand-tuned chart values that served this path live under deploy/llm-d/mi250/. When madengine generates values for ROCm clusters it applies the same UCX/NIXL defaults. Practical limits for that topology:

Constraint Detail
1 GPU per model-server pod Defaults and the MI250 values use gpu_count: 1 and tensor_parallel: 1. Large TP=8 cards (Mixtral-8×7B, Qwen3-235B, DeepSeek-class) need a different topology.
No pod RDMA / InfiniBand KV transfer uses NIXL with UCX rocm_copy,rocm_ipc,tcp,self,sm. Functional disagg; not a high-bandwidth RDMA path.
local-path storage Clusters that only expose local-path use hf:// emptyDir downloads (set model.size), not ReadWriteMany PVC caches.
Out of scope here MoRI and WideEP need RDMA-class fabrics and multi-GPU expert-parallel layouts this path does not configure.
MoE on 1×GCD Prefer FP8 MoE weights that fit ~64 GiB HBM with KV (for example Qwen3-30B-A3B-FP8). Dense BF16 ~30B is too tight at TP=1.

Reliability notes

Things worth knowing before you point this at a shared cluster:

  • Nothing is torn down that madengine did not install. Attach mode never uninstalls.
  • The shared-data PVC is never deleted. madengine-shared-data, created on demand for a pvc:///pvc+hf:// model.uri, outlives teardown — that is the point, so a cached model survives to the next run.
  • A failed standup unwinds. If *-modelservice fails, *-gaie and *-infra are uninstalled in reverse order before the error is reported. A half-installed stack holding GPUs is the outcome this is designed to prevent. Set teardown: false to keep the wreckage for debugging instead.
  • Teardown runs on success too. madengine's base deployment only cleans up on failure; the llm-d target adds a try/finally so a successful benchmark does not leak GPU-holding releases.
  • A teardown failure never masks your results. It is logged with the exact helm uninstall command to run by hand, and the benchmark result is returned unchanged.
  • Cache population is a standalone Job. When model.cache_pvc is set, madengine runs a one-off download Job before helm install, bounded by model.cache_timeout. The Job object is deleted after a successful download; only the weights persist on the PVC. A failed or timed-out Job is left in the namespace so kubectl logs job/<name> still works, and the next run deletes it before creating a new one. A failed download unwinds the helm releases like any other standup failure.
  • Readiness is two-stage. helm --wait can return before a model server has finished loading weights, so madengine additionally polls the model-server Deployments. This stage is best-effort on top of helm's own readiness gate: if those Deployments carry unexpected labels, or the API call itself fails (e.g. RBAC forbids listing Deployments), it says so and moves on rather than blocking a run that would otherwise succeed.
  • The endpoint is read, not guessed. It comes from the live Gateway resource's status.addresses, not from a chart naming convention. If the Gateway is ambiguous or has published no address, madengine fails with the reason and tells you to set endpoint_url.
  • Re-runs converge. Releases are installed with helm upgrade --install under names derived from the model, so re-running the same model updates the stack rather than colliding with it.

Troubleshooting

✗ Unpinned llm-d chart versions: gaie, infra, modelservice Set llm_d.charts.<name>.version. See Chart versions.

✗ Missing CRDs required by llm-d Install the Gateway API and GAIE CRDs (cluster-admin), then re-run.

✗ 'helm' not found on PATH Install helm, or use attach mode.

Gateway '...' has not published an address No controller is watching your gatewayClassName, or it is still provisioning. Check kubectl -n <ns> get gateway. Fall back to endpoint_url.

Timed out ... waiting for model-server Deployments to become ready Large models can exceed the 30-minute default. Raise readiness_timeout. llm-d-modelservice v0.4 does not set app.kubernetes.io/instance on the prefill and decode Deployments; their names start with <stem>-modelservice- (<stem> is MAD_LLM_D_RELEASE_PREFIX). Check kubectl -n <ns> get deploy for those names.

Found N Gateway(s) ... and none is identifiably owned by release More than one Gateway in the namespace and none labelled with the infra release. Set endpoint_url explicitly rather than letting madengine benchmark the wrong stack.

✗ Conflicting deployment configuration: both 'llm_d' and 'slurm' present llm-d is Kubernetes-native. Remove the slurm block.

Releases left behind after a crash

helm list -n <namespace>
# <stem> is MAD_LLM_D_RELEASE_PREFIX (it includes the model name), not release_prefix alone.
helm uninstall <stem>-modelservice <stem>-gaie <stem>-infra -n <namespace>

Next Steps