Chunk 65.0

In this chunk, the assistant built a complete native C/C++/CUDA DDTree inference engine for Kimi K2.6 from scratch, organized as a new `kdtree-engine/` repository. Phase 0 established the build infrastructure (CMake + CUDA 13 sm_120), a binary container format (KDTR) for sharing test data between Python and C++, and faithful numpy reference implementations of the DDTree algorithms. Phase 1 delivered three validated custom CUDA kernels: a GPU best-first tree builder (replacing SGLang's per-request CPU heapq), a tree-verify MLA-absorb attention kernel with visibility masking, and a greedy tree-accept kernel. All 27 kernel tests passed bit-exact against the references, including an on-device composition test chaining build→accept without host round-trips. Phase 2 produced a working MVP native engine implementing a full DeepSeekV3/Kimi-style MLA+MoE transformer in FP32 (cuBLAS GEMMs as the INT4 Marlin placeholder), with RMSNorm, NeoX RoPE, SwiGLU, MoE routing with shared expert, KV cache with post-verify compaction, and the complete DDTree speculative decode loop wiring all three custom kernels. The engine was validated against a numpy golden reference across two different model configurations, proving the critical invariant: DDTree greedy output matches autoregressive greedy output token-for-token (24/24 tokens exact, max logit diff 8e-6), with 8× fewer target forwards. The assistant then prepared for CT200 deployment by adding nvcc-direct build scripts (CT200 lacks cmake), kernel microbenchmarks at K2.6-realistic shapes, and a Python head-to-head benchmark comparing the GPU tree builder against SGLang's actual CPU implementation. After deploying to the 8× PRO 6000 Blackwell box, a crash in tree_accept from cyclic random test data was fixed with a safety bound, and verify_attn benchmarks were collected, confirming the documented production architecture (reuse FlashMLA for long prefix attention, custom kernel only for the small tree tail) is the correct path forward.

Building a Native CUDA DDTree Inference Engine: From First Principles to Validated Kernels 3323 words

Message Articles