vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.mla.balanced
¶
The KV-balanced MLA core ("balanced") of the specialized decode: the device-planned
split-KV FP8 MLA decode of nvidia/kv_balanced_mla in place of tokenspeed.
tokenspeed splits every request's KV into the same number of chunks, fixed per batch
shape, so the longest request of a mixed batch sets the layer time. The balanced core
plans each request's split count from this rank's KV lengths on the device (one small
kernel per decode step, launched by the step's first MLA layer and reused by the
others) and one wave of persistent clusters walks the planned work list. Under DCP it
reads the local KV shard, masks causally in global positions and returns the log2 LSE
that DcpValue merges, as tokenspeed does.
Precision is tokenspeed_mla_decode's (the stock TOKENSPEED_MLA backend): FP32 split-KV partials and its P handling (row max kept while it grows by at most 2^8, P stored as E4M3 unscaled), so only the split points (a summation order) differ from stock.
One BalancedMla per model: the kernels per query length q, their plan buffers and
one split-KV scratch, all allocated while the providers are built (before the KV
cache is sized).
Classes:
-
BalancedMla–The balanced cores of
headsdecode heads (under DCP: every rank's).
Functions:
-
reducer_d_tiles–D512 bands per row of the split-KV reduction of
rowsquery rows: -
supported–Whether the balanced core runs
headsxqquery rows (M128 tiles).
BalancedMla
¶
The balanced cores of heads decode heads (under DCP: every rank's).
Methods:
-
decode–BF16
out[B, q, heads, 512] (and the log2lse[B, q, heads]) of the -
key–(q, capacity) of a step of
requests: the core that decodes it. -
plan–Plan this step's split counts from
lengths(this rank's KV lengths, one -
require–Prepare the core of
qrows per request forrequests.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/balanced.py
decode(query, cache, block_table, lengths, scales, out, lse=None, **dcp)
¶
BF16 out [B, q, heads, 512] (and the log2 lse [B, q, heads]) of the
FP8 query [B, q, heads, 576] over the FP8 paged cache with the current
plan, PDL chained. Under DCP dcp holds cp (world, rank, interleave)
and totals, the requests' global lengths for the causal mask.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/balanced.py
key(q, requests)
¶
(q, capacity) of a step of requests: the core that decodes it.
plan(q, lengths)
¶
Plan this step's split counts from lengths (this rank's KV lengths, one
per request): once per step, before the decodes of its MLA layers.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/balanced.py
require(q, requests)
¶
Prepare the core of q rows per request for requests.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/balanced.py
reducer_d_tiles(rows, device)
¶
D512 bands per row of the split-KV reduction of rows query rows:
tokenspeed_mla_decode's choice, 2 when the rows fill at most half the SMs (TP8
R1 at q = 5: 60 rows; -1 us at 8K-128K, GB300), else 1.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/balanced.py
supported(heads, q, device)
¶
Whether the balanced core runs heads x q query rows (M128 tiles).