vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.mla.prepared
¶
Prepared MLA core: the packed input projection feeds the query kernel, then either
tokenspeed_mla_decode (core "tokenspeed") or FlashInfer's trtllm-gen MLA decode (core
"trtllm"; FP8 Q and KV as tokenspeed, FP32 softmax and accumulation) into the BF16
latent, and MlaValue (W_UV / gate). Under DCP (dcp: a DcpBox) the tokenspeed core
runs over the local KV shard for every DCP rank's heads between the query's q
publication and DcpValue's merge (see mla.dcp). Spec verify: q query tokens
per request (rows grouped by request, causal among them).
Classes:
-
PreparedMla–max_context(the deployment's longest sequence) bounds the split count;
Functions:
-
compile_core–CuTe kernels (query, value) of one batch of rows (
qper request); under DCP -
core_for–coreunless "auto": trtllm-gen from B16, else tokenspeed (spec verify, -
pad_requests–Request metadata for
batchrows: PIECEWISE graphs pad the tokens but not -
trtllm_decode–FlashInfer trtllm-gen MLA decode of FP8
query[B, q, H, 576] (causal among
PreparedMla
¶
max_context (the deployment's longest sequence) bounds the split count;
core forces "tokenspeed" or "trtllm". dcp: the model's DcpBox, with this
layer's mailbox parity. queries: the query lengths q (spec verify: 1 + the
draft length) prepared for every batch of rows divisible by q.
Methods:
-
prepare_dcp–(MlaQuery's publish arguments, DcpValue's mailbox arguments, parity and
-
run–lengths/block_table: this rank's KV (the local shard under DCP); -
stock_core–tokenspeed_mla_decode or trtllm-gen into the BF16 latent (DCP: tokenspeed
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
prepare_dcp(batch)
¶
(MlaQuery's publish arguments, DcpValue's mailbox arguments, parity and rank) of one batch.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
run(projected, out, *, cache, slots, block_table, lengths, totals=None, q=1)
¶
lengths/block_table: this rank's KV (the local shard under DCP);
totals: under DCP, the requests' full lengths. q rows per request (spec
verify; slots per row). Rows of projected beyond the requests run as
empty requests (zero output).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
stock_core(cache, block_table, lengths, batch, q=1, totals=None)
¶
tokenspeed_mla_decode or trtllm-gen into the BF16 latent (DCP: tokenspeed
for every rank's heads over the local shard into the DcpBox rows + LSE; q > 1
masks causally in global positions, totals). tokenspeed: a fixed split
count per batch (one CTA pair per split filling the SMs); both PDL chained
between our kernels.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
compile_core(batch, heads, pitch, specs, device, dcp=0, sms=148, q=1)
cached
¶
CuTe kernels (query, value) of one batch of rows (q per request); under DCP
(dcp: its size) the query publishes and the value is DcpValue.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
core_for(batch, core='auto', q=1)
¶
core unless "auto": trtllm-gen from B16, else tokenspeed (spec verify,
q > 1: tokenspeed, whose SM-filling splits stream long contexts far faster).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
pad_requests(batch, block_table, lengths, totals=None)
¶
Request metadata for batch rows: PIECEWISE graphs pad the tokens but not
the requests, so missing rows become empty requests (length 0 on page 0).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/mla/prepared.py
trtllm_decode(query, cache, block_table, lengths, max_seq, scales, out)
¶
FlashInfer trtllm-gen MLA decode of FP8 query [B, q, H, 576] (causal among
the q rows) over the FP8 paged cache into BF16 out [B, q, H, 512], PDL chained;
zeroed workspace and multi-CTA counter (self-resetting) owned here, one per (device,
heads).