vllm.models.kimi_k3.amd.specialized_decode.runtime.decode
¶
The Kimi-K3 specialized decode executor (layer mode): one routing decision per step, then the layer kernels inside the stock layer loop.
Built by the model state once the weights are loaded (KimiK3ModelState): checks
the loaded weights, builds the per-rank launch state (runner) and the layer
kernels of every width, and compiles every build, before memory profiling and graph
capture. prepare_kv binds it to every KV cache vLLM allocates. Each step
plan returns a Step or None; Step.layer(i) is the kernel replacing
decoder layer i (None for vLLM's layers). Weight reloads are not supported.
Classes:
-
SpecializedDecode–The executor: builds the layer kernels, binds them to each KV cache and
-
Step–A planned step:
widthrows of whole uniform decode requests.
Functions:
-
agree–Raises on every TP rank if any rank has
reasons: a rank that refused -
step_reason–None if a step's KDA and MLA metadata (identical on every TP rank) are a
SpecializedDecode
¶
The executor: builds the layer kernels, binds them to each KV cache and plans every step.
Methods:
-
after_step–Once per executed step, from compute_logits (eager on every rank, also
-
plan–This step's plan, or None to run vLLM's layers.
-
prepare_kv–Checks and binds the KDA states and MLA caches vLLM just bound (the
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
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 281 282 283 284 285 286 287 288 289 290 291 292 | |
_kv_key()
¶
The first KDA layer's recurrent state by all but its number of slots:
an extensible KV cache re-binds its views at the same addresses with the
final block count, which cache_reasons does not depend on.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
after_step()
¶
Once per executed step, from compute_logits (eager on every rank, also under graph replay). Raises on every rank once a rank gave up an in-kernel wait.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
plan(positions, intermediate_tensors)
¶
This step's plan, or None to run vLLM's layers.
Steps that run vLLM's layers:
- pipeline-parallel stage inputs, and steps before a KV cache is bound
(profiling, dummy runs);
- PIECEWISE steps (captured without attention metadata);
- widths without kernels (more than max_num_seqs requests);
- steps that are not pure, uniform regular-decode or spec-verify steps
(step_reason).
Eager steps run the kernels too. Every predicate is the same on all TP ranks: the kernels' mailboxes need every rank on one path. Under FULL graphs this runs at capture only and the plan is baked in; a replay with fewer requests than its graph pads whole requests (NULL_BLOCK_ID state, one accepted token), which the kernels serve like real ones.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
prepare_kv()
¶
Checks and binds the KDA states and MLA caches vLLM just bound (the CUDA-graph memory profiling cache, then the real one).
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
Step
¶
Bases: NamedTuple
A planned step: width rows of whole uniform decode requests.
Methods:
-
layer–The kernel replacing decoder layer idx in this step, or None (vLLM's).
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
layer(idx)
¶
The kernel replacing decoder layer idx in this step, or None (vLLM's).
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
agree(reasons, group, what)
¶
Raises on every TP rank if any rank has reasons: a rank that refused
alone would leave the others spinning in-kernel.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
step_reason(attn_metadata, kda_prefix, width, q, mla_prefix='')
¶
None if a step's KDA and MLA metadata (identical on every TP rank) are a
pure, uniform regular-decode or spec-verify step filling width rows, else
why not. q is the deployment's configured rows per request.