vllm.models.kimi_k3.nvidia.specialized_decode.runtime.prefetch
¶
L2 weight prefetch for the specialized decode.
Small-batch decode is bound by HBM bandwidth, and each kernel that starts on weights
not yet in L2 stalls on DRAM. Some kernels leave bandwidth idle, such as the attention
core and the all-reduces. At fixed points of each layer, this module launches a small
kernel (cutedsl/common/prefetch.py) on a side stream. It pulls the byte ranges of
the weights the next kernels read into L2, so that they start warm.
Prefetch points (fork(point, layer, batch)), each with its batches per TP:
oproj_down: after the o-projection (B3-8), the MoE front's packed router + latent-down rows.attention_moe: at TP8 only, after the KDA input projection (B5-8) or the MLA core (B8), the same front rows plus the shared expert's weights.next_attention: once the routed experts are launched, the next layer's attention weights, capped in MiB per batch (NEXT_ATTENTION). Not above B8, where the HBM-bound experts lose more bandwidth than the attention gains.
The front and shared-expert ranges are on the critical path. They launch with the highest stream priority and the maximum shared-memory carveout, which needs a driver launch because CuTe drops both attributes.
Each fork records an event on the main stream that the side stream waits on, so a
prefetch starts only after the work it overlaps. join() at the end of the step
makes the main stream wait for the side stream, so a captured graph always rejoins
it. This lives in runtime/ rather than cutedsl/ because it is host-side
orchestration across layers: a stream, events, and per-(point, layer, batch) tables
built from the model's layers.
Classes:
-
PrefetchController–Prefetch launches per (point, layer, batch) on one side stream.
-
PreparedWeightRanges–One owner retains weights, immutable range table, executable and launch ABI.
Functions:
-
attention_weights–Next-attention weights in their consumption order.
PrefetchController
¶
Prefetch launches per (point, layer, batch) on one side stream.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/prefetch.py
PreparedWeightRanges
¶
One owner retains weights, immutable range table, executable and launch ABI.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/prefetch.py
attention_weights(attention)
¶
Next-attention weights in their consumption order.