kda-and-context-parallel
KDA ops, KimiDeltaAttention/KDAConfig, safe-gate gating, optional FlashKDA/TileLang routing, and context-parallel guidance for flash-linear-attention.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- kda-and-context-parallel
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- KDA ops, KimiDeltaAttention/KDAConfig, safe-gate gating, optional FlashKDA/TileLang routing, and context-parallel guidance for flash-linear-attention.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/context-parallel.md7.9 KB
- 参考文档references/kda-workflows.md12.8 KB
- 参考文档references/troubleshooting.md7.7 KB
- 脚本scripts/smoke_kda.py5.5 KB
03 SKILL.md 正文
KDA and Context Parallel
Use this sub-skill when the task is specifically about Kimi Delta Attention (KDA), KDA layer/model configuration, KDA gate modes, safe_gate/lower_bound, KDA optional backends, or KDA context-parallel behavior.
Route here for
- Calling or diagnosing
chunk_kda,fused_recurrent_kda,KimiDeltaAttention,KDAConfig,KDAModel, orKDAForCausalLM. - Choosing between chunk KDA, fused recurrent KDA, KimiDeltaAttention's training/decode modes, and KDA model config fields.
- Handling raw gate inputs versus precomputed log decays,
A_log,dt_bias,use_qk_l2norm_in_kernel,use_gate_in_kernel,use_beta_sigmoid_in_kernel,allow_neg_eigval,safe_gate, andlower_bound. - Deciding whether a KDA call can use FlashKDA, TileLang KDA backward, Triton-Ascend KDA, distributed
cp_context, or intra-card context parallel. - Planning KDA native validation candidates without launching native tests or distributed jobs by default.
Do not use this sub-skill for
- Generic backend registry mechanics, non-KDA dispatch policy, or broad Triton kernel style; route to the ops/dispatch sub-skill if present.
- Generic benchmark loops, result tables, or autotuning methodology; route to the benchmarking sub-skill if present.
- Non-KDA linear-attention families unless the task is comparing their context-parallel contract with KDA.
First actions
- Identify the surface: operator call, KDA layer/model config, optional backend, distributed CP, or intra-card CP.
- Read the bundled reference that matches the surface:
references/kda-workflows.mdfor KDA APIs, gate contracts, layer/model config, backend gates, and native validation candidates.references/context-parallel.mdforcp_context, distributed KDA CP, intra-card CP, prerequisites, and skip rules.references/troubleshooting.mdfor common failures and the fastest diagnosis path.
- If a quick environment sanity check is useful, run the bundled helper with
--helpfirst. Usescripts/smoke_kda.py --require-cudaonly when a CUDA device is intentionally available; it does not launch distributed work.
Core operating rules
- KDA tensors use q/k heads
Hand value/gate headsHV; grouped value attention is valid only whenHV % H == 0. chunk_kdais the training-capable high-throughput route and the only KDA operator route that acceptscp_context.fused_recurrent_kdais the recurrent route for decode/small-token inference and does not acceptcp_context.- For raw gates, pass
use_gate_in_kernel=True,A_log, optionaldt_bias, and rawg; for precomputed gates, passuse_gate_in_kernel=Falseand ensuregis already the log-space decay tensor expected by the operator. - Prefer the explicit safe-gate contract
use_gate_in_kernel=True,safe_gate=True,lower_bound=-5.0; if using precomputed gates withsafe_gate=True, make the clamp/provenance ofgexplicit because the operator will not applylower_boundin that mode. - Do not mix
cp_contextwithinitial_stateoroutput_final_state=True;cp_contextowns the rank-localcu_seqlensmetadata. - Treat FlashKDA and intra-card CP as inference-only optional accelerators. If their verifier conditions are not all satisfied, expect silent fallback to the default path unless backend dispatch is disabled globally.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).