AGENT SKILL

ops-kernels-and-dispatch

Maintain public fla.ops APIs, Triton operator kernels, dispatch backends, and correctness gates for Flash Linear Attention.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
ops-kernels-and-dispatch
license
MIT
metadata
{ "disco-role": "operating" }
description
Maintain public fla.ops APIs, Triton operator kernels, dispatch backends, and correctness gates for Flash Linear Attention.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

ops-kernels-and-dispatch

Use this sub-skill when the task touches Flash Linear Attention's public fla.ops entry points, Triton/Gluon/TileLang/Ascend operator kernels, backend dispatch registration or verifiers, operator correctness tests, or operator maintenance audits.

Route here for

  • Inspecting or changing public operator APIs such as chunk_gla, chunk_linear_attn, chunk_kda, fused_recurrent_*, fused_chunk_*, and parallel_*.
  • Adding, removing, or modifying a @dispatch('<operation>') decorator, backend registry, backend verifier, backend env gate, or fallback path.
  • Maintaining Triton kernel wrappers, autograd Function surfaces, input_guard / autocast behavior, variable-length (cu_seqlens) contracts, or initial/final state layouts.
  • Writing or reviewing correctness coverage for forward outputs, backward gradients, dispatch routing, verifier rejection, and NaN-poisoned allocations.
  • Auditing every callsite after a shared signature, state layout, kernel launch, save-for-backward tuple, or return tuple changes.

Do not use this sub-skill for

  • KDA-specific context-parallel design, inter-card protocol, or deep KDA algorithm changes; route to the KDA/context-parallel sub-skill.
  • Benchmark loops, profiler work, speedup claims, or benchmark registry maintenance; route to the benchmarking/optimization sub-skill after the correctness gate is green.
  • Installation-only, backend wheel selection, or environment smoke checks unless the install issue blocks an operator import; route setup questions to the setup/backends sub-skill.
  • Layer/model APIs, checkpoint compatibility, or training recipes unless a layer/model callsite must be audited after an operator API change.

Fast workflow

  1. Identify the public entry point and mode. Use references/api-and-dispatch.md for the root export list, signature facts, shape contracts, and dispatch model. Use the bundled script when an installed package is available:

    python scripts/inspect_fla_ops.py --filter kda
    python scripts/inspect_fla_ops.py --signature chunk_gla --signature chunk_linear_attn --signature chunk_kda
    
  2. Preserve the public contract before optimizing internals: q/k/v/g/beta shapes, cu_seqlens flattening, initial/final state layout, dtype expectations, scale defaults, return tuple shape, and deprecation behavior all matter to downstream layers and models.

  3. For dispatch work, keep the decorated function as the semantic fallback. Verifiers must be cheap, deterministic, side-effect free, and return (True, None) or (False, reason). A rejected backend must fall through to the next backend or to the default implementation.

  4. For Triton kernel work, reuse shared kernels where possible, use explicit offset-vector loads/stores with full masks, cast program IDs and address arithmetic to tl.int64, and do not introduce tl.make_block_ptr or tl.advance in mainline Triton code. The Ascend backend is the only documented block-pointer exception.

  5. For public-facing PyTorch surfaces and autograd functions, preserve input_guard contiguity/device behavior and paired autocast_custom_fwd / autocast_custom_bwd behavior where the operator already supports mixed precision.

  6. Before calling an operator change complete, apply references/testing-and-correctness.md: optimized vs reference, forward and backward, deterministic seed, non-power-of-two shapes, varlen and state axes when reachable, dispatch accept/reject/fallback when relevant, and NaN-poisoning awareness.

  7. Audit callsites in one pass after shared changes: public wrapper signature, private helper signatures, kernel launch argument order, saved tensors, backward returns, state tuple order, tests, layer/module/model users, and any backend implementation that mirrors the public call surface.

  8. Use references/troubleshooting.md for shape assertion failures, silent dispatch fallback, optional backend gates, Triton compile failures, NaN failures, and torch.compile/autocast surprises.

Key guardrails

  • Do not relax tolerances or change a validated numerical algorithm to make a test pass without explicit design agreement.
  • Do not claim a backend was exercised from numerical parity alone; assert that routing reached the backend or that dispatch was deliberately disabled for the fallback comparison.
  • Do not promote forward-only checks for training-capable kernels; gradients and saved-state paths are part of the operator contract.
  • Do not make broad public API or checkpoint-visible changes silently. If a change is breaking, keep the non-breaking part separate and flag the compatibility decision.

Bundled assets

  • references/api-and-dispatch.md: public op families, verified signatures, q/k/v/g/beta shape cautions, input_guard / autocast expectations, dispatch registry, env vars, and backend checklist.
  • references/testing-and-correctness.md: frozen correctness contract, test axes, forward/backward template, NaN-poisoning behavior, dispatch tests, and callsite audit checklist.
  • references/troubleshooting.md: symptom-driven recovery for operator imports, shapes, varlen state, dispatch, backend gates, Triton compile errors, NaNs, and API drift.
  • scripts/inspect_fla_ops.py: safe installed-package helper that imports fla.ops, lists public ops, filters by substring, and prints signatures without executing kernels.

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