Skip to content

fix(pd): keep overloaded masters from dropping healthy peers - #1778

Merged
sufubao merged 7 commits into
ModelTC:glm53_optimfrom
sufubao:fix/glm53-pd-master-overload
Dec 3, 2026
Merged

sufubao merged 7 commits into
ModelTC:glm53_optimfrom
sufubao:fix/glm53-pd-master-overload

Conversation

@sufubao

@sufubao sufubao commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A single PD master HTTP worker serves chat requests, P/D registration sockets, and health probes on the same event loop. Synchronous chat template rendering and token counts can delay heartbeat reads under CPU pressure. On a fixed topology, removing a healthy registration after a late local deadline makes /health return 503. The incident logs establish the sequence from missed heartbeats to the failed probe. The initial production stall has no matching stack sample or CPU scheduling trace.

Changes

  • Admit generation and token-count requests before JSON parsing. Hold each slot until the HTTP response or SSE stream ends, including cancellation. Use the existing 429 response format and failure counter for each API.
  • Configure prompt scheduling when the HTTP worker starts. In PD master mode, rendering, token counts, and prefill preparation share a dedicated executor sized from CPU affinity and cgroup quotas. Each manager tokenizer backend is local to its thread. Cancel queued work when its request is cancelled, and count running work until the thread actually finishes.
  • Shed sustained prompt backlog when the worker has less than one CPU or its event loop has recently fallen behind. Sample the loop once per worker. A stalled local loop gives a timed-out registration read one more deadline. A silent peer on a responsive loop still expires after 30 seconds. A disconnect removes the peer immediately.
  • Probe each distinct P/D HTTP address once for fixed-topology health. After the network calls, recheck inference health, readiness and the identity of the registrations. Elastic health uses local state. /liveness runs on the event loop.
  • For HTTP/1.1, consume rejected uploads in chunks before responding. For HTTP/2, send 429 while draining the ASGI input queue so sibling streams can progress. Serving images and PD master startup verify the imported Hypercorn handler. The source-install guides include the pip and uv reinstall steps because the stock and patched packages both report 0.18.0. Pinned Hypercorn commit

Verification at 6007dc88c

  • 210 focused tests passed. The broader selection had 554 passes and the same five failing test IDs as base 9e0c01e43 (three PD abort fixtures and two DSV4 page-size cases). The cancelled-encoding and equal-metadata re-registration regressions both fail on the previous head aab67f60d and pass here.
  • Real PD master, GLM tokenizer, three-CPU quota, and loopback HTTP. Each of three concurrent /tokens request pairs returned 200 with counts of 200000 and 8. The Anthropic token-count route returned 200 for both short and long messages. The pip/uv stock-to-patch upgrade was tested on aab67f60d.
  • Built the FlashKDA/MegaMoE serving image from this commit using verified kernel layers. Its build validators passed. Over loopback TLS, HTTP/1.1 GET and POST /tokens with 64 KiB chunked uploads received complete 429 responses. On a single HTTP/2 connection, an ordinary request received 429, /liveness returned 200, and the already open SSE delivered [DONE].

CPU-limited replay

Each run sent 564 synthetic streaming requests to a real single-worker PD master under a kernel-verified quota of 7500 µs per 100000 µs. The 2P2D peers ran on separate CPUs and simulated GPU output. All runs used the same patched Hypercorn build. Client probes had a three-second deadline. SSE completion required HTTP 200, the final event and no stream error.

LightLLM revision HTTP/1.1 chat client Complete SSE HTTP 429 Other chat outcomes Peer heartbeat closes (1011) Client health / liveness timeouts Server health 503
PR base 9e0c01e43 pooled 53 427 84 13 79 / 72 44
Previous head aab67f60d pooled 59 502 3 0 16 / 10 1
Current head 6007dc88c pooled 60 498 6 0 14 / 10 2
Current head 6007dc88c fresh per chat 76 488 0 0 15 / 9 2

On the PR base, 13 chats received HTTP 500 and 71 hit the client deadline. The previous and current heads were replayed side by side after all 18 P/D registrations were active. All three client connection errors on the previous head and all six on the current head occurred on reused HTTP/1.1 connections. A second current-head run with a fresh chat connection per request completed 76 streams and returned 488 HTTP 429s. The first exploratory current-head run, started as soon as the topology became ready, had 58 complete streams, 496 rate limits, and 10 client connection errors.

The current head kept all 18 P/D registrations in the paired runs. A downstream health request can still fail under this quota, and the server can log 503 after the probing client has timed out. These measurements cover the HTTP worker, its probes and the registration protocol. Production CPU quota, GPU inference and Kubernetes restarts were outside the replay.

Earlier load matrix and peer recovery checks at d213de6

The original overload replay used commit d213de6e5, where 428 focused pytest cases passed in the serving image. The replay used a real single-worker PD master, mock P/D peers on separate CPUs, streamed responses and client-side HTTP probes. Each load group used the same synthetic request sizes and timing. CPU quotas were checked in the kernel.

Build CPU quota Requests Complete SSE HTTP 429 Other chat outcomes Max loop timer gap (s) Peer 1011 Health timeouts / 503 Liveness timeouts
parent 1 282 282 0 0 0.363 0 0 / 0 0
PR 1 282 282 0 0 0.344 0 0 / 0 0
parent 1 564 526 38 0 0.763 0 3 / 0 0
PR 1 564 543 21 0 0.444 0 0 / 0 0
parent 0.075 564 76 436 52 52.207 0 72 / 2 72
PR A 0.075 564 58 506 0 1.000 0 7 / 0 0
PR B 0.075 564 54 510 0 0.897 0 7 / 0 0
parent, affinity 4 0.05 564 6 395 163 57.903 4 87 / 3 87
PR, affinity 4 0.05 564 30 534 0 2.100 0 51 / 0 25
PR, affinity 1 0.05 564 16 548 0 1.303 0 7 / 0 0

At 0.075 CPU the two candidate runs rejected more requests up front and completed fewer chats than the parent. Every candidate chat received a complete stream or an explicit 429. The parent had 52 chat timeouts at that quota. All client-side probe timeouts in this replay used a three-second deadline.

Loss of one deliberately disconnected mock Decode was observed in 0.70–2.03 seconds across five candidate runs. Readiness and health returned 503 with the peer absent, liveness returned 200, and a new chat completed after re-registration without restarting the master. A connected but silent peer received WebSocket 1011 after 30.00 seconds on a healthy loop.

The replay covers the application and its probes. Kubernetes restart behavior and GPU inference are outside this experiment. Under extreme CPU limits, 429 responses, client deadlines and individual probe timeouts still represent real capacity limits.

@sufubao
sufubao merged commit a447350 into ModelTC:glm53_optim Dec 3, 2026
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