Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c2847721a | ||
|
|
9dbe8b5fa0 |
@@ -1,18 +1,18 @@
|
||||
# GLM-5 family at scale
|
||||
|
||||
Large-scale RL and serving for the GLM-5 family — including `zai-org/GLM-5.3-BF16` for training and its `GLM-5.3` block-FP8 serving release — at 131k context: 16 trainer nodes on the custom MoE implementation (expert parallelism; the llm-d variant adds context parallelism) and P/D-disaggregated FP8 inference. The `-llmd` variants front the inference plane with the [**llm-d**](https://llm-d.ai) router (Endpoint Picker + Envoy): its `active-request-scorer` load-balances in flight — instead of reacting to delayed metrics like the default `vllm-router` — which, combined with prefix-cache affinity for grouped rollouts, keeps prefill and decode ranks evenly loaded under RL's bursty request pattern. They also offload KV to a Mooncake distributed CPU pool (1TB per node by default).
|
||||
Large-scale RL and serving for the GLM-5 family — `zai-org/GLM-5.3-BF16` for training and serving alike, quantized to per-block FP8 online on the vLLM side — at 131k context: 16 trainer nodes on the custom MoE implementation (expert + context parallelism) and P/D-disaggregated FP8 inference. The [`swe-llmd.toml`](swe-llmd.toml) append fronts the same inference plane with the [**llm-d**](https://llm-d.ai) router (Endpoint Picker + Envoy): its `active-request-scorer` load-balances in flight — instead of reacting to delayed metrics like the default `vllm-router` — which, combined with prefix-cache affinity for grouped rollouts, keeps prefill and decode ranks evenly loaded under RL's bursty request pattern. It also offloads KV to a Mooncake distributed CPU pool (1TB per node by default).
|
||||
|
||||
| Config | What it runs | Topology |
|
||||
|---|---|---|
|
||||
| [`swe.toml`](swe.toml) | GLM-5 RL plane: 16 train nodes, eval on `swebench-verified` every 20 steps, default vLLM router over 2 P/D replicas (4 prefill + 4 decode nodes each). Declares **no train source** — compose yours on top with an `[[orchestrator.train.source]]` overlay. | 16 train + 16 infer nodes |
|
||||
| [`swe-llmd.toml`](swe-llmd.toml) | Full-stack GLM-5.3 RL: trains on `r2e-gym` (`rlm` harness), FP8-quantized trainer (`deepgemm_fp8` MoE compute), llm-d router + Mooncake KV offload. | 16 train + 16 infer nodes |
|
||||
| [`swe.toml`](swe.toml) | Base GLM-5.3 RL: trains on `r2e-gym` (`rlm` harness), FP8-quantized trainer (`deepgemm_fp8` MoE compute), serves `GLM-5.3-BF16` with online per-block FP8 quantization behind the default `vllm-router`. | 16 train + 16 infer nodes |
|
||||
| [`swe-llmd.toml`](swe-llmd.toml) | Append for `swe.toml`: swaps in the llm-d router (EPP scorer tuning) + Mooncake KV offload — launch as `rl @ swe.toml @ swe-llmd.toml`. | same |
|
||||
| [`infer/pd.toml`](infer/pd.toml) | Inference-only pre-flight: P/D-disaggregated `GLM-5-FP8`. | 6 infer nodes |
|
||||
| [`infer/pd-llmd.toml`](infer/pd-llmd.toml) | Inference-only pre-flight: `GLM-5.2-FP8` with llm-d + Mooncake. | 16 infer nodes |
|
||||
|
||||
## Requirements
|
||||
|
||||
- A Slurm cluster with 8-GPU nodes, a shared filesystem, and at least **32 nodes** (16 trainer + 16 inference) for the RL configs. This guide assumes the shared filesystem is mounted at `/shared` — adjust to your own path. If you have fewer nodes, drop `seq_len`, lower `num_train_nodes`, and reduce `cp` (llm-d variant) accordingly.
|
||||
- InfiniBand/RDMA NICs for the Mooncake KV pool (llm-d variants).
|
||||
- A Slurm cluster with 8-GPU nodes, a shared filesystem, and at least **32 nodes** (16 trainer + 16 inference) for the RL configs. This guide assumes the shared filesystem is mounted at `/shared` — adjust to your own path. If you have fewer nodes, drop `seq_len`, lower `num_train_nodes`, and reduce `cp` accordingly.
|
||||
- InfiniBand/RDMA NICs for the Mooncake KV pool (llm-d append).
|
||||
- **Sandboxes.** Rollout and eval agents run in sandboxes, wired for [Prime Intellect Sandboxes](https://docs.primeintellect.ai/sandboxes/overview) by default. If you use those, install the `prime` CLI separately and log in:
|
||||
|
||||
```bash
|
||||
@@ -25,9 +25,9 @@ prime login # or: prime config set-api-key <your-key>
|
||||
- Environment variables, exported in the shell you launch from — the launcher passes its environment to every component:
|
||||
|
||||
- `HF_TOKEN` — the GLM-5 family checkpoints are gated models.
|
||||
- `WANDB_API_KEY` — both RL configs log to W&B (`[monitors.wandb]`).
|
||||
- `WANDB_API_KEY` — both RL variants log to W&B (`[monitors.wandb]`).
|
||||
|
||||
### Install llm-d (llmd variants only)
|
||||
### Install llm-d (llm-d append only)
|
||||
|
||||
The llm-d router ships as vendored binaries (`epp`, `envoy`, `pd-sidecar`). Build them once into `third_party/llmd/bin`:
|
||||
|
||||
@@ -48,21 +48,20 @@ uv sync --all-extras --all-packages
|
||||
|
||||
## Tweak before launching
|
||||
|
||||
- `swe-llmd.toml` marks two `# FILL IN` values: `output_dir` (point it at your shared filesystem) and `[slurm] partition`. `swe.toml` needs `--slurm.partition <your-partition>` or `--output-dir` overrides on the command line.
|
||||
- `[inference.kv_cache_offload] device_name` — the RDMA NIC list for Mooncake. Auto-detection is unreliable; set it by hand from `nvidia-smi topo -m` on your nodes.
|
||||
- `[inference.kv_cache_offload.cpu] num_bytes` — 1TB per node by default; lower it if your nodes have less RAM.
|
||||
- `swe-llmd.toml` ships without `[ckpt]` — add a checkpoint overlay if you want resume support.
|
||||
- `swe.toml` marks two `# FILL IN` values: `output_dir` (point it at your shared filesystem) and `[slurm] partition`.
|
||||
- `swe-llmd.toml` `[inference.kv_cache_offload] device_name` — the RDMA NIC list for Mooncake. Auto-detection is unreliable; set it by hand from `nvidia-smi topo -m` on your nodes.
|
||||
- `swe-llmd.toml` `[inference.kv_cache_offload.cpu] num_bytes` — 1TB per node by default; lower it if your nodes have less RAM.
|
||||
|
||||
## Start the run
|
||||
|
||||
The `rl` entrypoint submits an sbatch job whenever the config has a `[slurm]` table — there is no separate launcher. From the shared checkout:
|
||||
|
||||
```bash
|
||||
# GLM-5.3 RL with llm-d + Mooncake (recommended)
|
||||
uv run rl @ examples/advanced/glm-5.3/swe-llmd.toml
|
||||
# GLM-5.3 RL behind the default vllm-router
|
||||
uv run rl @ examples/advanced/glm-5.3/swe.toml
|
||||
|
||||
# GLM-5 base plane — compose your train source onto it
|
||||
uv run rl @ examples/advanced/glm-5.3/swe.toml @ my-train-source.toml
|
||||
# with the llm-d router + Mooncake KV offload appended
|
||||
uv run rl @ examples/advanced/glm-5.3/swe.toml @ examples/advanced/glm-5.3/swe-llmd.toml
|
||||
```
|
||||
|
||||
The inference configs are standalone pre-flights: they serve the FP8 checkpoint through the same entrypoint the trainer uses (`/update_weights`, `/load_lora_adapter`, `/init_broadcaster` included — never call `vllm serve` directly), and are a fast way to check that this cluster can serve the model at all before committing it to a run:
|
||||
@@ -98,6 +97,6 @@ Pass several output directories to track parallel experiments side by side (`uv
|
||||
|
||||
## Checkpoint and resume
|
||||
|
||||
`swe.toml` checkpoints every 100 steps (`[ckpt] interval = 100`). To resume, re-run the same command with `--resume` (latest checkpoint) or `--resume.step <N>`, a stable `--run.name`, and a `--max-steps` at least the target final step. Trainer checkpoints are DCP-sharded; export HF-format weights with `tools/convert_dcp_to_bf16.py`. See [Training](../../../docs/training.md) for the full resume and export reference.
|
||||
Both RL configs ship without `[ckpt]` — add a `[ckpt]` overlay (e.g. `interval = 100`) for periodic checkpoints. To resume, re-run the same command with `--resume` (latest checkpoint) or `--resume.step <N>`, a stable `--run.name`, and a `--max-steps` at least the target final step. Trainer checkpoints are DCP-sharded; export HF-format weights with `tools/convert_dcp_to_bf16.py`. See [Training](../../../docs/training.md) for the full resume and export reference.
|
||||
|
||||
See [Scaling](../../../docs/scaling.md) for SLURM details and [Inference](../../../docs/inference.md) for the disaggregated-inference and router reference.
|
||||
|
||||
@@ -1,54 +1,25 @@
|
||||
max_steps = 10000000
|
||||
seq_len = 131072
|
||||
output_dir = "/shared/outputs" # FILL IN: point at your shared filesystem
|
||||
clean = true
|
||||
# llm-d append for swe.toml: fronts the P/D-disaggregated inference plane with
|
||||
# the llm-d router (Endpoint Picker + Envoy) and offloads KV to a Mooncake
|
||||
# distributed CPU pool. Everything else is inherited from the base config:
|
||||
#
|
||||
# uv run rl @ examples/advanced/glm-5.3/swe.toml @ examples/advanced/glm-5.3/swe-llmd.toml
|
||||
|
||||
[run]
|
||||
name = "glm5-llmd"
|
||||
|
||||
[log]
|
||||
level = "debug"
|
||||
|
||||
[monitors.wandb]
|
||||
project = "glm5-llmd"
|
||||
name = "base"
|
||||
|
||||
[weight_broadcast]
|
||||
type = "nccl"
|
||||
port = 29502
|
||||
timeout = 12000
|
||||
[slurm]
|
||||
job_name = "glm5-llmd"
|
||||
|
||||
[deployment]
|
||||
type = "multi_node"
|
||||
num_train_nodes = 16
|
||||
gpus_per_node = 8
|
||||
num_infer_replicas = 1
|
||||
|
||||
[inference.deployment]
|
||||
type = "disaggregated"
|
||||
prefill_nodes_per_replica = 2
|
||||
num_prefill_replicas = 4
|
||||
decode_nodes_per_replica = 8
|
||||
num_decode_replicas = 1
|
||||
|
||||
# skip warmup for faster start in cost of some jit overhead early
|
||||
# ucx needs to be set else random segfaults, vllm can't autoset before importing for some reason
|
||||
[inference.deployment.prefill_env_vars]
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
[inference.deployment.decode_env_vars]
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
# gives the most KV cache while keeping decent throughput, KV cache increase comes in from lower deep-ep LL static buffers
|
||||
[inference.deployment.prefill_vllm_overrides]
|
||||
"enable_dbo" = true
|
||||
|
||||
[inference.deployment.decode_vllm_overrides]
|
||||
"max_num_batched_tokens" = 96
|
||||
"max_num_seqs" = 96
|
||||
# Overlays replace arrays of tables wholesale, so the train source is spelled
|
||||
# out again just to swap the sandbox runtime label.
|
||||
[[orchestrator.train.source]]
|
||||
name = "r2e"
|
||||
env.taskset.id = "r2e-gym"
|
||||
env.agent.harness.id = "rlm"
|
||||
env.agent.runtime.labels = ["glm5-llmd"]
|
||||
|
||||
[inference.router]
|
||||
type = "llm-d"
|
||||
@@ -67,86 +38,6 @@ non_cached_tokens = 128 # if <128 tokens, skip prefill go to decode immediately
|
||||
"kv-cache-utilization-scorer" = 4.0
|
||||
"queue-scorer" = 3.0
|
||||
|
||||
[inference.vllm]
|
||||
# The trainer uses GLM-5.3-BF16; serve the official block-FP8 release.
|
||||
model = "zai-org/GLM-5.3"
|
||||
dtype = "bfloat16"
|
||||
quantization = "fp8_per_block"
|
||||
max_model_len = 131072
|
||||
tool_call_parser = "glm47"
|
||||
reasoning_parser = "glm45"
|
||||
gpu_memory_utilization = 0.75
|
||||
enable_expert_parallel = true
|
||||
enable_eplb = false
|
||||
enable_ep_weight_filter = true
|
||||
safetensors_load_strategy = "prefetch"
|
||||
[slurm]
|
||||
job_name = "glm5-llmd"
|
||||
partition = "all" # FILL IN: set to your cluster's partition
|
||||
|
||||
[trainer]
|
||||
dist_timeout_seconds = 1800
|
||||
|
||||
[trainer.model]
|
||||
name = "zai-org/GLM-5.3-BF16"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_2" # ignored with GLM5
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
cp = 4 # context parallel for the 131K seq len
|
||||
ep = 8
|
||||
|
||||
[trainer.model.quantization]
|
||||
type = "fp8"
|
||||
|
||||
[trainer.model.moe.compute]
|
||||
type = "deepgemm_fp8"
|
||||
|
||||
[trainer.model.ac]
|
||||
freq = 1
|
||||
|
||||
[trainer.model.compile]
|
||||
|
||||
[trainer.model.ac_offloading]
|
||||
max_inflight_activations = 1
|
||||
|
||||
[trainer.optim]
|
||||
type = "adamw"
|
||||
lr = 1e-6
|
||||
weight_decay = 0.0
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 8 # 16/32 can be better, 8 is more CPU stable
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 256
|
||||
max_inflight = 512
|
||||
|
||||
[orchestrator.model]
|
||||
name = "zai-org/GLM-5.3"
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-5.1"
|
||||
clear_thinking = false
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 1.0
|
||||
|
||||
[orchestrator.train.sampling.extra_body.chat_template_kwargs]
|
||||
clear_thinking = false
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "r2e"
|
||||
env.taskset.id = "r2e-gym"
|
||||
env.agent.harness.id = "rlm"
|
||||
env.agent.runtime.labels = ["glm5-llmd"]
|
||||
|
||||
[inference]
|
||||
# <0.80 because glm5 layers are too large for 0.85
|
||||
use_deep_gemm = true
|
||||
enable_fp32_lm_head = true
|
||||
|
||||
[inference.kv_cache_offload]
|
||||
type = "mooncake"
|
||||
# Auto Detection is funky, do it yourself from nvidia-smi topo -m
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
seq_len = 131072
|
||||
# Base GLM-5.3 RL config: P/D-disaggregated FP8 inference behind the default
|
||||
# vllm-router. Serves the same GLM-5.3-BF16 checkpoint the trainer broadcasts,
|
||||
# quantized to per-block FP8 online on the vLLM side. Append swe-llmd.toml to
|
||||
# front the same plane with the llm-d router + Mooncake KV offload:
|
||||
#
|
||||
# uv run rl @ examples/advanced/glm-5.3/swe.toml @ examples/advanced/glm-5.3/swe-llmd.toml
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-5.3-BF16"
|
||||
max_steps = 10000000
|
||||
seq_len = 131072
|
||||
output_dir = "/shared/outputs" # FILL IN: point at your shared filesystem
|
||||
clean = true
|
||||
|
||||
[run]
|
||||
name = "glm5"
|
||||
|
||||
[log]
|
||||
level = "debug"
|
||||
|
||||
[monitors.wandb]
|
||||
project = "glm5-pd-disag"
|
||||
project = "glm5"
|
||||
name = "base"
|
||||
|
||||
[weight_broadcast]
|
||||
type = "nccl"
|
||||
@@ -18,36 +29,72 @@ timeout = 12000
|
||||
type = "multi_node"
|
||||
num_train_nodes = 16
|
||||
gpus_per_node = 8
|
||||
num_infer_replicas = 2
|
||||
num_infer_replicas = 1
|
||||
|
||||
[inference.deployment]
|
||||
type = "disaggregated"
|
||||
prefill_nodes_per_replica = 4
|
||||
decode_nodes_per_replica = 4
|
||||
prefill_nodes_per_replica = 2
|
||||
num_prefill_replicas = 4
|
||||
decode_nodes_per_replica = 8
|
||||
num_decode_replicas = 1
|
||||
|
||||
# skip warmup for faster start in cost of some jit overhead early
|
||||
# ucx needs to be set else random segfaults, vllm can't autoset before importing for some reason
|
||||
[inference.deployment.prefill_env_vars]
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
[inference.deployment.decode_env_vars]
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
# gives the most KV cache while keeping decent throughput, KV cache increase comes in from lower deep-ep LL static buffers
|
||||
[inference.deployment.prefill_vllm_overrides]
|
||||
"enable_dbo" = true
|
||||
|
||||
[inference.deployment.decode_vllm_overrides]
|
||||
"max_num_batched_tokens" = 96
|
||||
"max_num_seqs" = 96
|
||||
|
||||
[inference.router]
|
||||
type = "vllm-router"
|
||||
|
||||
[inference.vllm]
|
||||
# Serve the shared BF16 checkpoint above with online per-block FP8 quantization.
|
||||
# Serve the same GLM-5.3-BF16 checkpoint the trainer broadcasts; vLLM quantizes
|
||||
# it to per-block FP8 online.
|
||||
model = "zai-org/GLM-5.3-BF16"
|
||||
dtype = "bfloat16"
|
||||
quantization = "fp8_per_block"
|
||||
max_model_len = 131072
|
||||
tool_call_parser = "glm47"
|
||||
gpu_memory_utilization = 0.80
|
||||
reasoning_parser = "glm45"
|
||||
gpu_memory_utilization = 0.75
|
||||
enable_expert_parallel = true
|
||||
enable_eplb = false
|
||||
enable_ep_weight_filter = true
|
||||
safetensors_load_strategy = "prefetch"
|
||||
[slurm]
|
||||
job_name = "glm5-pd-disag"
|
||||
|
||||
[ckpt]
|
||||
interval = 100
|
||||
job_name = "glm5"
|
||||
partition = "all" # FILL IN: set to your cluster's partition
|
||||
|
||||
[trainer]
|
||||
dist_timeout_seconds = 7200
|
||||
dist_timeout_seconds = 1800
|
||||
|
||||
[trainer.model]
|
||||
name = "zai-org/GLM-5.3-BF16"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_2" # dsa is skipping flash attn anyway
|
||||
fused_lm_head_token_chunk_size = 2048
|
||||
attn = "flash_attention_2" # ignored with GLM5
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
cp = 4 # context parallel for the 131K seq len
|
||||
ep = 8
|
||||
|
||||
[trainer.model.quantization]
|
||||
type = "fp8"
|
||||
|
||||
[trainer.model.moe.compute]
|
||||
type = "deepgemm_fp8"
|
||||
|
||||
[trainer.model.ac]
|
||||
freq = 1
|
||||
|
||||
@@ -56,35 +103,40 @@ freq = 1
|
||||
[trainer.model.ac_offloading]
|
||||
max_inflight_activations = 1
|
||||
|
||||
[trainer.ckpt]
|
||||
skip_optimizer = true
|
||||
|
||||
[trainer.optim]
|
||||
type = "adamw"
|
||||
lr = 1e-6
|
||||
weight_decay = 0.1
|
||||
weight_decay = 0.0
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 4096
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 16
|
||||
max_off_policy_steps = 8 # 16/32 can be better, 8 is more CPU stable
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 4096
|
||||
max_inflight = 8192
|
||||
initial_inflight = 256
|
||||
max_inflight = 512
|
||||
|
||||
[orchestrator.model]
|
||||
name = "zai-org/GLM-5.3-BF16"
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-5.1"
|
||||
name = "glm-5.3"
|
||||
clear_thinking = false
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 1.0
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swe-bench-verified"
|
||||
env.taskset.id = "swebench-verified"
|
||||
env.agent.harness.id = "bash"
|
||||
env.agent.runtime.labels = ["glm5-pd-disag", "swe-bench-verified"]
|
||||
[orchestrator.train.sampling.extra_body.chat_template_kwargs]
|
||||
clear_thinking = false
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "r2e"
|
||||
env.taskset.id = "r2e-gym"
|
||||
env.agent.harness.id = "rlm"
|
||||
env.agent.runtime.labels = ["glm5"]
|
||||
|
||||
[inference]
|
||||
# we need <0.85 bc glm5 layers are too large for 0.85
|
||||
# <0.80 because glm5 layers are too large for 0.85
|
||||
use_deep_gemm = true
|
||||
enable_fp32_lm_head = true
|
||||
|
||||
Reference in New Issue
Block a user