Skip to content

b12859

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 30 Nov 11:31
aa631e0

ggml : clean up FA bias API (#33178)

  • ggml : validate indexed bias at op construction only

The indexed-bias check already runs in ggml_flash_attn_ext_add_indexed_bias(), so the backend checks were redundant. Make the validator static in ggml.c, drop the ggml-impl.h declaration, and remove the CPU supports_op case, the CPU compute assert, and the CUDA kernel-selection check.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : rename FA indexed bias to bias_indexed

Add internal ggml_flash_attn_ext_has_bias() and ggml_flash_attn_ext_bias_is_indexed() helpers and derive the bias state from src[6]/src[7] instead of op_params[5]. Rename ggml_flash_attn_ext_add_indexed_bias() to ggml_flash_attn_ext_add_bias_indexed() and keep the old public names as deprecated wrappers.

Rename the remaining indexed_bias identifiers to bias_indexed, including the CUDA kernel templates and the HIP metrics script. Reject non-indexed bias in the CPU, CUDA and Vulkan backends; backends without bias support reject any bias.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : rename FA indexed bias validator

Name the static validator after the function it validates: ggml_flash_attn_ext_add_bias_indexed_validate().

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : keep src order in FA bias validation

Reorder the src tensor declarations in the indexed-bias validator to follow the src index order.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : mark FA bias wrappers as deprecated

Add the deprecated marker above the old indexed-bias wrapper implementations.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : generalize FA bias API

Rename ggml_flash_attn_ext_add_bias_indexed() to ggml_flash_attn_ext_add_bias() and rename its arguments to bias and bias_idxs. When bias_idxs is NULL, the bias is validated as a dense K*Q tensor with shape [n_kv, n_batch, n_head_kv, n_stream]; otherwise it remains an indexed bias table.

Update the deprecated wrapper to stay indexed-only, and align the table/indices naming in llama-graph, CPU, CUDA, Vulkan and the tests.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : move FA bias args after kv_rows

Reorder the bias and bias_idxs arguments of build_attn_mha() to follow kv_rows, and update all call sites.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : deduplicate FA kq_b and bias

Remove the kq_b argument from build_attn_mha() and build_attn_iswa_impl() and pass the dense KQ bias through bias with bias_idxs == nullptr. The FA path now rejects a dense bias and adds an indexed bias without backend checks. The non-FA path adds a dense bias directly to kq.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : inline dense bias mask

Inline the dense_bias_mask lambda into the non-FA path, now its only use.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : add FA bias to mask in non-FA path

Add both indexed and dense FA biases to the mask in the non-FA path so they are scaled by the ALiBi slope, matching the FA path. Remove the kq-side addition for dense bias.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : remove redundant non-FA mask cast

The non-FA path already implies soft_max_ext can consume an F32 mask, so drop the cparams.flash_attn check and the F16 cast.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : cast FA bias to mask type

Compute the non-FA bias in F32 and cast it to the mask type before adding, instead of casting the mask to F32.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : remove FA bias TODO

Remove the TODO after confirming that adding the bias to the mask is correct.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : guard FA dense bias in validation

Add a CPU compute assert for the indexed-bias assumption, reject the dense bias in ggml_flash_attn_ext_add_bias_validate with a TODO, and update the backend comments to say bias.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : document FA bias scaling

Note that the bias is added after the KQ scaling.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml : rename FA add sinks/bias to set

Rename ggml_flash_attn_ext_add_sinks to set_sinks and deprecate the old name. Rename ggml_flash_attn_ext_add_bias to set_bias. Allow set_sinks to override existing sinks.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • llama : set FA bias unconditionally

Call ggml_flash_attn_ext_set_bias() unconditionally and move it before ggml_flash_attn_ext_set_sinks().

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

  • ggml-cuda : fix sparse bias template names

Rename the remaining indexed_bias references in the sparse FA code added by master.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

Website:

Attestations:

macOS/iOS:

Linux:

Android:

Windows:

openEuler:

  • DISABLED
  • openEuler x86 (310p)
  • openEuler x86 (910b, ACL Graph)
  • openEuler aarch64 (310p)
  • openEuler aarch64 (910b, ACL Graph)

UI: