Guidelines for kernel correctness testing and coverage in fla/ops/** and related modules, including common Triton grid/addressing pitfalls. Helps decide what tests to add or run before an MR.
58
68%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/fla-correctness-coverage/SKILL.mdUse this skill when adding or modifying a kernel in fla/ops/ (e.g., KDA, GDN,
GLA, DeltaNet, NSA, etc.) and you need to verify correctness or close a coverage
gap.
When a task needs operator math or protocol details, read only the relevant reference file:
references/cp.md — context parallelism for linear attention, including KDA/GDN CP formulation.references/delta-rule.md — Delta Rule operator background.references/generalized-delta-rule.md — Generalized Delta Rule operator background.references/simple-gla.md — Simple GLA operator background.Do not load every reference by default; use these only when the touched code or test depends on that operator's math or distributed protocol.
For each kernel, check coverage across these dimensions:
| Axis | Values to cover |
|---|---|
| Sequence layout | dense, variable-length (varlen) |
| Direction | forward, backward |
| Gate mode | safe gate, non-safe gate (if applicable) |
| Beta mode | raw beta, post-sigmoid beta (if applicable) |
| QK normalization | with L2 norm, without L2 norm |
| State | initial state, final state (if the op supports state passing) |
| GVA | grouped value attention (GVA) enabled vs disabled |
| Head dimensions | D != Dv (different qk and v head dims) |
| Backend verifier | reference implementation, torch.autograd.gradcheck, and backend-specific sanity checks |
Before adding or changing a Triton kernel, check these implementation details in addition to numerical tests:
tl.int64 before using
them in address arithmetic.tl.int64, including block bases, strides,
varlen sequence offsets, head offsets, and element offsets. Do not rely on
int16 or int32 overflow behavior.tl.make_block_ptr use. Triton marks it deprecated; use
TensorDescriptor / tl.make_tensor_descriptor when descriptor semantics are
needed, or explicit tl.load / tl.store pointer arithmetic following an
existing validated kernel pattern.fla.utils.device and fla.utils.device_platform in tests instead of
adding new hard-coded device strings.IS_NVIDIA, IS_NVIDIA_HOPPER, IS_NVIDIA_BLACKWELL, IS_AMD, and
IS_INTEL from fla.utils for platform-specific skips or branches.torch.cuda platform checks in correctness tests. If no
existing helper covers the condition, add a small helper in fla.utils first.Use these paths when looking for existing tests or deciding where to add new ones:
tests/ops/test_kda.py — KDA kernel teststests/context_parallel/ — context-parallel variants (e.g., test_cp_kda.py, test_cp_gdn.py)tests/models/test_modeling_kda.py — end-to-end model tests for KDAAdapt the path to the specific op you are working on (replace kda with gdn,
gla, nsa, delta, etc.).
# Single op test
pytest tests/ops/test_kda.py -v
# Context parallel tests for the same op
pytest tests/context_parallel/test_cp_kda.py -v
# Model-level test
pytest tests/models/test_modeling_kda.py -v
# All dependent tests (see fla-mr-readiness skill)
python scripts/find_dependent_tests.py <changed_files>27967b9
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.