Repository navigation
perf(FlashKDA): add opt-in SM90 indexed KDA prefill - #5212
Conversation
Port the indexed prefill adapter and its regression from 7b28f6d onto main. Keep ReplaySSM dispatch and the existing decode path.
|
When every requested checkpoint is at the end of its sequence, Could we record whether any row needs an interior snapshot when building the prefill metadata on the host? For a terminal-only batch, we could omit both snapshot arguments to the provider and still export the terminal checkpoints from |
Classify interior checkpoints on the host after reservation IDs are bound. Preserve the plan on device transfer, and export terminal destinations from the final state even when both optional native snapshot arguments are absent.
|
@zzwwrr Thanks for catching this. Fixed in 95160d91. The host now checks the actual reserved checkpoint IDs and offsets and carries that decision to the device. For a terminal-only batch, the direct provider receives The new BF16 and FP32 regression cases failed on the previous head and passed on H200 after the fix. They inspect both native operator arguments and compare the output and entire state pool element-for-element, including a separate checkpoint destination at length 137. With the 32-row, 64-head, head-dim-128 shape you described, measured peak allocated memory for the call fell by 64 MiB for BF16 and 128 MiB for FP32. |
hehesnail
left a comment
There was a problem hiding this comment.
Retested both FlashKDA providers on H200. With terminal-only checkpoints, the updated direct provider produced exactly the same outputs and state pool as the previous revision while reducing peak allocation by about 64 MiB for BF16 and 129 MiB for FP32 in the 32-row, 64-head case. In a mixed batch, the interior checkpoint at token 64 also matched the state from running that prefix independently. LGTM.
Change
Add opt-in FlashKDA for SM90 compact indexed KDA prefill. The direct provider reads strided BF16 Q/K/V (head dimension 128, bounded gate), gathers shared input states before writing separate destinations, and exports FP32 or BF16 state. Terminal checkpoints use the final state; interior checkpoints use 64-token boundaries.
CUDA 13 production and development images package two independent providers. Before worker startup, set
FLA_FLASH_KDA=1to use the #5073 wheel for eligible prefills without checkpoint metadata, orLMDEPLOY_FLASH_KDA_LIB=1for the direct provider. Both default to off. On eligible indexed prefill the direct provider takes precedence and is located automatically in the installed wheel.LMDEPLOY_FLASH_KDA_LIB_PATHallows an external library override.Incremental AgentX performance
On the MegaMoE + 16K-checkpoint deployment at C90, enabling direct FlashKDA increased output throughput by 9.19%, request throughput by 5.41%, and goodput by 20.91%. The serving window used
eaaa56d9and its direct-provider switch. The independent GSM8K run below uses the current switch on the scored head.8×H200, DP8/EP8/TP1, native MTP3, RDMA Mooncake, Weka 256K, independent 1,800 s scored windows. Five-PR AgentX report with configurations, controls and concurrency sweeps.
Full GSM8K accuracy on this PR
Scored
a0784181on GLM-5.3-Flash FP8 with only the feature in this PR enabled. All 1,319 test questions used the same five train demonstrations, greedy decoding, seed 42, C32 through the router and the historical QA settingmax_tokens=1024(generated tokens per question, with input tokens counted separately). The grader compares the last parsable number after####with the gold answer and includes all 1,319 questions.LMDEPLOY_FLASH_KDA_LIB=1(direct SM90; FLA dispatcher off)The historical QA image on the same GLM-5.3-Flash FP8 weights scored 91.74% / 91.58% (1,210 / 1,208 correct out of 1,319). The earlier 91.96% QA result used a different checkpoint.
Per-PR counts, repeat runs and scoring evidence.
H200 latency
A (FLA) is the original indexed path. A (Docker) uses the #5073 wheel through FLA. B and C use the same direct-provider binary; B copies Q/K/V inside the timer and C consumes the views. The four arms share the same indexed state layout and inputs.
The 64K measurement uses 8×H200, DP8/EP8/TP1, eight 8K chunks and eight paired measurement blocks. C saves 411 ms versus indexed FLA and 226 ms versus Docker FlashKDA. Removing the three copies accounts for 112 ms. Docker → B changes both the provider revision and calling interface.
Numerical agreement and validation
The fork retains the experimental setup, original three-arm results, pairwise error metrics, FP64 controls and full 45-layer × 8-chunk trace. 完整中文报告 · Detailed measurements and layer trace