fla-dispatch-backends

Implements and tests runtime backend dispatch for FLA operations using BaseBackend subclasses and verifiers.

Updated Sep 11, 2026
One-click install
npx skills add https://github.com/swiss-ai/flash-linear-attention --skill fla-dispatch-backends-swiss-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fla-dispatch-backends
Source: https://github.com/swiss-ai/flash-linear-attention/tree/main/.agents/skills/fla-dispatch-backends
Command: npx skills add https://github.com/swiss-ai/flash-linear-attention --skill fla-dispatch-backends-swiss-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding or modifying hardware-specific backends in the Flash Linear Attention library requires following a strict dispatch contract—registries, priorities, verifiers, env vars, and torch.compile constraints—and mistakes silently break fallback behavior or compiled graphs. ## Core Features & Use Cases - Dispatch Model Guidance: Explains how @dispatch decorators, BackendRegistry, priority ordering, and is_available/is_enabled checks route calls to the right backend. - Backend Implementation Checklist: Walks through creating a BaseBackend subclass, writing verifiers, registering backends, and keeping the decorated function as the semantic fallback. - Verifier and Testing Rules: Enforces cheap, side-effect-free verifiers with rejection-reason logging, plus tests covering accepted dispatch, rejection, and fallback paths. - Use Case: When adding a TileLang backend for a Gated DeltaNet kernel, use this Skill to correctly place the decorator, write the verifier, set env vars like FLA_TILELANG, and add rejection tests. ## Quick Start Use the fla-dispatch-backends skill to add a new backend for the kda operation with a verifier and dispatch tests.

Frequently Asked Questions about fla-dispatch-backends

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new backend to an FLA operation?

Create a BaseBackend subclass under the operation's backends/ package, set backend_type, package_name, env_var, default_enable, and priority, then implement the verifier and backend function. Register it in the operation's backends/__init__.py and add dispatch tests.

How does the FLA backend dispatch decorator choose a backend?

The @dispatch decorator tries registered backends sorted by priority, where lower values run first. A backend is used only when both is_available() and is_enabled() return true and its verifier accepts the call; otherwise dispatch falls to the next backend or the default implementation.

Can I disable backend dispatch in Flash Linear Attention?

Yes, set FLA_DISABLE_BACKEND_DISPATCH=1 to bypass the dispatch decorator entirely and run the original implementation. Individual backends can also be toggled with their own env vars such as FLA_TILELANG or FLA_FLASH_KDA.

Why must backend verifiers be side-effect free?

Verifiers run on every dispatched call to decide routing, so they must be cheap, deterministic, and free of mutations to registries, tensors, RNG state, or environment variables. Side effects would corrupt fallback behavior and break torch.compile-friendly dispatch.

Does backend dispatch work with torch.compile?

The dispatch wrapper is marked with torch.compiler.disable, so backend selection happens outside compiled graphs. Keep selection logic in the wrapper and put compilable work inside the selected backend implementation, checking is_available and is_enabled directly rather than cached can_use paths.