Skip to content

Pad packed Kimi MLA query heads to eliminate tail launches - #6

Closed
myshytf wants to merge 1 commit into
integration/k3-packed-mla-reader-20260908from
perf/k3-packed-mla-20260908
Closed

myshytf wants to merge 1 commit into
integration/k3-packed-mla-reader-20260908from
perf/k3-packed-mla-20260908

Conversation

@myshytf

@myshytf myshytf commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Packed Kimi-K3 attention under TP9/DCP9 gathers 99 effective query heads. Padding those heads to 104 leaves an eight-head remainder for the packed reader's 16-head tiles, causing two successive kernel launches per MLA layer. Pad to 112 and remove the zero heads before the DCP output/LSE reduction, so every effective head executes in one launch.

The ordinary E4M3 reader retains its eight-head geometry. Packed inputs with at most one tile do not acquire an unnecessary additional tile. Target weights, KV records, visible tokens, and valid-head arithmetic are unchanged.

This is a focused change over integration/k3-packed-mla-reader-20260908. That integration branch composes the DFlash2 serving source with the existing reader controls from lab vLLM #644, which depends on B12X #311. Those PRs implement reader execution and split controls; this PR addresses the separate TP9 head-tail launch cost. Searches of open packed-MLA/head-padding PRs found no existing implementation of this Kimi packed-reader tile change.

Validation on RTX PRO 6000 Blackwell, vLLM fa6ea71c01fd, B12X 0bf9f177b237:

  • pytest -q --confcutdir=tests/v1/attention tests/v1/attention/test_b12x_mla.py: 47 passed, including packed/BF16 queries at 64 and 99 effective heads.
  • Six four-row comparisons at 2,048/8,192/16,384 local tokens preserve output and LSE digests for all 99 effective heads under 104-to-112 padding. With the vector-load reader, one call takes approximately 108–213 microseconds versus 195–287 with 104 heads. These are isolated kernel timings.
  • A frozen-source high-page check at byte offset 2,149,244,928 matches low-page output and LSE bit for bit.
  • Seven serving checks, including cold requests, 9,216-token external cache reuse, and adjacent conversation turns, pass without non-finite log probabilities. The serving configuration retains static split ranges and BF16 partials.
  • Pre-commit passes. Inherited test fixtures are updated to the implemented KV shard accessor and split-threshold contract.

Status: implemented; kernel, cache-serving, and concurrency-one context-sweep checks qualified.

The frozen default-prompt benchmark (30 seconds per cell, K=3) measures 64.21/70.42/72.81 output tokens/s at 16/32/64 Ki context, versus 61.14/61.53/62.28 before the packed-reader integration. Inferred verification rate improves 13.7–13.9% across those contexts. These numbers include the vector-load reader dependency and this head-padding change; each arm is one unseeded sweep. The 128 Ki candidate measures 68.90 tokens/s, but there is no valid baseline: the baseline client produced zero tokens while the benchmark's global-counter fallback attributed another request's throughput to it. Any earlier 128 Ki gain claim is withdrawn. At approximately 64 Ki, rank-zero target graph duration is 30.85 versus 35.35 ms, packed MLA kernel sum is 2.83 versus 7.50 ms per step, and the draft remains about 2.14 ms. The packed reader executes 96 rather than 192 launches across four steps and 24 layers.

OpenAI Codex assisted with implementation, PR review, and validation under the operator's direction. This draft requests human review before merge. No model payload, private request capture, or generated trace is included.

Pad packed-reader queries to a complete 16-head tile when a full tile and a remainder would otherwise launch separately. TP9 uses 99 effective heads, padded to 112; discard only zero padding before the DCP output reduction. Preserve ordinary FP8 tile geometry.

Validation: 47 adapter tests pass on SM120. Six four-row kernel cases at 2048, 8192, and 16384 local tokens retain identical output and LSE digests for the 99 valid heads under 104-to-112 padding. Repair inherited test fixtures to use the implemented KV shard accessor and balanced-plan threshold.

Co-authored-by: OpenAI Codex <noreply@openai.com>

Signed-off-by: g0san <myshytf@gmail.com>
@myshytf

myshytf commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Superseded by local-inference-lab/vllm#644 at commit 2c99648d718555502a25437ed3035c59dbd933b0.

That pull request now contains the packed-reader TP9/DCP9 99-to-112 head-tile
implementation, DCP padded-buffer replay guard, and focused regression
coverage. Keeping this draft open would require review of the same adapter
interface and test file twice. The public validation record, source scope,
128 Ki baseline invalidation, and single-sweep limits are recorded on vLLM
local-inference-lab#644. No unique implementation remains in this pull request.

@myshytf myshytf closed this Sep 8, 2026
@myshytf myshytf reopened this Sep 8, 2026
@myshytf

myshytf commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Frozen-runtime overlay validation for the equivalent vLLM local-inference-lab#644 commit
2c99648d718555502a25437ed3035c59dbd933b0 completed successfully:
tests/v1/attention/test_b12x_mla.py reports 63 passed on GPU 4. The test
mounted the frozen candidate and B12X evidence source read-only, overlaid only
the updated adapter files, and did not change a serving process or cache
namespace.

This draft has no implementation absent from vLLM local-inference-lab#644, so it is now closed to
keep one packed-reader review boundary. The validation scope and measurement
limits are documented on vLLM local-inference-lab#644.

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