Skip to content

ggml : use SpacemiT IME in flash attention and support head size <= 256 - #32194

Open
velonica0 wants to merge 2 commits into
ggml-org:masterfrom
velonica0:spacemit-fa-ime
Open

velonica0 wants to merge 2 commits into
ggml-org:masterfrom
velonica0:spacemit-fa-ime

Conversation

@velonica0

@velonica0 velonica0 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Speed up the SpacemiT flash attention path on K3 A100 cores (VLEN=1024). Depends on #32182.

Two commits:

  1. Support head size <= 256 (was <= 128, so e.g. Qwen3.5/Gemma 2 used the generic CPU path). Decode kernels pick LMUL by head size.
  2. Use IME vfwmadot for QK^T and PV in the tiled (prefill) kernel; tile functions in ime2_kernels.cpp, guarded like the other IME2 kernels.

Additional information

K3, A100 cores, GCC 15.2, -DGGML_CPU_RISCV64_SPACEMIT=ON, process started on an A100 core.

test-backend-ops test -b CPU -o FLASH_ATTN_EXT: 5721/5721

llama-bench -t 8 -fa 1, master (5676dfb) vs this PR, t/s:

Qwen3.5-9B Q4_K_M (head size 256):

depth pp512 master pp512 PR speedup tg32 master tg32 PR speedup
0 24.98 25.43 1.02 4.25 4.31 1.01
1024 23.33 25.01 1.07 3.21 4.21 1.31
2048 21.85 24.14 1.10 2.67 4.17 1.56
4096 19.00 23.25 1.22 2.01 4.05 2.01
8192 15.73 22.10 1.40 1.33 3.84 2.89

Qwen2.5-1.5B Q4_0 (head size 128):

depth pp512 master pp512 PR speedup tg32 master tg32 PR speedup
0 238.97 243.79 1.02 25.86 25.88 1.00
4096 81.91 95.64 1.17 15.00 14.86 0.99

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes. AI tools assisted with code changes, testing, review.

@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Nov 13, 2026
@velonica0 velonica0 changed the title Spacemit fa ime ggml : use SpacemiT IME in flash attention and support head size <= 256 Nov 13, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

Hi @velonica0, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • Multiple open PRs from a new contributor: We limit new contributors (those without a previously merged PR) to 1 open PR at a time. You currently have 2 open PRs.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@velonica0

Copy link
Copy Markdown
Contributor Author

PTAL @alex-spacemit

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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