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 spec-verify 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 metadata (identical on every TP rank) is a pure
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 vLLM just bound (the CUDA-graph memory
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/decode.py
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 | |
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_TOKENS rows);
- steps that are not pure spec-verify steps of whole uniform requests
(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 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 spec-verify 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)
¶
None if a step's KDA metadata (identical on every TP rank) is a pure
spec-verify step of whole uniform requests filling width rows, else why
not.