Skip to content

metal: implement DSv4 Lightning Indexer#25893

Draft
tarruda wants to merge 1 commit into
ggml-org:masterfrom
tarruda:dsv4-metal-lightning-indexer
Draft

metal: implement DSv4 Lightning Indexer#25893
tarruda wants to merge 1 commit into
ggml-org:masterfrom
tarruda:dsv4-metal-lightning-indexer

Conversation

@tarruda

@tarruda tarruda commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Overview

Metal backend for GGML_OP_LIGHTNING_INDEXER

Additional information

This is the first of a series of changes that target improving DSv4 performance on Apple Silicon. I extracted this commit from my dsv4-improvements branch, which includes metal backends for hyper-connections and a few other improvements.

On master branch, these are some performance numbers of DSv4 on my M1 Ultra (llama-bench --mmap 1, -fa 1, -p 512, -n 128; d=0/10k/20k/30k, benchmarking this quant):

  • pp512: 153.73 ± 0.87 t/s
  • tg128: 8.91 ± 0.04 t/s
  • pp512 @ d10000: 73.90 ± 0.39 t/s
  • tg128 @ d10000: 8.66 ± 0.03 t/s
  • pp512 @ d20000: 45.83 ± 0.18 t/s
  • tg128 @ d20000: 8.26 ± 0.03 t/s
  • pp512 @ d30000: 33.40 ± 0.21 t/s
  • tg128 @ d30000: 7.94 ± 0.01 t/s

With this commit, things improve slightly:

  • pp512: 155.19 ± 0.91 t/s
  • tg128: 8.95 ± 0.04 t/s
  • pp512 @ d10000: 86.95 ± 0.69 t/s
  • tg128 @ d10000: 9.00 ± 0.05 t/s
  • pp512 @ d20000: 62.01 ± 0.45 t/s
  • tg128 @ d20000: 8.68 ± 0.04 t/s
  • pp512 @ d30000: 49.18 ± 0.33 t/s
  • tg128 @ d30000: 8.60 ± 0.02 t/s

With all commits from my branch, this is what it looks like:

  • pp512: 168.67 ± 0.82 t/s
  • tg128: 23.59 ± 0.06 t/s
  • pp512 @ d10000: 151.10 ± 0.55 t/s
  • tg128 @ d10000: 20.87 ± 0.13 t/s
  • pp512 @ d20000: 145.98 ± 0.45 t/s
  • tg128 @ d20000: 20.68 ± 0.13 t/s
  • pp512 @ d30000: 141.91 ± 0.29 t/s
  • tg128 @ d30000: 20.56 ± 0.06 t/s

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, this is 100% generated by GPT 5.6 Sol. I have reviewed and tested the changes, but I am not a Metal kernel developer and thus cannot judge the quality of these changes. Hopefully the maintainers can extract something as the compounded performance improvements can make DSv4 flash very usable with a local coding harness. CC @ggerganov @fairydreaming

- Implement GGML_OP_LIGHTNING_INDEXER for 128-dimensional, 64-head inputs
  with F32 queries and weights plus F16 keys and masks.
- Add tiled and tail kernels and test KV lengths around 8- and 64-element
  boundaries.

llama-bench (--mmap 1, -fa 1, -p 512, -n 128; d=0/10k/20k/30k):

Before:
- pp512: 153.73 ± 0.87 t/s
- tg128: 8.91 ± 0.04 t/s
- pp512 @ d10000: 73.90 ± 0.39 t/s
- tg128 @ d10000: 8.66 ± 0.03 t/s
- pp512 @ d20000: 45.83 ± 0.18 t/s
- tg128 @ d20000: 8.26 ± 0.03 t/s
- pp512 @ d30000: 33.40 ± 0.21 t/s
- tg128 @ d30000: 7.94 ± 0.01 t/s

After:
- pp512: 155.19 ± 0.91 t/s
- tg128: 8.95 ± 0.04 t/s
- pp512 @ d10000: 86.95 ± 0.69 t/s
- tg128 @ d10000: 9.00 ± 0.05 t/s
- pp512 @ d20000: 62.01 ± 0.45 t/s
- tg128 @ d20000: 8.68 ± 0.04 t/s
- pp512 @ d30000: 49.18 ± 0.33 t/s
- tg128 @ d30000: 8.60 ± 0.02 t/s

Assisted-by: Codex
@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning Apple Metal https://en.wikipedia.org/wiki/Metal_(API) labels Jul 19, 2026
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 testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant