vllm.models.kimi_k3.nvidia.recoverssm.kernels
¶
Host side of the CuTe KDA RecoverSSM kernels (SM10x tensor cores).
CuteRecoverSSMVerify: the speculative verify of one KDA layer with the short convolution fused in (cutedsl/verify_ws.pyfor the dim-first conv state,cutedsl/verify.pyotherwise). It writes the outputs, the rolled conv state and the verify records, likecausal_conv1d_updatefollowed bykda_recoverssm_verify.cute_recoverssm_commit: the state fold of a prepared commit plan for all KDA layers in one launch (cutedsl/commit.py), replacing the Triton fold ofKDARecoverSSMCommitContext.commit.
The kernels compile when the KV cache is bound, before CUDA graph capture; nothing compiles under capture.
Classes:
-
CuteRecoverSSMVerify–The CuTe verify for one KDA layer's shapes (compiled kernels are shared).
Functions:
-
can_use_cute_recoverssm–Whether the CuTe verify and commit can serve a KDA layer, and if not,
-
compile_state_commit–Compile the CuTe state commit (before serving: it runs eagerly).
-
cute_recoverssm_commit–Fold the accepted tokens of a prepared commit plan into the state of all
CuteRecoverSSMVerify
¶
The CuTe verify for one KDA layer's shapes (compiled kernels are shared).
Methods:
-
__call__–Verify
state_indices.shape[0]requests.mixed_qkv[T, 3HK] is -
compile–Compile the variants this layer launches (outside graph capture).
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
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 | |
__call__(*, mixed_qkv, raw_gate, raw_beta, A_log, dt_bias, lower_bound, state, records, query_start_loc, state_indices, num_accepted_tokens, conv_state, conv_weight, out)
¶
Verify state_indices.shape[0] requests. mixed_qkv [T, 3HK] is
the raw projection (before the convolution), raw_gate [T, HK],
raw_beta [T, H], out [T, HV]; conv_state is the stored
[slots, 3HK, Q + 2] (dim first) or [slots, Q + 2, 3HK] page view.
Request b writes its verify records to row b of records.
Returns False without launching when an activation does not start on a 16-byte boundary (e.g. for an odd token offset into projection rows that are not 16-byte aligned): the caller then runs the Triton verify.
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
_bulk_copy_aligned(mixed_qkv, raw_gate, conv_state, conv_weight)
¶
The warp-specialized verify bulk-copies q / k / v and gate rows (16-byte aligned rows), conv state channel blocks (contiguous per slot) and conv taps; otherwise the plain tcgen05 verify runs.
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
compile()
¶
Compile the variants this layer launches (outside graph capture).
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
_check_layouts(state, *tensors)
¶
The KV cache pages, records and parameters the CuTe kernels read: the state streams in by TMA (K-element rows of contiguous heads, slots a multiple of 16 bytes apart), and every tensor starts on a 16-byte boundary.
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
can_use_cute_recoverssm(*, head_dim, window, conv_width, has_conv_bias, activation_dtype, conv_state_dtype, state_dtype, conv_weight_dtype, lower_bound)
¶
Whether the CuTe verify and commit can serve a KDA layer, and if not, why.
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
compile_state_commit(num_heads, window, device, align)
¶
Compile the CuTe state commit (before serving: it runs eagerly).
Source code in vllm/models/kimi_k3/nvidia/recoverssm/kernels.py
cute_recoverssm_commit(context, state_indices, batch, align)
¶
Fold the accepted tokens of a prepared commit plan into the state of all
of context's layers in one launch. It runs after sampling, outside CUDA
graphs, on the current stream (TVM-FFI).