vllm.models.kimi_k3.nvidia.specialized_decode.runtime.decode
¶
The specialized decode executor over the stock Kimi K3 backbone: one routing decision per step, then every layer's prepared providers in one loop.
Classes:
-
SpecializedDecode–Built once the weights are loaded; owns every prepared provider, the
Functions:
-
decode_metadata–One layer's metadata if this step is a pure decode (q = 1) or a uniform
-
is_uniform_verify–Whether every request of the b // q graph rows verifies q tokens (FULL graphs
SpecializedDecode
¶
Built once the weights are loaded; owns every prepared provider, the mailboxes and the decode buffers. Reads the backbone, never modifies it.
Methods:
-
build_providers–Every layer's attention and feed-forward providers, the model's mailboxes
-
normalize–A stock step's output with the backbone's final norm applied, as the
-
plan–This step's decode plan, or None to run the stock forward instead.
-
prepare_kv–Compile each layer's cores for its bound KV cache layout (the profiling
-
run–Normalized hidden states (and the aux streams) of a planned step.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
build_providers()
¶
Every layer's attention and feed-forward providers, the model's mailboxes and the prefetch side stream. All collective allocations, weight packing and kernel compiles finish here, before KV binding and CUDA graph capture.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
normalize(output)
¶
A stock step's output with the backbone's final norm applied, as the specialized decode's last AttnRes applies it; the aux streams stay pre-norm.
Runs in chunks of at most 255 rows: the stock RMSNorm kernel reduces with
1024-thread blocks below 256 rows and 256-thread blocks above, so chunking keeps
the reduction order compute_logits uses for the few sampled rows, and
prefill logits match stock.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
plan(positions, intermediate_tensors)
¶
This step's decode plan, or None to run the stock forward instead.
Steps that run the stock forward:
- pipeline-parallel stage inputs (intermediate_tensors);
- token counts without prepared providers (above 64 or not in batches);
- steps outside a CUDA graph capture (profiling, warmup and the warmup run
before each capture), so every stock kernel runs before its capture;
- PIECEWISE steps, keyed by token count alone and so captured as stock;
- steps with prompt rows (prefills, chunked prefills, fresh prompts);
- speculative steps whose requests do not all verify q tokens (partial
drafts, verify rows mixed with plain decode rows).
Every predicate is the same on all TP ranks: the mailboxes of the specialized decode need every rank to take the same path.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
prepare_kv()
¶
Compile each layer's cores for its bound KV cache layout (the profiling cache, then the real one).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
run(step, input_ids, inputs_embeds)
¶
Normalized hidden states (and the aux streams) of a planned step.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
decode_metadata(attention, context, q, b)
¶
One layer's metadata if this step is a pure decode (q = 1) or a uniform verify step of b tokens, else None.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/decode.py
is_uniform_verify(md, q, b)
¶
Whether every request of the b // q graph rows verifies q tokens (FULL graphs pad whole requests: KDA stages NULL state rows, MLA zero-length decodes).