Skip to content

Use paired router rows for Kimi P8 gather - #258

Merged
lukealonso merged 2 commits into
martin/kimi-counted-owner-transportfrom
martin/kimi-p8-paired-rows
Nov 11, 2026
Merged

lukealonso merged 2 commits into
martin/kimi-counted-owner-transportfrom
martin/kimi-p8-paired-rows

Conversation

@voipmonitor

@voipmonitor voipmonitor commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Kimi K3.1 decode gathers the per-rank latent projection and router logits before selecting experts. For eight physical rows, the paired gather previously used one CUDA thread block to copy every row. Two blocks can divide complete rows between them while retaining each output's rank-major layout.

Implementation

Pass row_blocks=2 to the paired latent/router gather only when the prepared route exchange contains eight physical rows. All other paired row capacities use one block. The fused route path and expert-selection arithmetic keep their existing behavior.

Result

At the Kimi K3.1 eight-row TP16 geometry, the isolated paired gather's median slowest-rank latency fell from 33.3148 µs with one block to 31.0025 µs with two blocks, a 6.9% reduction. This measures the paired collective. Complete Flare graphs, native serving, and performance policies for other tensor-parallel sizes remain unqualified.

Validation

  • Against combined FlashInfer d1611d36f5fdd245e0a75815f1ed327b86174967, Flare passed 154 CPU tests with five CUDA-only cases skipped. The preparation policy checks physical row counts 2, 4, 6, 7, and 8. Combined FlashInfer passed 152 CPU tests with 16 CUDA-only skips; offline SM120 compilation also checked counted/full-width owner transport and distinct one-, two-, four-, and eight-block paired-gather programs. Both dependency lockfiles pass uv lock --check --offline.
  • The underlying FlashInfer paired gather passed exact TP4 and TP16 CUDA tests covering varying row capacities and block counts, changing inputs, queued graph replay, guarded output buffers, and epoch rollover. Both outputs were compared byte for byte with a rank-major reference. FlashInfer #99
  • The TP16 timing used sixteen RTX PRO 6000 Blackwell Workstation Edition GPUs, driver 615.71.10, Torch 2.14.1+cu132, and FlashInfer paired-gather code based on 9bf51994746c2bf6319786351f389ccea0a6c3c9. Each rank supplied an 8 × 224 BF16 latent tensor and an 8 × 56 FP32 router tensor generated from seed 32145. Both configurations used 512 threads per block and 64 gathers per CUDA graph. After warmup and exact output checks, six groups of replays used block counts 1, 2, 2, 1. The reported statistic is the median of the per-replay maximum rank durations divided by 64. After the run, reported graphics clocks were about 2610 MHz, memory clocks were 16,365 MHz, and the power limit was 600 W per GPU.

Dependencies

This draft is stacked on the Flare change that enables counted Kimi candidate transport. FlashInfer's paired-gather change supplies the two-block launch configuration. Both dependency files pin d1611d36f5fdd245e0a75815f1ed327b86174967, which combines the corrected counted transport and paired gather branches without the independent top-16 change. Update this pin after the FlashInfer PRs merge, then retarget this draft to main after the Flare parent merges. Flare #257 · FlashInfer #99

🤖 Generated with Claude Code

voipmonitor and others added 2 commits November 10, 2026 21:30
The eight-row Kimi route exchange submitted its paired latent and router gather with one row block, leaving the transport's independent row partitioning unused. Enable two row blocks only for eight physical rows, where additional CTAs can divide complete rows without changing the route computation.

Pass row_blocks=2 for P8 and retain row_blocks=1 for every other multi-row shape. Add a CPU preparation test that inspects the actual b12x call metadata for two, four, six, seven, and eight rows.

This is expected to reduce P8 paired-gather serialization; no latency or whole-model improvement is claimed from this CPU-only validation.

The focused policy test passed all five geometries, and test_kimi31_query_overlap.py plus test_kimi31.py reported 26 passed and 30 skipped with CUDA disabled. Multi-CTA collective correctness, CUDA graph replay, and performance remain unrun here and require the matching FlashInfer paired-gather revision; the dependency pin remains unchanged.

Design-Signed-Off-By: Kimi (Kimi); design-review=cfcf
Co-Authored-By: Kimi <noreply@anthropic.com>
The eight-row gather policy needs both counted candidate transport and
multi-CTA paired gathers. Integrate the parent's scratch validation and
pin the two corrected FlashInfer APIs together, with matching uv.lock
metadata, so locked preparation can build both operations.

The eight-row policy remains two row blocks; every other paired capacity
retains one. The dependency revision excludes the independent standalone
top-16 optimization, keeping the required transport changes explicit.

Combined FlashInfer CPU coverage passes 152 tests with 16 CUDA skips, and
Flare passes 154 tests with 5 CUDA skips. Both dependency locks validate.
The underlying transports passed separate TP16 CUDA checks; the paired
gather also passed TP4. Whole-model performance remains unqualified.

Design-Signed-Off-By: Codex GPT-6; design-review=cfcf
Signed-off-by: Martin Vit <martin@voipmonitor.org>
@lukealonso
lukealonso marked this pull request as ready for review November 11, 2026 12:50
@lukealonso
lukealonso merged commit 58a81a4 into martin/kimi-counted-owner-transport Nov 11, 2026
1 of 3 checks passed
lukealonso pushed a commit that referenced this pull request Nov 11, 2026
A single thread block copies every row of the paired latent/router gather.
Partitioning eight-row gathers across two blocks exposes more copy work
while preserving each output's rank-major layout.

Set row_blocks=2 only at eight physical rows and retain one block elsewhere.
Pin the merged FlashInfer main that supplies the partitioned-gather API in
both pyproject.toml and uv.lock. This ports the policy accepted in PR #258
onto main without replaying the counted-selection change already merged.

Earlier isolated TP16 measurements reduced this gather from 33.31 to
31.00 microseconds; they do not establish full-model speedup. On this branch,
41 focused CPU checks pass, including five row-capacity policy cases.
The dependency lock validates offline. GPU and end-to-end tests were not
rerun for this port.

Design-Signed-Off-By: Codex GPT-6; design-review=cfcf

Signed-off-by: Martin Vit <martin@voipmonitor.org>
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