AGENT SKILL

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

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, or KDAForCausalLM.
  • 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, and lower_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

  1. Identify the surface: operator call, KDA layer/model config, optional backend, distributed CP, or intra-card CP.
  2. Read the bundled reference that matches the surface:
    • references/kda-workflows.md for KDA APIs, gate contracts, layer/model config, backend gates, and native validation candidates.
    • references/context-parallel.md for cp_context, distributed KDA CP, intra-card CP, prerequisites, and skip rules.
    • references/troubleshooting.md for common failures and the fastest diagnosis path.
  3. If a quick environment sanity check is useful, run the bundled helper with --help first. Use scripts/smoke_kda.py --require-cuda only when a CUDA device is intentionally available; it does not launch distributed work.

Core operating rules

  • KDA tensors use q/k heads H and value/gate heads HV; grouped value attention is valid only when HV % H == 0.
  • chunk_kda is the training-capable high-throughput route and the only KDA operator route that accepts cp_context.
  • fused_recurrent_kda is the recurrent route for decode/small-token inference and does not accept cp_context.
  • For raw gates, pass use_gate_in_kernel=True, A_log, optional dt_bias, and raw g; for precomputed gates, pass use_gate_in_kernel=False and ensure g is 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 with safe_gate=True, make the clamp/provenance of g explicit because the operator will not apply lower_bound in that mode.
  • Do not mix cp_context with initial_state or output_final_state=True; cp_context owns the rank-local cu_seqlens metadata.
  • 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351