AGENT SKILL

flash-linear-attention

Operate Flash Linear Attention package workflows: setup, kernels, layers/models, KDA/context parallel, and benchmarking.

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

01 前言 Front Matter

name
flash-linear-attention
license
MIT
metadata
{ "disco-role": "operating" }
description
Operate Flash Linear Attention package workflows: setup, kernels, layers/models, KDA/context parallel, and benchmarking.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Flash Linear Attention Repo Skill

Use this repo skill for tasks involving Flash Linear Attention (FLA), the fla Python package, its Triton-based linear-attention operators, fused modules, Transformers-compatible model families, Kimi Delta Attention (KDA), context-parallel routes, and FLA-specific benchmark or maintainer workflows.

Read references/repo-provenance.md before deciding whether this skill is current for a checkout. If the commit, package version, public API, or evidence paths differ materially, refresh this skill before relying on detailed guidance.

Fast routing

User task Read
Install/import FLA, choose CUDA/ROCm/XPU/NPU/CPU extras, inspect runtime versions, debug backend wheel or env-var issues. sub-skills/setup-and-backends/SKILL.md
Call or maintain fla.ops functions, debug @dispatch fallback, select op tests, or reason about Triton kernel correctness. sub-skills/ops-kernels-and-dispatch/SKILL.md
Use fla.layers, fla.modules, fla.models, Hugging Face AutoModelForCausalLM, generation, training, evaluation, or fused losses. sub-skills/layers-and-models/SKILL.md
Work on KDA, KimiDeltaAttention, KDAConfig, chunk_kda, safe gates, FlashKDA/TileLang KDA, or context parallel. sub-skills/kda-and-context-parallel/SKILL.md
Build correctness-gated benchmark commands, interpret speedups, run optimization loops, or summarize benchmark JSON. sub-skills/benchmarking-and-optimization/SKILL.md

Minimal package setup facts

  • Import package: fla.
  • Main distribution: flash-linear-attention for layers/models plus core kernels.
  • Core distribution: fla-core for fla.ops, fla.modules, and fla.utils-only users.
  • Python: >=3.10.
  • Base dependencies: transformers>=4.45.0 and einops.
  • torch and the correct Triton flavor are intentionally selected through backend extras, not the bare package install.

Typical install choices:

# NVIDIA CUDA
pip install 'flash-linear-attention[cuda]'

# ROCm: install torch from the PyTorch ROCm index first, then FLA.
pip install --index-url https://download.pytorch.org/whl/rocm7.2 torch
pip install 'flash-linear-attention[rocm]'

# CPU import-only or limited CPU checks.
pip install --index-url https://download.pytorch.org/whl/cpu torch
pip install 'flash-linear-attention[cpu]'

For XPU, NPU/Ascend, source installs, and --no-deps workflows, route to sub-skills/setup-and-backends/SKILL.md.

Safe first checks

From the owning sub-skill directories, these bundled scripts avoid downloads, training, native tests, and destructive writes:

# Setup/import/backend visibility.
python sub-skills/setup-and-backends/scripts/check_fla_runtime.py --show-env-vars

# Public operator names/signatures without running kernels.
python sub-skills/ops-kernels-and-dispatch/scripts/inspect_fla_ops.py --filter gla

# Tiny layer/model construction without checkpoint downloads.
python sub-skills/layers-and-models/scripts/smoke_layer_model.py --device cpu

# KDA import and optional tiny CUDA KDA smoke.
python sub-skills/kda-and-context-parallel/scripts/smoke_kda.py --help

# Build a gated benchmark command without running it.
python sub-skills/benchmarking-and-optimization/scripts/fla_verify_op_command.py --op chunk_gla --base main

Use CUDA-requiring script flags only when the active environment intentionally has CUDA hardware and matching wheels.

Cross-cutting operating rules

  • Do not treat CPU import success as proof that Triton/CUDA, ROCm, XPU, NPU, TileLang, FlashKDA, or context-parallel kernels work.
  • Set FLA_* backend and cache environment variables before starting Python; dispatch decisions are made in the active process.
  • For maintainer tasks in an FLA checkout, correctness gates come before performance claims. A red or skipped gate means no speedup can be promoted.
  • Do not change public layer/model symbols, config fields, checkpoint compatibility, validated numerical precision, or tolerances without explicit approval.
  • Keep KDA-specific gate and CP behavior out of generic ops guidance; KDA has its own per-key-dimension gate and context-parallel constraints.

References

  • references/package-overview.md — package surfaces, supported workflow map, public exports, and optional dependency boundaries.
  • references/troubleshooting.md — cross-cutting install/import/runtime triage before selecting a deeper sub-skill.
  • references/repo-provenance.md — source commit, package version, evidence paths, and refresh checklist.
  • references/repo-routing-metadata.json — structured router metadata for managed import tooling.

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