Skip to content

vulkan : support non-contiguous src in SCALE - #32735

Merged
0cc4m merged 1 commit into
ggml-org:masterfrom
Revertron:inkling-2-mini-vulkan-opt
Nov 22, 2026
Merged

0cc4m merged 1 commit into
ggml-org:masterfrom
Revertron:inkling-2-mini-vulkan-opt

Conversation

@Revertron

@Revertron Revertron commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Overview

I've tried the new model Inkling 2 Mini that gave only 20 tok/s on my R9700. The GPU was utilized around 47% on decode, and about 5% was on copy. So, I tried to find the issue and fix it.
The issue is that Vulkan's supports_op rejected SCALE on non-contiguous input, so the scheduler sent those ops to the CPU. In build_moe_ffn, SiTU applies SCALE to the gate and up halves of the fused gate_up output, but because these are non-contiguous, strided views, Vulkan rejects them, forcing both scale operations in every layer to run on the CPU and resulting in 194 graph splits.

After my fix scale.comp indexes through src0_idx()/dst_idx(), as log.comp and other unary shaders do. Those strides were already in the push constants. The contiguity check is dropped from supports_op. That brings Vulkan in line with CUDA and Metal, which already accept this.

Additional information

Used Inkling-2-Mini-UD-Q8_K_XL.gguf from Unsloth repo (from Mainline_Support folder) on my Radeon AI PRO R9700.

test before (b019be0c, master) after (0ea4ffd0, fix) change
pp512 507.3 +/- 5.3 1604.8 +/- 7.8 3.2x
tg128 19.1 +/- 2.6 53.8 +/- 0.2 2.8x
pp512 @ d16384 388.1 +/- 4.0 892.9 +/- 28.6 2.3x
tg128 @ d16384 18.9 +/- 0.4 47.8 +/- 0.6 2.5x

Tested with llama-bench -ngl 99 -fa 1 -ctk q8_0 -ctv q8_0 -p 512 -n 128 -d 0,16384 -r 3.

And the splits in log went from 194 to 2. Long-context output checked on a coding task in my harness - it worked for 22 minutes and finished the test project successfully.
The existing non-contiguous SCALE view tests used to be skipped on Vulkan and now run, I've added an f16 view case.

Also, this slowness is mentioned in issue #32707. It doesn't close that issue, since others there report slowness on CUDA, which this fix doesn't touch, but may help in identifying the cause.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, Opus 5.5 in Claude Code helped me identify the problem and made a patch. I've reviewed and tested it.

@Revertron
Revertron requested review from a team and ggerganov as code owners November 21, 2026 14:04
@github-actions github-actions Bot added testing Everything test related Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Nov 21, 2026
@Revertron

Copy link
Copy Markdown
Contributor Author

Should I do something about failed check?

@0cc4m

0cc4m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

No, we're just waiting for CI to finish.

ryanabx pushed a commit to ryanabx/llama.cpp that referenced this pull request Nov 21, 2026
ryanabx pushed a commit to ryanabx/llama.cpp that referenced this pull request Nov 22, 2026
@0cc4m
0cc4m merged commit 8a97fa9 into ggml-org:master Nov 22, 2026
31 of 32 checks passed
Lanilen added a commit to Lanilen/llama.cpp that referenced this pull request Nov 22, 2026
…upstream's head, Vulkan and ROCm

llama-bench on one R9700, two passes each, the fork (f7d126a) against upstream at e300919, which has its own fix for
the SCALE of a view (ggml-org#32735) and the loop fix: UD-Q4_K_XL generates at 48.0-48.2 tok/s against 37.1-37.3 (Vulkan) and
33.7 (ROCm), the Q8_0 at 46.2 against 36.2 and 31.2; prompts of 512 within 1-3% of ROCm, at a depth of 2048 57-60% ahead
of it. The guide's R9700 section and FORK.md's line take these in place of the numbers against the fork's base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@garrettkajmowicz

Copy link
Copy Markdown

FYI: It appears that this change took my test run documented here:

#32785

From 212 splits to 20!
Prompt processing went from about 50 t/s to 58 t/s and inference on a trivial prompt went from 6.4 t/s to 9.6 t/s

Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
davidtaylor6130 added a commit to davidtaylor6130/InferDeck that referenced this pull request Nov 23, 2026
Moves llama.cpp from the PR head 0ea4ffd00 to upstream master 8a97fa98a, the merge commit of ggml-org/llama.cpp#32735. The only API delta is additive mtmd audio fields, which InferDeck does not use.
Kidplayer666 pushed a commit to Kidplayer666/llama.cpp that referenced this pull request Nov 23, 2026
@misterkerns

Copy link
Copy Markdown

Windows Vulkan confirmation on one AMD Radeon AI PRO R9700. Official ggml-org Inkling-2-Mini-IQ4_NL, llama-server -c 2048 -fa off -ngl 99 --no-mmproj.

Raw /completion, n_predict 128, prompt "The capital of France is":

  • b12600: 23.77 tok/s
  • b12628 (8a97fa98a): 66.06 tok/s

A 17×3 chat returned 51 on both builds. One shot from llama-server timings, not llama-bench, and flash attention was off. Different quant and harness from the Q8_K_XL table above.

@misterkerns

Copy link
Copy Markdown

Follow-up on the same Radeon AI PRO R9700, Windows Vulkan b12628 (8a97fa9), official Inkling-2-Mini IQ4_NL.

llama-server -c 17408 -fa off -ngl 99 --no-mmproj. One raw /completion, not llama-bench (no context cap, and this GGUF defaults to 1M). Prompt was 16378 tokens so 128 generated tokens fit.

prompt 943.88 tok/s, predicted 128 at 54.38 tok/s.

The PR table is Q8_K_XL, FA on, llama-bench tg128 47.8 at depth 16384. Different quant and harness. Short-context pair on this machine is unchanged: 66.06 at -c 2048, FA off.

Lanilen added a commit to Lanilen/llama.cpp that referenced this pull request Nov 24, 2026
… own

The base is upstream f4f6f2e. Upstream's weight scales (ggml-org#32669), the lightning indexer always fused (ggml-org#32650), SCALE through the strides (ggml-org#32735, the fork's own change line for line) and the whole copy of a looped model's experts (ggml-org#32807, kept to the shared tensors). docs/inkling2-mini.md no longer lists the loop fix and the SCALE as the fork's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pratiknarola-t added a commit to tetherto/qvac-fabric-llm.cpp that referenced this pull request Nov 24, 2026
Port of ggml-org#32735. Inkling 2's SITU activation scales the
strided gate and up views of the fused gate_up output; with a contiguous
src required, both SCALEs ran on the CPU, two round trips per MoE layer.
Inkling 2 Mini UD-Q4_K_XL on RADV gfx1151: pp512 +39%, tg128 +40%.

test-backend-ops adds a view that starts half a row in, like the up half
of gate_up.
pratiknarola-t added a commit to tetherto/qvac-fabric-llm.cpp that referenced this pull request Nov 26, 2026
Port of ggml-org#32735. Inkling 2's SITU activation scales the
strided gate and up views of the fused gate_up output; with a contiguous
src required, both SCALEs ran on the CPU, two round trips per MoE layer.
Inkling 2 Mini UD-Q4_K_XL on RADV gfx1151: pp512 +39%, tg128 +40%.

test-backend-ops adds a view that starts half a row in, like the up half
of gate_up.
dzannotti pushed a commit to halo-box/strix-llama.cpp that referenced this pull request Nov 26, 2026
Backport of upstream 8a97fa9 (ggml-org#32735). scale.comp indexes src and dst with src0_idx / dst_idx, so supports_op no longer needs a contiguous src. Before, the scheduler put every SCALE of a view on the CPU: Inkling 2 Mini's situ activation scales the gate and up views of the merged gate_up output, 96 SCALE ops per decoded token, 194 graph splits instead of 2.

Upstream's F16 view test is not added: Vulkan SCALE in this fork is F32 only.

Assisted-by: Claude Code
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 testing Everything test related Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants