Skip to content

metal : split fa kernels into per-dtype libraries - #29329

Merged
ggerganov merged 2 commits into
masterfrom
gg/metal-optimize-compile
Sep 25, 2026
Merged

ggerganov merged 2 commits into
masterfrom
gg/metal-optimize-compile

Conversation

@ggerganov

Copy link
Copy Markdown
Member

Overview

Split the monolithic fa.metal library into per-dtype FA and FA-vec Metal libraries so ggml_metal_library_compile_all can compile them concurrently instead of waiting on one large fa source.

On Apple M2 Ultra cold-start compile dropped from 16.856 sec (max single = fa) to 2.609 sec (max single = fa_vec_f16).

Additional information

  • Removed fa.metal.
  • Added shared fa_common.metal and fa_vec_common.metal templates.
  • Split block FA into fa_f16, fa_f32, fa_q4_0, fa_q4_1, fa_q5_0, fa_q5_1, fa_q8_0.
  • Split FA vec into fa_vec_f16, fa_vec_f32, fa_vec_q4_0, fa_vec_q4_1, fa_vec_q5_0, fa_vec_q5_1, fa_vec_q8_0.
  • Added fa_aux for pad/blk/idx/reduce/kv_f16/lightning indexer.
  • Updated GGML_METAL_LIBS and CMake embed/non-embed source handling.
  • All 559 original host_name kernels are preserved.
  • Validated with test-backend-ops -b MTL0 -o 'ADD(...)' after clearing the Metal cache.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp

@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Apple Metal https://en.wikipedia.org/wiki/Metal_(API) labels Sep 23, 2026
@ggerganov
ggerganov marked this pull request as ready for review September 24, 2026 10:56
@ggerganov
ggerganov requested a review from a team as a code owner September 24, 2026 10:56
@ggerganov
ggerganov force-pushed the gg/metal-optimize-compile branch from e10e2c1 to f7640c9 Compare September 24, 2026 13:11
@ggerganov
ggerganov force-pushed the gg/metal-optimize-compile branch from f7640c9 to 65437b3 Compare September 25, 2026 08:33
@ggerganov
ggerganov merged commit 5a75f14 into master Sep 25, 2026
30 of 33 checks passed
@ggerganov
ggerganov deleted the gg/metal-optimize-compile branch September 25, 2026 09:11
feal87 added a commit to feal87/myllama.cpp that referenced this pull request Sep 25, 2026
Merge upstream commits:
  - llama: add llama_prec_policy + model-driven W4A4 path (ggml-org#24364)
  - llama: fix tensor split for fused qkv with uneven K/V head sizes (ggml-org#29294)
  - metal: split fa kernels into per-dtype libraries (ggml-org#29329)
  - metal: FWHT kernels for block widths above 512 (ggml-org#29095)
  - CUDA: fuse RMS_NORM + SCALE into one kernel (ggml-org#29393)
  - common: extract shared unicode path/string helpers (ggml-org#29415)
  - common,rpc: simplify fs_create_directory_with_parents() (ggml-org#29432)
  - rpc: include nb in the get_alloc_size cache key (ggml-org#29283)
  - [SYCL] support sparse FA (ggml-org#28796)
  - musa: fix PH1 operator failures and build issues (ggml-org#29193)
  - HIP: bump HIP_VERSION required for fp8 (ggml-org#29231)
  - opencl: add q5_k bin kernel (ggml-org#29401)
  - hexagon: add q5_k quant type support (ggml-org#29123)
  - hexagon: use DMA for contiguous dim1 CONCAT (ggml-org#29404)
  - mtmd: fix mel preprocessor in LFM2 audio (ggml-org#29403)
  - vulkan: fix legacy GLSLC without cooperativeMatrix (ggml-org#29409)
  - gguf-py: ByteLevel processing defaults bos/eos to False (ggml-org#29422)
  - gguf-py: TemplateProcessing has final word on add_special_token (ggml-org#29417)

Assisted-by: Pi
sky-mighty pushed a commit to sky-mighty/llama.cpp that referenced this pull request Sep 26, 2026
* metal : split fa kernels into per-dtype libraries

Assisted-by: pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp

* cont : minor fix comment
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
* metal : split fa kernels into per-dtype libraries

Assisted-by: pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp

* cont : minor fix comment
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 7, 2026
* metal : split fa kernels into per-dtype libraries

Assisted-by: pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp

* cont : minor fix comment

(cherry picked from commit 5a75f14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Apple Metal https://en.wikipedia.org/wiki/Metal_(API) ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant