feat(kda): add KDA attention components#1051
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates Kimi Delta Attention (KDA) into the sglang-jax framework, enabling efficient hybrid linear-attention model serving. The implementation provides high-performance Pallas kernels for the forward pass, a dedicated attention backend, and robust support for data parallelism, ensuring the model scales effectively across distributed hardware configurations. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
4d23248 to
d009bbf
Compare
0003845 to
644687e
Compare
644687e to
6e3801a
Compare
- Add KDA Pallas kernel (python/sgl_jax/srt/kernels/kda/) with naive reference - Add KDA attention backend (linear/kda_backend.py) and short convolution layer - Wire KDA into hybrid_linear_attn_backend and radix_linear_attention - Add unit tests for TP and DP paths (test_kda_attention*.py, test_short_conv.py) - Register tests in unit-test-tpu-v6e-4 suite
6e3801a to
6131a09
Compare
Summary
Adds the KDA (Kimi Delta Attention) inference components for sglang-jax, enabling hybrid linear-attention model serving (e.g. Kimi-Linear, #937). Includes DP support via
shard_map.Changes
Kernels (
srt/kernels/kda/)kda.py— chunked Pallas forward (gate cumsum → intra-chunk delta-rule solve → inter-chunk state propagation → output computation), varlen alignment helpersnaive.py— step-by-step recurrent reference, used as decode path and test baselineLayers (
srt/layers/attention/linear/)short_convolution.py— stateless depthwise causal conv1d with EXTEND (cu_seqlens-aware) and DECODE (rolling cache) pathskda_backend.py—KDAAttnBackendextendingLinearRecurrentAttnBackend: conv → L2 norm → recurrent kernel dispatch, conv state pack/unpack, pool gather/scatter viashard_mapfor DPTests (
test/)test_short_conv.py— 24 tests, conv correctness vsnnx.Convbaseline (fp32 + bf16)test_kda_attention.py— 9 backend tests at TP=4 (rtol/atol = 2e-2 / 1e-2)test_kda_attention_dp.py— 9 DP tests covering DP=4/TP=1 and DP=2/TP=2 (sparse ranks, unbalanced batches, mixedhas_initial_state, multi-round prefill→decode)Test plan
pytest python/sgl_jax/test/test_short_conv.py→ 24/24 (TPU v6e-4)pytest python/sgl_jax/test/test_kda_attention.py→ 9/9 (TPU v6e-4)pytest python/sgl_jax/test/test_kda_attention_dp.py→ 9/9 (TPU v6e-4)References