Skip to content

fix: keep GLM-5.2 weight broadcast within GPU memory at 4-node scale - #3199

Open
samsja wants to merge 1 commit into
mainfrom
fix/glm52-broadcast-memory
Open

fix: keep GLM-5.2 weight broadcast within GPU memory at 4-node scale#3199
samsja wants to merge 1 commit into
mainfrom
fix/glm52-broadcast-memory

Conversation

@samsja

@samsja samsja commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

At 4 train nodes the resident FP32 master shards for GLM-5.2 are ~87 GiB/rank. The NCCL weight broadcast gathers each layer's full routed-expert tensors and fp8-quantizes them, transiently peaking ~49 GiB above that — the startup broadcast fit with ~4 GiB to spare, but the post-step broadcast OOMed because ~42 GiB of training transients sat in allocator caches (incl. per-stream pools) the broadcast's default stream could not reuse.

Two changes:

  • torch.cuda.empty_cache() before each in-loop broadcast so cached training pools become reusable (measured: reserved drops 129.7 → 93.9 GiB entering the broadcast).
  • Leaner GLM-5.2 layer conversion in convert_tt_layer_to_vllm_kernel: drop consumed expert tensors eagerly and quantize each expert into preallocated stacks instead of list + torch.stack copies. Per-layer transient peak drops from ~49 GiB to ~31 GiB (measured 135.4 → 117.8 GiB reserved during broadcast).

Validation

GLM-5.2 wordle RL on 8 nodes (4 trainer + 2 prefill + 2 decode disaggregated NIXL), seq_len 8192, cp1/ep8, fp8 trainer quantization, optimizer+gradient CPU offload (#3196), sign_sgd: 20/20 steps with in-loop NCCL broadcasts every step, peak reserved stable at 129.8 GiB, no OOM. Layer-by-layer memory probes confirmed the numbers above.

🤖 Generated with Claude Code

With 4 train nodes the resident FP32 master shards are ~87 GiB/rank and the
per-layer broadcast (full expert gather + fp8 conversion) peaked ~49 GiB above
that, OOMing the post-step broadcast once training transients filled the cache.

- empty_cache() before broadcast so cached training pools are reusable
- drop consumed expert tensors eagerly and quantize into preallocated stacks
  instead of list+torch.stack copies (~49 -> ~31 GiB transient per layer)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant