vllm.models.kimi_k3.nvidia.specialized_decode.recoverssm.state
¶
How the specialized decode installs its deferred RecoverSSM on the stock Kimi K3 objects, without changing their classes:
- the KDA layers (
install_layers, before the specialized providers are built): verify records indexed by record slot (with a scratch row) and a verify that flushes the pending replays and writes the records to each request's record slot; - the model runner state (
install_model_state): the per-request pending replay counts (DeferredRecoverSSMState), reset per new request and bound, with the step's request slots, to the KDA metadata builders before their build; - the KDA metadata builders (
install_builder, on first bind): thefp32_deferredcommit context, and each step'srecoverssm_deferred.
Classes:
-
DeferredRecoverSSMState–pending[max_num_reqs]: per request-state slot, the accepted tokens of its
Functions:
-
deferred_recoverssm_verify–KimiK3DeltaAttention._recoverssm_verifyof a Triton RecoverSSM layer -
install_builder–Set up a KDA metadata builder for the deferred RecoverSSM: the
-
install_layers–Before the specialized providers read them: give every Triton RecoverSSM KDA
-
install_model_state–Install the deferred RecoverSSM on a
KimiK3ModelState(no-op without
DeferredRecoverSSMState
¶
Bases: RecoverSSMState
pending [max_num_reqs]: per request-state slot, the accepted tokens of its
last verify not yet folded into its checkpoint, for the KDA metadata builders
that defer the commit to the next verify (those install_builder set up);
other builders never see it.
Methods:
-
bind–Hand deferring builders the step's request slots (None: capture or
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
bind(attn_groups, idx_mapping)
¶
Hand deferring builders the step's request slots (None: capture or dummy batches, whose rows own no request) and, once, the pending counts. Only ubatch 0's builders: the hybrid state does not support DBO.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
_DeferredStepCommit
¶
A step's commit context (the KDA metadata's recoverssm_context): the
fp32_deferred context's commit with the step's deferred operands.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
_build_deferred(builder, m, context, num_spec_decodes, spec_request_indices, num_decode_draft_tokens_cpu, state_indices)
¶
Stage the speculative rows' record slots; with prefix caching (align), mark the rows to commit after sampling: those whose window, up to the next step's, may reach a mamba block boundary (the boundary state and the next block's checkpoint must hold committed states), from the host's upper bound of each sequence length with a margin for rejected drafts.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
_spec_sequence_masks_cpu(builder, m, num_decode_draft_tokens_cpu)
¶
The speculative rows of a RecoverSSM build with speculative rows (the
builder's spec_sequence_masks_cpu).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
deferred_recoverssm_verify(self, m, mixed_qkv, raw_g, raw_beta, conv_weight, query_start_loc, out)
¶
KimiK3DeltaAttention._recoverssm_verify of a Triton RecoverSSM layer
under the deferred RecoverSSM: a deferred step's verify does not replay the
last step's accepted tokens, so it folds them into the checkpoints first (every
layer, once per step), and writes its records to the request slots. Other steps
run the stock verify.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
install_builder(builder, pending)
¶
Set up a KDA metadata builder for the deferred RecoverSSM: the
fp32_deferred commit context for Triton RecoverSSM layers (CuTe ones keep
their own FP32-state commit), and a build that adds the step's
recoverssm_deferred (None: not deferred) to the metadata.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
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 | |
install_layers(layers)
¶
Before the specialized providers read them: give every Triton RecoverSSM KDA
layer of layers (decoder layers) verify records indexed by record slot and
the deferred verify (deferred_recoverssm_verify). CuTe RecoverSSM layers
keep their own FP32-state commit and are left as they are.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/recoverssm/state.py
install_model_state(state)
¶
Install the deferred RecoverSSM on a KimiK3ModelState (no-op without
RecoverSSM): its recoverssm becomes a DeferredRecoverSSMState, and its
add_request / prepare_attn reset a new request's pending count after the
base and bind the KDA builders before the metadata build.