Module kda_cuda

Module kda_cuda 

Source
Expand description

2026-09-25: Host launch of the Kimi K3 KDA decode kernels (PTX module MODULE) for one token.

Two launches per token: CONV_ENTRY updates the short-conv state and applies SiLU, then RECURRENT_ENTRY L2-normalises q and k and runs the gated delta-rule step. The CPU reference is kda_decode_token. Decode uses launch_k3_kda_decode_token_on_device unless K3_CUDA_KDA=0.

Owner: model-arch, Kimi K3. Invariants:

  • Every temporary device buffer a launch allocates gets a free call before it returns, on success and on error; a failed free is ignored.
  • KdaDeviceState::alloc_and_upload, when it fails, calls free on what it allocated, ignoring a failed free.

Structs§

K3KdaDecodeKernels
KdaDeviceState
2026-09-25: One sequence’s KDA conv and recurrent state on the device. launch_k3_kda_decode_token_on_device updates it in place and copies only the output back; download copies it to a host KdaState.

Constants§

CONV_ENTRY
MODULE
2026-09-25: Built from kernels/gb10/kimi-k3/bf16/kda_decode.cu.
RECURRENT_ENTRY

Functions§

launch_k3_kda_decode_token
2026-09-25: One decode token against a host KdaState: uploads the state, runs both kernels, and downloads the updated state.
launch_k3_kda_decode_token_on_device
2026-09-25: One decode token against a KdaDeviceState; only the output is copied back to the host.