Repository navigation
feat(atom): GLM-5.2 ATOM on nightly_202610131505 (LMCache GTT pool, DCP pad-row fix), PP4 prefill 4P4D kit, ATOM router support - #198
Merged
Conversation
… ROCm pool and DCP sparse pad rows Rebase the opt-in ATOM image from nightly_202609221542 (ATOM d9f0720) onto rocm/atom-dev:nightly_202610131505 (ATOM 661ef766, LMCache 0.5.6.dev139). The build arg ATOM_DCP_PATCHES / patches/atom_dcp becomes ATOM_NIGHTLY / patches/atom_nightly: the base is an ATOM nightly, so the legacy patches/atom loop (written for the default release base) is skipped and the strict scripts run instead. The default build (ATOM_NIGHTLY=0) is unchanged. - Drop patch_dcp_prefill_mtp_metadata (upstream #2430; fails on the new base), patch_lmcache_lookup_pin (LMCache#5098 is in the base) and patch_moe_eager_decode_pad (DP attention only, unused by the DCP kits). - Keep the AITER mha_varlen prebuild and the protobuf<7 pin. On gfx950 this nightly loads the ASM fmha_v3 varlen module instead; the prebuild stays for gfx942. - patch_lmcache_rocm_pinned_alloc.py: with LMCACHE_NUMA_MODE the LMCache CPU pool is mmap + mbind + hipHostRegister, a KFD USERPTR mapping whose pages the kernel may migrate; each migration evicts every GPU queue of the process (15-110 s stalls measured on a 256 GiB pool). With HSA_USERPTR_FOR_PAGED_MEM=0 the pool now uses LMCache's exact-size hipHostMalloc (GTT, not migratable), as sgl-project/sglang#42553 does for HiCache. Without =0 the upstream path stays and a warning says so. - patch_atom_dcp_sparse_pad_rows.py: with sparse MLA + DCP + MTP the P/D producer runs an eager q_len=1 step whose padded rows keep stale dcp_sparse_kv_indptr_buffer offsets; a negative row length makes the persistent MLA kernel read past kv_indices ("Memory access fault by GPU" on the prefill under long-prefix load). Padded rows now get an empty KV range. - Correct the base Mooncake version (0.3.13, same binary as the old nightly). Co-Authored-By: Claude <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…D example 4P4D kit (atom_4p4d_glm5.2_dcp): - The prefill with LMCache offload sets HSA_USERPTR_FOR_PAGED_MEM=0 so the CPU pool is GTT (one 4 x 256 GiB prefill per node fits the ~1376 GiB GTT cap). - Backward-compatible multi-node hooks: ETCD_IP, KIT_GPUS (VRAM waits only on the kit's GPUs, on the docker host), REMOTE_PREFILLS and PREFILL_NUM_WORKERS; the libionic mount is checked on the engine's node. - smoke: the needle cold/repeat requests share a session id, so the repeat lands on the same prefill; the expected prefill count follows the topology. - agentx: scrape /metrics of the router and every worker it lists; the GPU count uses the validated prefill count. - README: new image recipe and validation (smoke 6/6, GSM8K 0.975; AgentX C48 26141.94 and C64 30579.35 input tok/s/GPU); old-base numbers kept and labelled. New atom_8p4d_glm5.2_dcp: two TP4+DCP4 prefills and one TP4+DCP4 decode on two nodes (head: prefill0 + decode + etcd/router; second node: prefill1 on GPUs 0-3, started through DOCKER_HOST=ssh:// with the 4P4D worker.sh). Thin kit over the 4P4D scripts. Correctness validated (router 2P/1D, smoke 6/6, GSM8K 0.985, cross-node RDMA); AgentX C84/C96 not measured yet. Co-Authored-By: Claude <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…rough Co-Authored-By: Claude <[email protected]> Signed-off-by: YaoCheng <[email protected]>
ChengYao-amd
requested review from
JohnQin-llm,
jiejingzhangamd,
limou102 and
xiaobochen-amd
as code owners
October 15, 2026 07:16
Image (deploy/docker/): - patch_atom_dcp_sparse_pad_rows.py: move the clamp from _rebuild_sparse_dcp_persistent_metadata into _forward_decode and key it on the host-side row count the DCP exchange writes (scheduled_bs * max_seqlen_q). The padded rows of an eager step now get an empty KV range on q_len=1 decode and MTP verify, persistent and non-persistent alike. A replayed graph runs nothing extra; the previous q_len test was captured into the decode graphs and replayed in every indexer-owning layer each step. - patch_lmcache_rocm_pinned_alloc.py: read HSA_USERPTR_FOR_PAGED_MEM once at import, so a pool is always freed by the function that allocated it. - Dockerfile.atom: a non-empty ATOM_DCP_PATCHES (the switch's old name) fails the build instead of silently building without the nightly steps. Kits (examples/atom_4p4d_glm5.2_dcp/, atom_8p4d_glm5.2_dcp/): - worker.sh: check the docker host's free GTT before starting a prefill with an LMCache CPU tier, instead of failing minutes into the cold start. - common.sh: wait_vram_free reads VRAM in KFD topology order (the order ROCr numbers GPUs) rather than DRM card order, and retries a failed read (an ssh hiccup) until the timeout. KIT_ROLES names the kit's containers on the docker host; prefill1.sh sets it to prefill, so a remote down touches only that container. - agentx.sh: parse the router's worker list as JSON. Validated on MI355X: 8P4D smoke 6/6, GSM8K 0.975; 4P4D AgentX C64 on the same node and settings as before, 30739.05 input tok/s/GPU (was 30579.35), no fault. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…e load and a PP prefill New env.sh knobs, defaults unchanged (the generated docker run commands are identical to before): - BLOCK_SIZE (64), both legs - PREFILL_MAX_BATCHED_TOKENS (16384) - OFFLOAD_MIN_LOAD_TOKENS (8192) - PREFILL_PP (1): 4 runs the prefill TP1 x PP4, eager, with PREFILL_PP_PARTITION layers per stage; AgentX metadata follows - PREFILL_SEND_WORKERS (empty = ATOM's 16): Mooncake num_worker_threads Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…fill An env.sh over the 4P4D kit, as atom_8p4d_glm5.2_dcp is: the prefill follows ATOM's GLM-5.2 AgentX recipe (TP1 x PP4, layers 20,20,20,18, eager, chunk 8192, mem util 0.85, LMCache loads of any length), block 16 on both legs, decode unchanged otherwise. Four Mooncake send workers per stage: ATOM's default 16 hung an RDMA write to one decode rank within the first requests of every AgentX run on MI355X, and one missed the 120 s transfer deadline on 300k-token prompts. On MI355X (crsuse2-m2m-140) against the 4P4D kit, input tok/s/GPU: C64 33389.60 vs 30739.05 (+8.6%), C96 30115.94 vs 20902.07 (+44.1%). For a comparison only; not for merge. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…PP4 prefill atom_4p4d_glm5.2_dcp and atom_4p4d_glm5.2_pp4 become atom_4p4d_glm5.2. Its env.sh defaults are the PP4 kit's (TP1 x PP4 prefill, layers 20,20,20,18, eager, chunk 8192, mem util 0.85, block 16, LMCache loads of any length, 4 Mooncake send workers), which beat the DCP prefill by 8.6% at C64 and 44.1% at C96 in input tok/s/GPU. PREFILL_PP=1 still selects the TP4 + DCP4 prefill; env.sh and the README list the settings it was validated with. PREFILL_SEND_WORKERS now keeps an explicit empty value (ATOM's default), so those settings can be passed from the environment. CTR defaults to glm52_4p4d. The 8P4D example (atom_8p4d_glm5.2_dcp) and its manual page are removed. The kit's generic multi-node hooks (DOCKER_HOST, REMOTE_PREFILLS, PREFILL_NUM_WORKERS, ...) stay, unused by default. The README merges the two: PP recipe, the DCP prefill as an alternative, validation and reference numbers of both on the current image, and the send-worker hang as gotcha 13. The previous image's numbers are dropped. Not run on GPUs. With docker mocked, worker.sh generates the same docker run commands as the PP4 kit by default, and as the DCP kit with PREFILL_PP=1 and the listed settings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
The Python router started uvicorn with its 5 s keep-alive default. Agentic clients (AIPerf, agentx-harness) reuse one connection per session across idle turns, and a client that resends just as the router closes that connection gets ServerDisconnectedError, which AIPerf counts as a failed request. --timeout-keep-alive (env INFERA_TIMEOUT_KEEP_ALIVE, default 900) sets uvicorn's timeout_keep_alive. The Rust backend needs no flag: axum's serve sets no hyper timer, so it never closes an idle client connection. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
An aggregated ATOM worker with --enable-dp-attention runs one engine per attention rank, each with its own KV and prefix cache, but registered as a single target, so the router could not keep a session on one rank. - The ATOM launcher registers dp_size = data_parallel_size x tp under DP attention (ATOM's global_engine_count), for mixed workers. The router already expands such a worker into per-rank targets and binds sessions per rank. - ATOM reads the rank from the request body (data_parallel_rank), not the X-Data-Parallel-Rank header. inject_dp_rank writes it for ATOM targets on the mixed path and on both PD legs; dp_rank_header no longer sends the header to ATOM. PD workers keep registering one rank: the prefill picks its own and the atom-mooncake hand-off reports it back. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
The Rust router answered 501 for ATOM PD: it only implemented the concurrent protocols. atom-mooncake is a serial pull -- the decode body is the prefill response's kv_transfer_params -- so it gets its own path, mirroring the Python DisaggRouter._dispatch_serial: - protocol.rs: prefill / hand-off / decode shaping, field for field what ATOM's proxy and the Python protocol send. - disagg.rs: serial_pull POSTs the prefill for one token, releases its load once it answers, then POSTs (unary) or streams the decode. A failed prefill or a reply without a hand-off never reaches the decode and only rebinds the prefill session. The unary decode handling moves into finish_unary_decode, shared with unary_dual. - dp.rs / proxy.rs: ATOM targets carry their DP rank in the body (data_parallel_rank) instead of the header, on the mixed HTTP and NATS paths and the ATOM PD legs. The 4P4D GLM-5.2 kit gets ROUTER_BACKEND (python by default) to run either. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: YaoCheng <[email protected]>
…r keep-alive, ATOM PD on the Rust router
xiaobochen-amd
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR covers three fairly independent parts:
1. Image and patches (
deploy/docker/)The opt-in nightly build of
Dockerfile.atommoves fromnightly_202609221542(ATOM d9f0720) torocm/atom-dev:nightly_202610131505(ATOM 661ef766, LMCache 0.5.6.dev139). The default build (ATOM_NIGHTLY=0) is unchanged.ATOM_DCP_PATCHES→ATOM_NIGHTLY, andpatches/atom_dcp/→patches/atom_nightly/.ATOM_NIGHTLY=1skips the legacypatches/atomloop (those edits are duplicate or dead code on the nightly) and runs strict patches instead: a drifted anchor fails the build.patch_dcp_prefill_mtp_metadata: upstreamed (ATOM #2430).patch_lmcache_lookup_pin: LMCache#5098 is in the base.patch_moe_eager_decode_pad: only DP-attention with eager decode triggers it, and the DCP kits do not use that.patch_lmcache_rocm_pinned_alloc.py: removes prefill stalls caused by LMCache's NUMA CPU pool on ROCm.hipHostRegister(KFD USERPTR). Whenever the kernel migrates one of its pages, every GPU queue of the process is evicted; stalls of 15–110 s were measured on a 256 GiB pool.HSA_USERPTR_FOR_PAGED_MEM=0, the pool comes from an exact-sizehipHostMalloc(GTT, cannot migrate), as sglang#42553 does.=0, the upstream path is kept and a warning is logged.patch_atom_dcp_sparse_pad_rows.py: fixes aMemory access faulton the prefill node under long-prefix load.dcp_sparse_kv_indptr_bufferonly for the scheduled rows. An eager step padded to a graph bucket therefore reads the previous step's stale offsets in its padded rows. That gives negative-length rows, and the persistent ASM decode kernel then reads out of bounds._forward_decodegives every row afterscheduled_bs × max_seqlen_qan empty KV range. This is the same count the exchange writes, so plain decode and MTP verify, persistent and non-persistent, are all covered. A replayed graph runs nothing extra.mha_varlenprebuild and theprotobuf<7pin are kept. The base's Mooncake version note is corrected (0.3.13, the same binary as the old nightly).deploy/docker/patch.upstream.status.md; the conditions for dropping each patch are inpatches/atom_nightly/README.md.2. GLM-5.2 4P4D kit (
examples/atom_4p4d_glm5.2/)Renamed:
atom_4p4d_glm5.2_dcp→atom_4p4d_glm5.2, along with its manual page. The defaultCTRchanges fromglm52_4p4d_dcptoglm52_4p4d.The prefill now defaults to TP1 × PP4, following ATOM's GLM-5.2 AgentX recipe:
20,20,20,18, mem util 0.85, max-num-batched-tokens 8192, block size 16, and LMCache loads hits of any length.PREFILL_PP=1brings back the TP4 + DCP4 prefill; the README lists the settings it was validated with.New knobs:
PREFILL_PP,PREFILL_PP_PARTITION,PREFILL_MAX_BATCHED_TOKENS,BLOCK_SIZE,OFFLOAD_MIN_LOAD_TOKENS,PREFILL_SEND_WORKERS(default 4, see gotcha 13) andROUTER_BACKEND(default python).Deployment robustness:
worker.shsetsHSA_USERPTR_FOR_PAGED_MEM=0and checks the free GTT before starting. If the pools do not fit, it fails right away instead of several minutes into the cold start.wait_vram_freewaits only for the GPUs the kit uses, found in KFD topology order (the HIP device order); before, it took the maximum over every GPU. A failed read counts as "not yet free" and is retried./v1/workerslist (parsed as JSON) and collects their server metrics, instead of hard-coding the prefill/decode ports.3. ATOM support in the router (
infera/,rust/router/)--timeout-keep-alive, default 900 s, also set byINFERA_TIMEOUT_KEEP_ALIVE.--enable-dp-attentionregistersdp_size = data_parallel_size × tp, which matches ATOM's global engine count. Without DPA,--data-parallel-size Nregisters N.data_parallel_rank(ATOM does not read theX-Data-Parallel-Rankheader).--session-affinity both, a session stays on one rank, so its prefix cache is reused turn after turn.atom-mooncake, serial pull):kv_transfer_paramsit returns, and builds the decode request from them. Field for field, this matches Python'satom_mooncake.py, i.e. ATOM's own proxy.transfer_idis never sent twice.manual/components/engines.md; the supported scope inrust/README.mdis updated.4. Behaviour changes and compatibility
ATOM_DCP_PATCHES→ATOM_NIGHTLYexamples/atom_4p4d_glm5.2_dcp→examples/atom_4p4d_glm5.2, new defaultCTRCTRuses new JIT volumes, so the first start compiles from scratchPREFILL_PP=1with the settings in the README for the old layoutexamples/deepseek_v4/engine/mix/atom(CONC ≥ 128): ranks used to be chosen by ATOM'sleast_requests, and are now chosen by the router policy (round-robin in that example). Intentional, no opt-out; see belowMixed ATOM workers with DP-attention get router-chosen ranks
Before: a mixed ATOM worker started with
-tp N --enable-dp-attentionwas a single target to the router. ATOM picked the rank itself through--dp-load-balance, by defaultleast_requests(the rank with the fewest in-flight requests).After:
dp_size=N, and the router expands it into N rank targets (worker#dp0..N-1).data_parallel_rank.least_requestsandATOM_DP_SESSION_AFFINITYno longer apply.Why:
--session-affinity both, a session stays on one rank and its prefix cache is reused across turns; the measured hit rate rose from 0.50 to 0.75.--dp-size: expand into ranks, then let the router pick and pin.Impact on existing deployments:
least_requests, showing up as higher TTFT and tail latency.examples/deepseek_v4/engine/mix/atom, which uses-tp 8 --enable-dp-attentionat CONC ≥ 128 with a round-robin router and no session affinity. Its performance numbers were measured with the old behaviour, and this PR has not re-run them under the new one.round-robin + --session-affinity bothfor ATOM DPA deployments.5. Validation
Unit tests at
5a7cab9f:pytest tests/unit/router tests/unit/engine tests/unit/server: 786 passed.cargo test(rust/) passes, andcargo clippy --all-targets -D warningsis clean.Image + 4P4D kit: 8×MI355X, GLM-5.2-MXFP4.
smoke.py(real MTP acceptance)Memory access faultAgentX reference numbers (same node, crsuse2-m2m-140, forced MTP acceptance AL=2.99 with K3):
Router: Crusoe 140, image
infera-atom:atom-router-882fcd0e.-tp 4 --enable-dp-attention, 6 sessions × 4 turns:--session-affinity both, every session stayed on one rank for all 4 turns, and the prefix hit rate was 0.75, against 0.50 with affinity off (0.75 is close to the theoretical maximum).6. Known limitations and follow-ups
max_num_batched_tokens. After changingPREFILL_MAX_BATCHED_TOKENS, use anotherCTR(fresh JIT volumes), or the prefill fails at startup.least_requestsat CONC=128/256 has not been run (see section 4).7. Merge method
Please squash-merge: the branch history contains intermediate debug commits and two merge commits without
Signed-off-by, which should not land in main's history. The squashed commit message needs aSigned-off-by.🤖 Generated with Claude Code