* feat(v1): GLM-4.5-Air scaleswe SWE ablation config (router replay)
v1 RL config: GLM-4.5-Air (zai-org/GLM-4.5-Air, 100B MoE) on scaleswe-v1 (train)
+ swebench-verified (eval), bash harness on prime sandboxes. Router replay on
(trainer.enable_router_replay + inference.enable_return_routed_experts).
2 train + 2 infer nodes. Trainer: cp=8 ulysses, muon, + GLM-5.1 prod-run memory
improvements (LM-head chunking, AC + activation offload, optimizer CPU offload,
skip-gather/skip-optimizer ckpt). Inference: 2x tp=8 replicas, NO expert
parallelism (inference EP + router-replay capture deadlocked the engine via
cross-node EP all-to-all). Renderer/parsers auto-resolve from the official slug.
Relies on fixes already in main: the glm4_moe routed_experts .contiguous() slice
(torch.compile stride assert) and the verifiers always-install-uv bootstrap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(slurm): VLLM_CACHE_ROOT=/tmp in multi_node_rl template
vLLM's compile cache defaulted to NFS (~/.cache/vllm), which hung inference
startup on slow shared FS. Point it at node-local /tmp (matching inference.sbatch.j2).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(swe-abl): online fp8 inference + 384 rollout concurrency for glm45air
Inference runs vLLM online fp8 quant (vllm_extra={quantization="fp8"}) over the
bf16 policy for faster generation; trainer/inference/orchestrator all use the
bf16 zai-org/GLM-4.5-Air. The per-channel GLM-4.5-Air-FP8 checkpoint is
incompatible with prime-rl's block-wise fp8 path (use_deep_gemm /
quantize_in_weight_transfer), so we use online quant instead. max_inflight_rollouts=384.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(swe-abl): glm45air-scaleswe -lp variant (default length penalty)
Sibling of glm45air_scaleswe.toml with orchestrator.advantage.length_penalty
enabled at defaults (coef=0.25, gate_by_correctness=false). Distinct slurm
job_name + sandbox labels (glm45air-swe-lp) so it runs alongside the no-penalty
run without sharing prime sandboxes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(swe-abl): bump weight_broadcast timeout to 3600s for cold NFS loads
Cold-cache nodes read the 206GB bf16 model from NFS at ~50s/shard (~46min
total). The weight-broadcast store rendezvous default (1200s/20min) times out
before inference finishes loading (DistStoreError: 1/17 clients joined), killing
the trainer. 3600s covers the cold-load worst case with margin. Applied to both
the base and -lp ablation configs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): kv-offload + fp8, drop router replay, bash_edit
- Drop router replay (trainer.enable_router_replay + inference.enable_return_routed_experts):
mutually exclusive with inference.kv_cache_offload (rl.py validator — external KV cache hits
don't carry routed-expert decisions).
- Enable native KV-cache offloading with a 128GB CPU tier (extends the prefix cache).
- FP8 trainer (DeepGEMM blockwise linear/MoE) — impl=custom is already set.
- Use the bash_edit harness (bash + local edit tool) for train + eval, replacing pure bash.
- Bump max_inflight_rollouts 384 -> 512.
- Keep LM-head token chunking + activation checkpointing explicit at the values that become
trainer defaults in #2867 (not merged yet, so removing them would disable the features).
- Drop the -lp length-penalty variant.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): kv-offload + fp8, drop router replay, bash_edit
- Drop router replay (trainer.enable_router_replay + inference.enable_return_routed_experts):
mutually exclusive with inference.kv_cache_offload (rl.py validator — external KV cache hits
don't carry routed-expert decisions).
- Enable native KV-cache offloading with a 128GB CPU tier (extends the prefix cache).
- FP8 trainer (DeepGEMM blockwise linear/MoE) — impl=custom is already set.
- Use the bash_edit harness (bash + local edit tool) for train + eval, replacing pure bash.
- Bump max_inflight_rollouts 384 -> 512.
- Keep LM-head token chunking + activation checkpointing explicit at the values that become
trainer defaults in #2867 (not merged yet, so removing them would disable the features).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): drop inference fp8 quant to lower mismatch
Run bf16 inference (remove vllm_extra quantization=fp8). fp8 inference added
~10x mismatch KL (~0.002 vs ~0.0002); bf16 inference lowers it. Trainer fp8 +
native KV-cache offload (and the now-disabled router replay) unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): bump context to 131072
seq_len + inference.model.max_model_len 65536 -> 131072.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): revert to 65k ctx, drop kv offload, 384 inflight
- seq_len + inference.model.max_model_len 131072 -> 65536
- Remove inference.kv_cache_offload (native CPU tier)
- max_inflight_rollouts 512 -> 384
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): eval at step 0 (explicit skip_first_step=false)
Make the startup eval explicit so SWE-Bench Verified runs at step 0 before
any train rollouts (already the default; pinned for clarity).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): drop fp8 trainer
Remove trainer.model.fp8 (back to bf16 training).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): bring back router replay
Re-enable trainer.enable_router_replay + inference.enable_return_routed_experts.
Compatible again now that kv-cache offload and fp8 (both mutually exclusive with
router replay) have been dropped; replaying inference's routed-expert decisions in
the trainer cuts the train/inference mismatch by ~an order of magnitude.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): scale inference to 4 nodes / 4 replicas
num_infer_replicas 2 -> 4 (num_infer_nodes is per-replica, so total inference
nodes = num_infer_nodes * num_infer_replicas = 4). Total job = 2 train + 4 infer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): bump max_inflight_rollouts 384 -> 512
Increase orchestrator rollout concurrency to better saturate the 4 inference replicas.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(slurm): node-local FlashInfer JIT cache to avoid weka lock deadlock
FLASHINFER_WORKSPACE_BASE defaulted to $HOME/.cache/flashinfer on shared weka.
With concurrent GLM-4.5-Air/MoE runs every TP worker contends on the same
fused_moe_*.lock there and deadlocks in uninterruptible (D-state) filesystem
I/O during the CUTLASS fused-MoE JIT build, so inference never serves. Pin it
to node-local /tmp like the Triton/vLLM caches.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* glm45air-scaleswe: bump max_steps 400 -> 1000
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): set node-local cache dirs via config env_vars
Move the cache-dir env vars out of the SLURM templates and into the config
so the PR only adds the TOML (the merged env-var feature, #2863, makes this
possible):
- [env_vars] TRITON_CACHE_DIR (trainer + inference)
- [inference.env_vars] VLLM_CACHE_ROOT, FLASHINFER_WORKSPACE_BASE
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* exp(glm45air-scaleswe): migrate renderer preserve_all_thinking -> thinking_retention
Main #2900 replaced the renderer `preserve_all_thinking` bool with
`thinking_retention`; the merge left the config on the removed field, so it
failed the config-load unit test ("No config class could be parsed"). Switch
to `thinking_retention = "all"` (the documented equivalent).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Mika Senghaas <mail@mikasenghaas.de>
Co-authored-by: Mika Senghaas <mika@primeintellect.ai>
* chore: bump vLLM to 0.23.0 and prune/adapt monkeypatches
Bump vllm 0.22.0 -> 0.23.0 (pyproject + regenerated uv.lock).
Remove two now-redundant monkeypatches (verified against 0.23.0 source,
adversarially double-checked):
- monkey_patch_deep_gemm_silu_mul_quant_int64: upstream kernel already uses
int64 pointer arithmetic, so the patch was a behavioral no-op.
- _patch_qwen35_lora (vllm#36372): the Qwen3.5 GDN LoRA IndexError is fixed
natively in vLLM; the patch is redundant and would corrupt the native path.
Adapt two patches the bump moved/changed:
- serving_tokens: get_max_tokens moved out of the deleted vllm.entrypoints.utils
to vllm.entrypoints.serve.utils.api_utils (import-time breakage otherwise).
- monkey_patch_minimax_m2_for_lora: the MoE gate is now GateLinear (was
ReplicatedLinear); rebuild as GateLinear(out_dtype=float32) with a bf16 weight
so the LoRA Triton kernel's bf16/fp16 assertion passes while router logits
stay fp32.
Default VLLM_USE_V2_MODEL_RUNNER=0: vLLM 0.23.0 routes dense Llama/Mistral/Qwen3
to the V2 GPU model runner, which has no _preprocess hook for the padded-input
scrub and does not zero the padded decode tail itself, reproducing NaN logits.
Forcing V1 keeps the scrub effective for every model and is also required for
routed-experts capture. setdefault keeps it overridable.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(inference): cite vllm#44814 as the NemotronH mixer.D reload fix
The _restore_reload_corrupted_params workaround's removal trigger was vague
("once the upstream bug is fixed"). The upstream fix is vllm-project/vllm#44814
(merged 2026-06-10), which is NOT in the pinned 0.23.0 release, so the workaround
is still required. Record the root cause (mixer.A's composed_weight_loader
double-count drops the trailing mixer.D) and the exact removal condition.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(configs): add GLM-5.2 16-node P/D mooncake + llm-d inference config
Standalone `inference` deployment for GLM-5.2-FP8 on 16 nodes: disaggregated
8 prefill (4 replicas) + 8 decode, mooncake distributed CPU KV store, llm-d
router (EPP+Envoy), vLLM 0.23. Requires source-built NIXL/UCX 1.19.x
(scripts/install_nixl_from_source.sh) — the wheel UCX segfaults on P/D KV
transfer. Validated: 1000-req/500-concurrent burst, 0 faults / 0 RPC_FAIL.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(inference): keep Qwen3.5-MoE on 2D per-expert LoRA format
Dropping _patch_qwen35_lora wholesale also removed the
Qwen3_5MoeForConditionalGeneration.is_3d_moe_weight = False override.
vLLM 0.23.0 defaults that flag to True, so the LoRA loader expects 3D
stacked-expert adapters, but our trainer emits the 2D per-expert layout
(MultiLoRAGroupedExperts.state_dict_for_adapter) which vLLM only reads
when is_3d_moe_weight is False (or enable_mixed_moe_lora_format=True).
Without the override Qwen3.5-MoE LoRA adapters fail to load.
Re-add it as a minimal standalone patch. The rest of the old shim
(in_proj_qkvz packed-mapping + N-slice can_replace_layer/slice_lora_a for
vllm#36372) stays removed -- 0.23.0 handles it natively via expand_packed_lora.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(dockerfile): bake NIXL-from-source into base image
The PyPI nixl wheel ships its own UCX that segfaults on prefill->decode KV
transfer (#2883). Rebuild NIXL against the UCX 1.19 we already compile in
the builder stage so the disagg P/D path works without per-host rebuilds.
Adds ~5 min to the amd64 build. arm64 unchanged for now — NIXL upstream
should support it but hasn't been validated here.
* gate NIXL build behind INCLUDE_NIXL_FROM_SOURCE arg
Default off — base build stays identical. The hosted-rl workflow that builds
the disagg P/D variant passes --build-arg INCLUDE_NIXL_FROM_SOURCE=1 (and
should tag-suffix the result, e.g. prime-rl:<ver>-nixl-amd64, to keep image
streams disambiguated).
* fix(dockerfile): seed pip into venv before building NIXL wheel
uv-created venvs don't include pip by default. Mirror install_nixl_from_source.sh
which seeds it via 'uv pip install pip' before invoking 'python -m pip wheel'.
Also swap the final install to 'uv pip install' so we don't depend on the
.venv/bin/pip shim either.
* feat(dockerfile): opt-in disagg extras build (INCLUDE_DISAGG_EXTRAS)
Adds --build-arg INCLUDE_DISAGG_EXTRAS=0 (default) gating --extra disagg
in the uv sync step. The disagg extra installs deep-ep, deep-gemm and
quack — heavy source builds only the disaggregated-MoE inference path
needs (e.g. GLM-5.2 16-node P/D with deepep_high_throughput).
Default off so training-only / single-node inference builds are unaffected.
Enable via --build-arg INCLUDE_DISAGG_EXTRAS=1; pairs with --build-arg
INCLUDE_NIXL_FROM_SOURCE=1 (#2885) for full disagg P/D images.
---------
Co-authored-by: hallerite <git@hallerite.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: faresobeid <fares@primeintellect.ai>
Co-authored-by: Jannik Straube <info@jannik-straube.de>
* refactor: drop client-side DP-rank pinning for external-LB
With external-LB data parallelism each DP rank is its own API server on its
own port (the URL is the rank selector), so the client no longer needs the
hybrid-LB `X-data-parallel-rank` header to pin a rollout to an internal DP
shard. Remove the `dp_rank_count` client field + its auto-setup and the
per-rank client expansion: one client per base URL, no rank header. The
router (vllm-router or llm-d EPP) balances across the per-rank endpoints.
This also fixes llm-d routing: the EPP forwards the header to the dp=1
backend, which rejected it ("data_parallel_rank N is out of range").
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat: llm-d (EPP+Envoy) router backend
Add llm-d as a second router backend alongside vllm-router, selected via
`[inference.deployment.router] type = "llm-d"`. Built on the external-LB
launch substrate — the per-rank vLLM engines launch identically; only the
router control plane differs.
- `LlmdRouterConfig`: discriminated-union member with `scorers` (base) +
per-profile `prefill_scorer_overrides`/`decode_scorer_overrides`,
`non_cached_tokens`, `decode_sidecar_port`, and a known-scorer validator.
- `launch_router` helper gains an llm-d branch: renders per-replica EPP +
Envoy + file-discovery endpoints and launches `epp` + `envoy` instead of
vllm-router. Call sites stay router-agnostic.
- pd-sidecar on each decode node (P/D) for remote-prefill orchestration + NIXL.
- Entrypoints pass the `router` config object to the templates.
- Reject `enable_return_routed_experts` with llm-d (breaks P/D, unverified
for multi-node).
- SLURM cleanup also clears stale `epp`/`envoy`/`pd-sidecar` processes.
- Presets under `templates/llmd/` + `scripts/install_llmd.sh`; docs + install skill.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(inference): mooncake-store + llm-d EPP coexistence on SLURM P/D
- per-rank VLLM_RPC_BASE_PATH: external-LB runs one engine per process (all
data_parallel_rank_local 0), so the mooncake-store lookup ipc socket collided
on a node-shared dir; key it by $port. Also avoids an absent submit-node TMPDIR.
- EPP --grpc-health-port 9003 -> 9013: 9003 collided with mooncake_master's
metrics server on the shared replica-head node, which killed the EPP.
- mooncake_master -default_kv_lease_ttl=3600000: KV blocks were expiring (5s
default) before the decode side reused them.
- envoy circuit_breakers raised to 100000 on backend + epp clusters: the default
(~1024) overflowed at high inflight concurrency -> "reset reason: overflow" 500s.
- pd-sidecar launches on every decode node (not just the replica head), else
decode nodes past the head advertise endpoints nothing serves.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Feat: dockerless llmd install
* chore(configs): add GLM-5.1 llm-d disaggregated RL config
End-to-end RL config used for the GLM-5.1-FP8 llm-d (EPP+Envoy) P/D run:
12 train nodes + 16 inference nodes (8 prefill x2 / 8 decode x2), mooncake KV
store, r2e env. Lives alongside the existing glm5 disaggregated inference preset.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(configs): move GLM-5.1 llm-d RL config to dedicated configs/glm5_llmd/
Relocate the end-to-end GLM-5.1-FP8 llm-d (EPP+Envoy) P/D RL config into its own
configs/glm5_llmd/rl.toml (out of glm5_disagg_inference) and refresh it to the
latest tuned version.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(inference): per-role prefill/decode vLLM overrides for disaggregated P/D
Add `prefill_vllm_overrides` / `decode_vllm_overrides` to the disaggregated
inference deployment config (mirrors the existing `*_env_overrides`): extra
vLLM config options merged into the per-role `--vllm-extra` JSON for prefill
vs decode ranks on SLURM. Rendered via a small `vllm_overrides_fragment` helper
into the `ROLE_EXTRA` string in the inference / multi-node-RL sbatch templates.
Needed by configs/glm5_llmd/rl.toml (sets `decode_vllm_overrides`), which
otherwise fails `extra="forbid"` validation in test_load_configs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(configs): enable prefill dual-batch-overlap in glm5_llmd config
Set prefill_vllm_overrides = {enable_dbo = true} (the inference-side perf knob
tuned during the GLM-5.1 run). Batch size / num-concurrent / node-scale knobs
left as-is — those are run-specific, not portable config.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(configs): tune glm5_llmd prefill/decode replicas (4 prefill / 1 decode)
num_prefill_replicas 2->4, num_decode_replicas 2->1 — the disaggregation split
found to perform best for GLM-5.1 (prefill is the bottleneck; one wide decode
replica maximizes decode KV/batching).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: add GLM-5 llm-d example (16-node / 131K trainer) (#2854)
* docs: add GLM-5 llm-d example (16-node / 131K trainer)
Move the glm5_llmd config from configs/ into examples/glm5_llmd/ with a
README, mirroring the other GLM-5 example. Frame llm-d as the faster
router for GLM-5 and document the placeholders users must tweak
(output_dir, slurm partition, mooncake device_name).
Tune the example for a 16-node trainer: seq_len=131072, num_train_nodes=16,
cp=4, and adamw optimizer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: reword GLM-5 llm-d example entry as one-line SLURM deploy
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: highlight GLM-5 llm-d one-line SLURM deploy in Overview
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Signed-off-by: Matej Sirovatka <54212263+S1ro1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: faresobeid <fares@primeintellect.ai>
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
* fix(inference): tolerate KV-transfer finish for already-freed (aborted) reqs
In disaggregated P/D (NIXL, optionally + a KV store), a request can be finished
— most often FINISHED_ABORTED from an off-policy cancel, client disconnect, or
request timeout — while it still has in-flight KV transfers. When such a
request's finished_recving and finished_sending both arrive in the same
Scheduler.update_from_output step, the stock
Scheduler._update_from_kv_xfer_finished frees it in the recving branch
(_free_blocks -> del self.requests[req_id]) and then the sending branch hits
`assert req_id in self.requests`, killing the EngineCore. On a DP deployment
that one death cascades to every rank via the gloo finish-state all-reduce and
takes down the whole decode pool.
Observed on two llm-d P/D runs: the genuine crash is always one rank asserting
in _update_from_kv_xfer_finished, the rest are gloo "Connection closed by peer"
cascade victims. It is abort-triggered, not pause/resume-related: it reproduced
during normal stepping (~19k log lines after the last resume, engine actively
running model batches) and on a run with max_off_policy_steps=80000 / zero
off-policy cancellations — driven purely by incidental client-side aborts.
Monkey-patch _update_from_kv_xfer_finished to skip request ids no longer in
self.requests instead of asserting. Their blocks are already freed, so dropping
the stale notification is safe. Installed via the vllm.general_plugins entry
point so it applies in the EngineCore process where the Scheduler runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: link upstream vLLM issue #46240 in the KV-xfer patch
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: faresobeid <fares@primeintellect.ai>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The off-policy drain (cancelling rollouts past max_off_policy_steps) ran via
on_new_version *after* the inference engines resumed from the weight-update
pause. In a NIXL P/D deployment this reliably crashed the decode engines.
Aborting a rollout cancels its /generate request; vLLM marks the request
FINISHED_ABORTED and frees it, recording it in the NIXL connector's
_reqs_not_processed set so the worker suppresses its in-flight KV-transfer
completion. That suppression only propagates to the workers while the engine is
stepping. Pausing with mode="keep" (PAUSED_ALL) skips step(), so KV transfers
that complete during the pause are flushed on the first step after resume — at
the same moment the drain fires its aborts. The abort frees the request before
its suppression reaches the worker, so the flushed completion hits
`assert req_id in self.requests` in the decode scheduler's
_update_from_kv_xfer_finished, killing the engine and cascading to every DP
rank via the gloo finish-state all-reduce.
With max_off_policy_steps=8 the first mass drop lands at the 9th weight update,
which is why the run always died at step 8/9.
Move the drain to a new on_version_pending observer hook that the watcher calls
*before* update_weights (before the pause), so the aborts are processed under
normal stepping and the connector's native cleanup completes before the engine
freezes. on_new_version still runs post-update for the orchestrator's dispatch
gate, which needs the live policy version.
Co-authored-by: faresobeid <fares@primeintellect.ai>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The DSA sparse-attention indexer runs its forward under torch.no_grad(), so its
params (wq_b, wk, k_norm, weights_proj) never receive a gradient. They were left
with requires_grad=True and handed to AdamW, which lazily creates per-param state
only on the first step where a grad exists -- so the indexer params stayed
stateless.
This breaks strict checkpoint resume. At save time DCP's _init_optim_state
returns early (optim.state already non-empty), so the stateless indexer params
are omitted from the saved optimizer state. At load time the optimizer is fresh,
so _init_optim_state runs a zero-grad step over every requires_grad param and
materializes exp_avg/exp_avg_sq/step for the indexer too. DCP then demands those
keys, the checkpoint doesn't have them, and load dies with:
RuntimeError: Missing key in checkpoint state_dict:
app.optimizers.state.model.layers.0.self_attn.indexer.wq_b.weight.step
With resume_step=-1 every restart re-picks the same checkpoint and crashes
identically -> crash-loop.
Fix:
- freeze_sparse_indexer(): set requires_grad=False on all Indexer params, called
unconditionally in setup_model (no-op for non-DSA models). The indexer is never
trainable anyway, so this only makes save/load state symmetric.
- _create_optimizer(): hand only trainable params to AdamW/SGD/SignSGD (Muon
already filtered internally), so frozen params carry no optimizer state.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
UCX's --with-verbs silently disables IB when the rdma-core dev headers
are missing, producing a TCP-only build that only fails much later at
runtime with NIXL_ERR_BACKEND. On hosts with RDMA devices, require the
headers before building and verify the rc_verbs transport made it into
the built UCX. Also pass --with-rdmacm so the rdmacm connection manager
is built when available.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
GLOO_SOCKET_IFNAME was hardcoded to bond0 and UCX_NET_DEVICES to all,
both of which break on clusters with different NIC naming or with RDMA
devices UCX cannot open (e.g. a non-functional Ethernet bond, which
fails NIXL backend creation with NIXL_ERR_BACKEND). Derive the gloo
interface from LOCAL_IP and enumerate RDMA ports from sysfs (ibv_devices
is not on the job PATH), preferring InfiniBand, falling back to RoCE,
and keeping "all" on hosts without RDMA devices.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
/resume and /update_weights previously had no retry and no per-attempt
timeout, so a transient failure or stuck server during a weight update
could leave engines paused indefinitely (the admin AsyncClient uses
timeout=None). Factor the /pause retry into a shared _admin_post helper
with a single default timeout, overridable per call; /update_weights
gets a longer one since the collective NCCL receive can take a while.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The dense multi-node external-LB weight-broadcast world size was computed as total_infer_nodes * api_server_count * tp. api_server_count can resolve to the global DP size (e.g. when parallel.dp is set, or via validator ordering), which double-counts the node dimension, so the trainer's NCCL broadcast waits for more ranks than exist and init deadlocks.
Every allocated inference GPU is one NCCL rank, and the external-LB launcher starts dp_per_node TP-sharded servers per node (gpus_per_node workers/node), so size the world directly as total_infer_nodes * gpus_per_node. This matches the disaggregated path.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(slurm): use external-LB everywhere, drop hybrid-LB
Unify every router-fronted vLLM launch path on external load balancing:
one API server per DP rank on PORT+k, each pinned to its TP slice of GPUs,
with the router balancing across the per-rank endpoints. This removes the
hybrid-LB mode (data_parallel_hybrid_lb / data_parallel_start_rank /
--intra-node-data-parallel-size) from both the RL and standalone-inference
SLURM templates, across multi-node and disaggregated (P/D) deployments.
- Extract the duplicated per-rank vLLM launch into a shared
`_launch_rank.sh.j2` helper, included once and called from every launch
site in both templates.
- Build per-rank router worker URLs (BACKEND_PORT+k for multi-node;
PREFILL_PORT+k / DECODE_PORT+k for P/D).
- TP-correct DP group sizing (DP = nodes_per_role_replica * dp_per_node),
fixing the latent tp>1 bug where the disaggregated inference path sized
the group as nodes * gpus_per_node.
- Pass data_parallel_rpc_port + enable_expert_parallel to the multi-node
standalone-inference template so per-rank MoE EP groups rendezvous
node-locally.
- Drop the now-dead USE_DISTRIBUTED_EP gate (EP is decided directly by
enable_expert_parallel).
- Fix a latent apostrophe in a bash -c comment ("can't" -> "cannot") that
broke `bash -n` on multi-node non-disaggregated renders.
- Route DP rank 0 to the node-level log (node_<rank>.log, the target of the
top-level inference.log symlink) via a shared `rank_log` helper, so
inference.log captures real server output again instead of just the preamble;
ranks 1+ keep their own node_<rank>_rank<k>.log.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(slurm): extract router launch into _launch_router helper
Pull the per-replica vllm-router invocation (repeated across the multi-node
and disaggregated launch sites in both templates) into a shared
`_launch_router.sh.j2` helper: `launch_router <mode:pd|regular> <worker_args>
<port> <policy> <log> [replica_idx]`. Call sites now resolve the worker URLs
and call the helper, instead of inlining the `vllm-router` command four times.
This localizes the router launch to one place — a future llm-d (EPP+Envoy)
backend slots in as a single branch inside the helper rather than touching
every call site.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(slurm): per-rank metrics roles + multi-node EP DP coordinator address
Two correctness fixes for the external-LB paths:
- inference_metrics_roles: external-LB exposes one admin client per DP rank,
but the role list was built per node. Expand it per rank
(stride = gpus_per_node / tp) so prefill/decode labels line up with the
per-rank ADMIN_URLS the orchestrator collects metrics from.
- multi-node MoE EP: data_parallel_address was chosen on the global DP rank,
so every local rank after the first on the replica head got the head
hostname instead of the head's own IP — non-zero local ranks on the head
could fail to rendezvous with the DP coordinator when dp_local > 1. Choose
the address per node (head ranks use LOCAL_IP, other nodes use the head
hostname), matching the disaggregated path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduce a `RouterConfig` (currently just `vllm-router`, with `type`/`port`/
`policy`) and put `router: RouterConfig` on `BaseInferenceDeploymentConfig`,
alongside `backend_port`. Previously `router_port`/`router_policy` lived only on
the multi-node / disaggregated deployment types, so the RL launcher needed
`getattr(inference.deployment, "router_port", 8000)` to cover a multi-node
allocation running a single-node inference deployment (e.g. general_agent).
Now every deployment type carries the router config and the launchers read
`deployment.router.port` / `deployment.router.policy` directly. These are
external-LB serving config — only used when the inference is served as a fleet
behind the router (a multi-node allocation, or a standalone multi-node /
disaggregated inference); a co-located single-node server ignores them.
`RouterConfig` is a `type`-discriminated alias (single member for now), so other
router backends can be added to the union without touching call sites. The SLURM
templates are unchanged — the entrypoints still pass the same `router_port` /
`router_policy` template vars — so the rendered scripts are byte-identical.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`validate_multi_node_requires_slurm` only checked `multi_node`, but a
disaggregated (P/D) deployment is equally multi-node (separate prefill/decode
node groups + NIXL) and needs SLURM. Without this, a disaggregated
`InferenceConfig` with no slurm passed validation and fell through to the local
launcher, which cannot run it.
The same `InferenceConfig` is also used nested inside `RLConfig`, where slurm
lives at the top level — so also forward top-level `[slurm]` into the nested
inference (RL P/D, e.g. examples/glm5_pd_disag, sets `[slurm]` but not
`[inference.slurm]`). The per-rank `inference.toml` already excludes `slurm`, so
each rank still runs locally — no SLURM-in-SLURM.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(inference): tiered KV cache offload (native + mooncake, CPU/disk)
Replace the flat `inference.kv_cache_offload` (single `cpu_bytes`) with a typed,
backend-swappable, tiered config discriminated on `type`:
- native: vLLM `OffloadingConnector` (cpu) / `TieringOffloadingSpec` (cpu+disk,
fs_python secondary). Fully self-contained.
- mooncake: per-node standalone-store (`mooncake_master` + `mooncake_client`, RDMA),
cpu and/or disk tiers.
Composable `cpu`/`disk` tiers (cpu required, disk-only rejected); `disk.num_bytes`
is mooncake-only (native fs tier is filesystem-bounded; warns if set on native).
Centralize the vLLM `kv_transfer_config` build in
`InferenceConfig.build_kv_transfer_config` (NIXL transfer + offload composed via
`MultiConnector`); both SLURM templates stop hand-rolling the JSON and launch the
node-local Mooncake store. New `src/prime_rl/inference/mooncake.py` launches the
master+client and writes `MOONCAKE_CONFIG_PATH`; `server.py` brings it up for local
runs.
Verified:
- Single-node (Qwen3-0.6B, H200): all four configs boot + serve; native-cpu and
mooncake-rdma both round-trip KV (store ~1.1GB / reload ~205MB).
- Multi-node 3-node SLURM disaggregated (Qwen3-30B-A3B): NIXL P/D transfer serves
coherent output; with mooncake offload, MultiConnector[Nixl, MooncakeStore] +
per-node RDMA store serves coherent output.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(inference): drop unused mooncake disk num_bytes and metadata_server
- DiskOffloadTier.num_bytes: removed. Neither backend enforces a disk byte quota
(capacity is bounded by the filesystem at disk.path), so it was a no-op knob.
- MooncakeKVCacheOffloadConfig.metadata_server: removed. The launcher always hosts
the HTTP metadata server on the node-local master and auto-derives the URL from the
master host.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(inference): launch Mooncake store in sbatch bash; add CHANGELOG
Address PR review: replace the Python launcher CLI (+ env.sh round-trip) with an
explicit bash launch in the SLURM templates, and document the breaking config change.
- New `templates/_mooncake_store.sh.j2` partial (shared via `{% include %}` by
`inference.sbatch.j2` and `multi_node_rl.sbatch.j2`): launches the node-local
`mooncake_master` + `mooncake_client`, writes the config JSON, and exports
`PYTHONHASHSEED` / `MOONCAKE_CONFIG_PATH` inline — visible in the rendered script.
Removes the hacky orphan-process CLI, the `print`, and the unquoted-`env.sh` round-trip.
- Delete `src/prime_rl/inference/mooncake.py` and the `server.py` store-launch hook.
- Mooncake offload is now SLURM-only: `inference_local` errors (when no store env is
present) and an `RLConfig` validator rejects local RL + mooncake. Native offload is
unchanged and still works locally. Entrypoints pass `kv_offload_{cpu_bytes,disk_path,
device_name}` template vars.
- CHANGELOG.md: document the `inference.kv_cache_offload.cpu_bytes` -> discriminated
`type` breaking change (per .cursor/BUGBOT.md).
Verified single-node SLURM (Qwen3-0.6B): store launches via the template bash,
MooncakeStoreConnector (standalone-store) loads, and the server serves coherent output.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(inference): Mooncake shared distributed KV pool across nodes
Switch the Mooncake offload backend from per-node isolated stores to a single shared
distributed pool, so all inference nodes' CPU RAM (and disk) form one KV cache and a
prefix cached on any node is reusable by every other node/replica.
- `_mooncake_store.sh.j2`: the head inference node (first in the SLURM nodelist) runs the
one master + HTTP metadata server; every node runs a client pointing at the head and
contributes its segment. Store keys are model + parallel-rank + content-hash (no instance
id), so the pool is reused across nodes and replicas.
- Drop the now-unused `MooncakeKVCacheOffloadConfig.master_server_address` (auto head).
- docs: describe the shared pool (total pool ≈ num_bytes × #inference-nodes).
Verified on a 2-node SLURM job (Qwen3-0.6B): one master on the head, both clients join
(2 segments), and a prefix cached on node A is served from node B over RDMA
(load_get ~160 MB cross-node hit).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(inference): drop runtime mooncake-requires-slurm check
The RLConfig `validate_mooncake_offload_requires_slurm` config validator already guards
the misuse case; the per-request runtime check in `inference_local` (and its `import os`)
was redundant. Remove it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Feat: bump vllm to 0.22
* fix: regenerate uv.lock against merged verifiers submodule
The merge commit locked uv.lock while deps/verifiers was still checked out
at the pre-merge commit, so the verifiers package metadata (harnesses/
tasksets editable packages, dropped nltk/textarena) was stale and failed
'uv sync --locked' in CI. Re-locked with the submodule at the merged gitlink.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Support delta-only routed experts replay
* Pin routed experts replay dependencies
* fix(orchestrator): match longest active prefix in interleave_rollout
* Fix: add layerwise as default
* Fix; cleanup
* fix(filesystem): apply layerwise reload to filesystem transport
Mirror the same fix as the NCCL path: replace
`model.load_weights + process_weights_after_loading` with
`load_weights_checkpoint_layerwise`. Without it, MoE
+ filesystem transport hits the same
`Current vLLM config is not set` AssertionError at
`worker/filesystem.py` on the first weight update.
Verified end-to-end on Qwen3-30B-A3B-Thinking-2507 + reverse-text:
filesystem broadcast returns 200 OK, orchestrator step 2 consumed
new weights cleanly (off-policy level 1, reward 0.3583), trainer
steady-state at ~29K tok/s, MFU 21%, no NaN, no errors.
---------
Co-authored-by: hallerite <git@hallerite.com>
* Feat: deep-gemm-fp8
* Feat: cleanup
* nit
* Style
* Feat: works now
* Feat: fp8 grouped gemm works
* Fix: skip unaligned + qwen3.5
* chore(deep_gemm): rebuild d30fc36 wheel against torch 2.11 / cu128
The wheel was built against torch 2.10 + cu128; the merge from main bumped
torch to 2.11.0+cu128 / vllm to 0.20.1, breaking ABI compat with the old
build. Rebuilt via scripts/install_deep_gemm.sh --wheel-dir tools/wheels.
Also updates install_deep_gemm.sh:
- default ref pinned to d30fc36 (was 477618c)
- script header documents the wheel-dir flow used to refresh tools/wheels/
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(deep_gemm): pin to v0.5.0 release URL (uploaded d30fc36 wheel)
The d30fc36 wheel is now hosted on the v0.5.0 GitHub release alongside the
existing 477618c build, so we can drop the local path-based pin.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(fp8): make deep_gemm import optional for CPU-only envs
deep_gemm only ships CUDA wheels; importing prime_rl on a CPU box currently
fails with ImportError before any FP8 path is even touched. Wrap both call
sites in try/except so the import is graceful — actual deep_gemm calls live
inside autograd Function bodies that only run on GPU anyway.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(fp8): wire FP8 grouped GEMM into NemotronH; assert disabled for GPT-OSS
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Signed-off-by: Matej Sirovatka <54212263+S1ro1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: KV cache offloading on both prefill and decode nodes in P/D disaggregated mode
Enable OffloadingConnector on decode nodes (previously prefill-only) and
fix several issues blocking disaggregated P/D with CPU KV cache offloading:
- **Fix CPUOffloadingSpec `num_blocks` miscalculation**: the spec multiplied
`page_size_bytes` by `len(kv_cache_tensors)`, but for
`UniformTypeKVCacheSpecs` the page size already aggregates all layers.
This made `num_blocks` ~156× too small for GLM-5, so pinned CPU tensors
were undersized and `swap_blocks` (`cuMemcpyDtoHAsync_v2`) segfaulted on
out-of-bounds pinned memory. Applied as a monkey-patch via the
`transformers_v5_compat` vLLM plugin.
(upstream: vllm-project/vllm#38395, vllm-project/vllm#39500)
- **OffloadingConnector on decode nodes**: when `kv_cache_offload` is
configured, both prefill and decode now get
`MultiConnector(NixlConnector + OffloadingConnector)`.
- **Router `--intra-node-data-parallel-size`**: was hardcoded to 1 (P/D
disaggregated) or missing (multi-replica), now set to `{{ gpus_per_node }}`
so the router correctly distributes across DP ranks.
- **`ulimit -l`**: raise locked-memory limit early in the sbatch script so
pinned allocations succeed.
- **Router bump**: vllm-router 0.1.14 → 0.1.18 for P/D disaggregation
fixes.
- Removed unused `block_size` pass-through from OffloadingConnector config
(was never read by CPUOffloadingSpec).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: align OffloadingConnector config and router DP across both templates
- Remove unused `block_size` field from KVCacheOffloadConfig and templates
- Add `dp_per_node` template variable (gpus_per_node // tp) for router
`--intra-node-data-parallel-size` (was hardcoded to 1 or missing)
- Align multi_node_rl template with inference template: decode nodes now
get OffloadingConnector when kv_offload is enabled
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: format patches.py and inference config
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: pass dp_per_node to all deployment types, not just disaggregated
The multi_node template branch also uses {{ dp_per_node }} for the
router --intra-node-data-parallel-size flag. Move the variable into the
common template_vars so it's always available.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Some changes
* Fix: ep backends
* Fix: router dp per node
---------
Signed-off-by: Matej Sirovatka <54212263+S1ro1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* bunch of stuff
* Feat: dbo/cpu offloading
* fix: ruff formatting for inference entrypoint and patches
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Revert "Enable none in config (#2093)"
This reverts commit a25b3e7a18.
* Revert "Fix/none in list (#2094)"
This reverts commit 4f612601f6.
* fix conflict
* Enable top_k indices from inference
* Feat; base64
* Feat: more work
* Feat: works now
* Feat: router replay done
* Fix: paths
* Fix: reshape vs view
* Final
* Fix: cp
* fix: config
* Add tests for router replay and fix routed_experts KeyError
- Add unit tests for `_align_routed_experts` (none, empty, no deficit,
deficit padding, excess length)
- Add tests for `interleave_rollout` with routed experts (single-step
alignment, multi-step extension, None passthrough)
- Add tests for `prepare_sample` with routed experts (passthrough,
truncation, None)
- Add GPU test for Qwen3 MoE router replay (forward + backward with
forced expert indices)
- Fix `tokens["routed_experts"]` -> `tokens.get("routed_experts")` in
trajectories.py to avoid KeyError when field is absent
- Fix `_attn_only` tests for afmoe/glm4_moe/qwen3_moe broken by
`routed_experts` kwarg passed to nn.Identity
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* nit
* Fix
* Feat: address comments
* add to minimax and glm moe dsa
* add to minimax and glm moe dsa
* Fix: boundaries
---------
Signed-off-by: Matej Sirovatka <54212263+S1ro1@users.noreply.github.com>
Signed-off-by: samsja <55492238+samsja@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
* feat: add GLM-5 (glm_moe_dsa) custom model with MLA attention
Implement GLM-5 as a custom model following the 4-file convention:
- configuration, modeling, converting, and __init__
- MLA (Multi-head Latent Attention) with LoRA-compressed Q/KV
- Interleaved RoPE support via apply_rotary_pos_emb_interleave()
- Dense attention only (sparse Lightning Indexer is future work)
- Reuses existing MoE, MLP, RMSNorm, and RotaryEmbedding layers
- Weight conversion roundtrip (HF <-> PrimeRL) for MoE experts
- Indexer weights declared but unused for state dict compatibility
- mini_moe.py preset for test model creation
- Unit tests (attn-only, mlp-only, full model + roundtrip)
* feat: add sparse MLA attention with tilelang kernels for GLM-5
Add Dynamic Sparse Attention (DSA) to the glm_moe_dsa model using
vendored tilelang kernels for training fwd+bwd. Includes a bf16
PyTorch indexer (varlen-aware via cu_seqlens) and the absorption
trick to operate in compressed KV latent space (d_qk=576, d_v=512).
* Progress we run against vllm
* Feat: works but slow
* works now i think
* Cleanup
* deps
* Minor changes
* fix minimoe
* To be verified
* Feat: glm5
* Fix: scaling
* Fix more scaling
* FP8 quant
* Scale
* Cleanup: remove banner comments, verbose docstrings, dead code, and broken tests
- Remove license banner, section separators, and shape annotation comments
- Remove unused _weight_scale variable and commented-out code in fp8_indexer
- Trim verbose vendor attribution comments
- Consolidate duplicate warnings in GlmMoeDsaForCausalLM
- Remove broken test file (tests passed wrong kwargs to attention forward)
- Remove sloppy init comment in models/__init__.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* final
* nit
* Fix GlmMoeDsaConfig pad_token_id forwarding
Co-authored-by: Matej Sirovatka <S1ro1@users.noreply.github.com>
---------
Signed-off-by: Matej Sirovatka <54212263+S1ro1@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Matej Sirovatka <S1ro1@users.noreply.github.com>