local-ai · review · first seen Nov 30, 10:32 UTC
llama.cpp generalizes flash-attention bias API
llama.cpp shipped a generalized flash-attention bias API in b12859: construction validates dense K*Q bias when bias_idxs is NULL, but CPU, CUDA and Vulkan reject that non-indexed form. Builders should distinguish what the API accepts at construction from what their chosen backend will run.
In short
- Dense K*Q bias is validated when bias_idxs is NULL; validation alone is not execution support.
- Old indexed-bias names remain as deprecated wrappers; the renamed indexed API is available.
- CPU, CUDA and Vulkan reject non-indexed bias; unsupported backends reject all bias.
What shipped
The ggml_flash_attn_ext_add_bias() path now validates a bias as a dense K*Q tensor when bias_idxs is NULL. That is a construction-time rule for the non-indexed form, not a statement that every backend can execute it. For a caller passing no bias index tensor, the shape of the bias is now part of the API contract that must be satisfied before backend behavior becomes relevant. [1]
The indexed-bias function was renamed to ggml_flash_attn_ext_add_bias_indexed(). The old indexed-bias public names remain available as deprecated wrappers. Existing callers therefore have a compatibility path, while a caller updating its use of the indexed form can move to the new name. The source excerpt also says the implementation derives bias state from src and src instead of op_params; that is an internal change, not a new promise of backend support. [1]
Backend acceptance remains narrower than the generalized API shape. CPU, CUDA and Vulkan reject non-indexed bias. Backends without bias support reject any bias, whether indexed or not. The decision is not only whether the call can describe a dense bias, but whether the actual backend accepts the requested bias form. The shipped change should not be read as a blanket enablement of dense bias across those execution paths. [1][2][3]
Why it matters if you build
If you maintain a flash-attention caller, separate two checks in your workflow: build the operation with the intended bias representation, then test that operation against the backend you actually use. A dense K*Q bias with bias_idxs set to NULL is subject to validation at construction. Passing that check does not override the explicit CPU, CUDA or Vulkan rejection of non-indexed bias. Treat an accepted graph description and an executable graph as different outcomes. [1][2]
If your integration already uses indexed bias, the deprecated public names reduce the immediate pressure to rename every call. They do not make the old names the preferred long-term interface: the shipped indexed name is ggml_flash_attn_ext_add_bias_indexed(). A focused migration can change the call site while preserving the indexed representation, then check behavior on its target backend. This is a naming migration, not evidence that a dense replacement will work there. [1][2]
The limit is operational rather than cosmetic. A product that chooses a backend with no bias support cannot use either bias form there; a product on CPU, CUDA or Vulkan cannot assume non-indexed bias works merely because the API validates its dense tensor. That can change which path you select for a feature that requires bias. The supplied claims give no performance or memory measurement, so there is no supported efficiency case for switching representations today. [1][2][3]
How to try it today
- Locate each flash-attention bias call and note whether it passes bias_idxs as NULL.
- For a NULL bias_idxs call, check that the supplied bias is a dense K*Q tensor before constructing the operation.
- For indexed-bias calls, identify uses of the deprecated public names and evaluate the ggml_flash_attn_ext_add_bias_indexed() name.
- Test the intended bias form on the backend you actually deploy; expect CPU, CUDA and Vulkan to reject non-indexed bias.
- If your backend has no bias support, test a path without bias rather than assuming either bias form is accepted.
What we checked
Every claim below was walked down the source ladder. The rung is how close the source is to the thing itself; the tense is the source's own.
-
shipped L0 · primary
ggml_flash_attn_ext_add_bias() validates bias as a dense K*Q tensor when bias_idxs is NULL.
per GitHub releases · ggml-org/llama.cpp (L0) -
shipped L0 · primary
The old indexed-bias public names remain as deprecated wrappers.
per GitHub releases · ggml-org/llama.cpp (L0) -
shipped L0 · primary
CPU, CUDA and Vulkan reject non-indexed bias.
per GitHub releases · ggml-org/llama.cpp (L0) -
shipped L0 · primary
Backends without bias support reject any bias.
per GitHub releases · ggml-org/llama.cpp (L0)
What is not confirmed
These claims do not establish that any named backend executes non-indexed bias, or that dense bias is faster, cheaper or equivalent in output to indexed bias. The construction validator and the stated rejections support a narrower conclusion: the interface can validate the dense form, while the listed backends still decline it. No timetable for wider backend support is given. [1][2][3]
The deprecated wrappers are reported as remaining, but the supplied material gives no removal date or migration deadline. It also does not specify which, if any, backends support indexed bias beyond the rejection rules stated here. Do not infer an indexed-bias support matrix from a public function name or from the fact that an older wrapper still exists. [1][2][3]
Who should act, who should wait
Move now if you own an indexed-bias API caller: inventory deprecated names and migrate deliberately to ggml_flash_attn_ext_add_bias_indexed(), while checking your deployment backend. Also update a non-indexed caller to supply a dense K*Q bias when bias_idxs is NULL, if it constructs that operation. Wait on a feature that requires non-indexed bias on CPU, CUDA or Vulkan, or any bias on a backend without bias support. The shipped validation does not remove those execution limits. [1][2][3][4]
Sources
- b12859: ggml : clean up FA bias API (#33178) — GitHub releases · ggml-org/llama.cpp L0 · primary