Skip to content

perf(glm): an idle rank 1 waits on the rendezvous TCP store, not in a spinning all-gather - #132

Closed
MiaAI-Lab wants to merge 1 commit into
ashhart:mainfrom
MiaAI-Lab:pr/glm-idle-doorbell
Closed

MiaAI-Lab wants to merge 1 commit into
ashhart:mainfrom
MiaAI-Lab:pr/glm-idle-doorbell

Conversation

@MiaAI-Lab

@MiaAI-Lab MiaAI-Lab commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: on GLM-5.3-Flash's two-rank CUDA engine, an idle rank 1 no longer busy-waits for the next request. Rank 0 rings a key in the rendezvous TCPStore that NCCL already holds before each request's header; rank 1 blocks on that socket first, then runs the same all-gathers as before. Replies and the request exchange are unchanged.

The problem

Between requests, rank 1 waits for the next request inside the header's all-gather (follow -> _share). That wait is an NCCL kernel spinning on its GPU plus a host thread spinning in the device-to-host copy that waits for it, and it lasts for as long as the server stays idle. On two DGX Sparks serving GLM-5.3-Flash, an idle rank 1 sits at ~96% GPU utilization and ~210% CPU (two cores) with no request in flight: power, heat, and a GPU that other work on that machine can't use.

The change

In families/glm5_next/cuda/engine.py:

  • _ring() (rank 0): right before each request's _share(header), sets tf_glm_request_<n> in self.comm.store, the TCPStore NCCL already creates for the rendezvous.
  • _await_bell() (rank 1): at the top of each follow() iteration, blocks on store.wait([key]), deletes the consumed key, then enters the all-gathers as before.
  • Keys are numbered per request, so a ring sent while rank 1 is still busy with the previous request is not lost.
  • An idle hour's wait timeout is retried; any other store error (rank 0 gone, connection reset) raises instead of waiting forever.
  • Communicators without a store attribute (test fakes) skip the doorbell entirely.

The header, prompt and grammar still go through _share exactly as before; the bell only decides when rank 1 starts waiting on the GPU.

Measurements

  • Before: idle rank 1 at ~96% GPU and ~210% CPU on two DGX Sparks.
  • After (measured on two DGX Sparks serving GLM-5.3-Flash with this change on top of other local patches): idle rank 1 at 0% GPU and ~10% CPU. Replies were unchanged (the same greedy reply hashes for 12k/50k/149k-token prompts, and drafted replies equal to "draft": false). The per-request cost of the extra store round trip (one small TCP set/wait on the rendezvous link) was not measured separately; prefill timings stayed within run-to-run noise.

Tests

  • tests/test_glm_idle_bell.py (CPU only, a real TCPStore on localhost with the two ranks as threads): rank 1 stays blocked until rank 0 rings, then follows 3 requests in order and the consumed keys are deleted; rings sent before rank 1 waits are not lost; idle timeouts are retried and other store errors raise; no store means no doorbell. 4 passed.
  • Checked that torch's real timeout text matches the retry test (DistStoreError: wait timeout after 1000ms, keys: /nope).
  • In tensorfold-glm53:v0.5.0 (NVIDIA PyTorch container, aarch64), pytest tests --ignore=tests/cuda -k 'glm or capacity or geometry or cuda': 1005 passed, 79 skipped. That's the same as unmodified main (1001 passed) plus the 4 new tests. The 2 collection errors (test_alternating_kv.py, test_dflash_tree_search.py) need mlx and fail the same way on main.
  • Not run: the GPU engine tests (tests/cuda/test_glm_*), and a two-rank GLM-5.3-Flash server with this patch.

…ezvous TCP store, not in a spinning all-gather

Between requests GLM-5.3-Flash's rank 1 waited for the next header inside _share's all-gather: an NCCL kernel
spinning on its GPU and a host thread spinning in the copy that waits for it, for as long as the server stayed
idle. On two DGX Sparks an idle rank 1 sat at 96% GPU utilization and ~210% CPU.

Rank 0 now sets a key (tf_glm_request_<n>) in the rendezvous TCPStore that NCCL already holds (NCCL.store)
right before each request's header, and follow() blocks on store.wait for that key first, then enters the
all-gathers as before. Consumed keys are deleted; a wait that times out after an idle hour is retried, any other
store error (rank 0 gone) raises. Communicators without a store skip the doorbell, so the request exchange and
every reply are unchanged.

Tests: tests/test_glm_idle_bell.py (a real TCPStore on localhost, the two ranks as threads: rank 1 blocks until
rank 0 rings and follows every request in order; rings sent before rank 1 waits are not lost; idle timeouts retry
and other errors raise; no store, no doorbell).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014wCj5zx4NuKdUNWUeJi3X1
@ashhart

ashhart commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks for this. Between requests the idle rank was sitting in the collective, at 96% of the GPU and 200% of a core. It now waits on the rendezvous store until the next request arrives, and those idle samples read 0% and 0%. All 20 reply hashes matched. This is in 0.6.0, out tonight.

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.

2 participants