Repository navigation
Conversation
FLARE_KIMI3_PREFILL_LATENT_GATHER=1 (default off): prefill MoE layers compute their own latent columns from the full hidden row with the row-sharded latent_down_rows weights that decode already loads, and all-gather them through a DcpAllToAll column channel. This replaces the all-reduce of BF16 partials of the column-sharded latent_down (down_reduce, rows x 3584 per MoE layer). No reduction is left in that step: each latent value is one FP32-accumulated full-K dot product rounded to BF16 once (today: BF16 partials, FP32 sum, BF16 again), identical on all ranks. expert_reduce is unchanged; its input depends on the reduced latent through the experts, so the two 3584-wide reductions cannot be merged. Switches (export and serve): FLARE_KIMI3_PREFILL_LATENT_GATHER=1; FLARE_KIMI3_PREFILL_LATENT_GATHER_LAUNCH=threads:block_limit (default 512:32, "default" = channel default); FLARE_KIMI3_PREFILL_LATENT_GATHER_ROWS (channel rows, default the serial channel rows). Enabled only when the latent width divides into 64-column rank partitions (3584: world 2, 4, 7, 8). PreparedAllGather / PreparedChunkedAllGather gain an optional launch=(threads, block_limit) (default None = unchanged). Decode, verification and speculation decoders are unchanged: the channel is passed only to the main prefill decoders.
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.
📌 Description
FLARE_KIMI3_PREFILL_LATENT_GATHER=1(default off, read at preparation; set the same for export and serve).In a prefill MoE layer, the latent down projection is column-sharded today. Every rank multiplies its slice of the hidden row and all-reduces BF16 partials: the
down_reduce, rows x 3584 per MoE layer. With the switch, prefill graphs instead compute their own 448 latent columns from the full hidden row. They uselatent_down_rows, the row-sharded copy of the same weight that decode already loads, so no new weights are needed. The columns are then all-gathered through aDcpAllToAllcolumn channel. No reduction is left in that step:down_reduce), speculation/draft decoders andexpert_reduce. The channel is passed only to the main prefill decoders. The routed experts consume the reduced latent and are nonlinear, so the two 3584-wide reductions cannot be merged into one.FLARE_KIMI3_PREFILL_LATENT_GATHER_LAUNCH=threads:block_limit(default512:32;default= channel default) andFLARE_KIMI3_PREFILL_LATENT_GATHER_ROWS(channel rows; default = the serial channel rows).PreparedAllGather/PreparedChunkedAllGathergain an optionallaunch=(threads, block_limit); the defaultNoneis unchanged.index_selectcopy into the down-projection source is skipped.latent_down_rowsat M = prefill rows, K 7168, N 448). The old prefilllatent_downshape is no longer used.Measured at TP8 (8x RTX PRO 6000 Max-Q, two PCIe Gen5 switches with 4 GPUs each, no NVLink), 3072-row chunk, max-rank medians in ms:
down_reduce)latent_down_rowsvslatent_down)That is -39 to -44 ms per 3072-token chunk over 92 MoE layers, about +3 % prefill throughput modelled. With the channel's default launch geometry (0.64-0.66 ms) the gain halves. With the flat gather (0.94-1.05 ms) it is gone.
🧪 Tests
On this rebased branch:
tests/recipes/test_kimi3*,test_kimi31*,tests/components/test_candidate_merge*,test_collective*): release base 5 F / 148 P, this branch 5 F / 159 P. The failure set is identical (the 5 pre-existing failures). The newtests/recipes/test_kimi3_prefill_latent_gather.py(11 tests) passes. It covers the switch parsing, the W/width gate, and that the speculationcollectivesdict does not carry the channel.DcpAllToAll.all_gather_heads, 3584 columns, launch 512:32, chunks 1024 and 3072) was stress-tested on the rebased Align the FlashInfer pin with the tuning efforts ignition accepts NVIDIA/hyperflare-inference#91 branch at world 2 and world 4, flat topology (the island topology needs world 8). Each run did 2,000 CUDA-graph replays with a new input bank every replay, outputs poisoned in-graph and the channel's IPC staging memset 0xFF 40 times: 0 mismatches on every rank.On our pre-rebase tree (release branch + these patches) (same flare change on our tree, same b12x island gather):
Topology assumptions
all_gather_headsfrom flashinfer Align the FlashInfer pin with the tuning efforts ignition accepts NVIDIA/hyperflare-inference#91 (B12X_PCIE_DCP_GATHER_ISLAND=1, ranks 0-3 | 4-7, partner rank ^ 4). On other layouts it is exact but may not be faster than the reduction it replaces.Reviewer Notes
expert_reduce(the second 3584-wide all-reduce) could become a column reduce-scatter plus a small FP32 sum-of-squares all-reduce for the latent norm. That needs a new exact column-RS kernel and is not part of this PR.