Repository navigation
Conversation
ggml-org#29029 made supports_op reject every MUL_MAT_ID with GGML_PREC_F32 on src1. For Mistral 4 this moves the ffn_moe_down op of every layer to the CPU during token generation (41 -> 3.4 t/s on a Radeon 8060S). The overflow on the mat-vec path comes from MMVQ (src1 quantized to q8_1). Skip MMVQ when the op is flagged and only reject the batched path. Add n=1/4/8 cases and Q5_K/Q6_K to the src1 f16 overflow tests. Assisted-by: Claude Opus 5.5
0cc4m
left a comment
There was a problem hiding this comment.
this is generally valid, I've got a larger branch I'm working on for all precision changes. But it's okay to do this separately first.
… F32 and the wrong comment is gone.
|
@ggerganov @CISC https://github.com/ggml-org/llama.cpp/actions/runs/38710930783/job/116359711341?pr=30544 Do you know what caused this? I don't think it was this PR. test-llama-context |
I think it is, as it happens on |
|
This change is very similar to #30105. My feedback on that one applies here as well. |
|
You mean the feedback about adding a function to get the src1_prec value? |
|
Yes, and Georgi's reply about explicitly handling all prec enums in a switch statement. |
supports_op made F32-precision MUL_MAT_ID depend on the batch size (GPU for mat-vec, CPU otherwise), so the graph splits differed between the reserved and actual graphs and test-llama-context aborted on mistral4-moe with GGML_SCHED_DEBUG_REALLOC=1. The batched path now honors src1 precision F32/BF16: it uses new f32 shared memory MUL_MAT_ID pipelines with f32 accumulation, never quantizes src1 to q8_1 or rounds it to f16, and copies non-contiguous src1 to the kernel's B type. supports_op only falls back to CPU when those pipelines are missing, independent of the batch size.
|
Looks like I opened a can of worms. Fixing that one spot wasn't enough. On GPUs with fp16 support, the batch kernels hold their inputs as f16 in shared memory (the GPU's fast scratch memory) even when the input is F32. Values above 65504, the largest f16 number, turned into NaN, which is why the n ≥ 16 cases failed. Full-F32 versions of the same kernels (*_fp32) were already compiled, but only loaded on GPUs without fp16. Changes (ggml-vulkan.cpp, ggml-vulkan-types.h):
Some caveats
|
|
#30656 should cover these cases in a much more performant way. |
|
@0cc4m - does that mean this should be closed instead of merged? |
…path giving NaN on AMD's GPU (ggml-org/llama.cpp#30544: a Radeon 8060S under RADV, Q4_K and Q5_K, cleared by GGML_VK_DISABLE_INTEGER_DOT_PRODUCT) [skip ci] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Overview
Since #29029 (0f8a414), Mistral Small 4 token generation on Vulkan dropped from ~41 t/s to ~3.4 t/s. Prompt processing is unaffected.
#29029 sets GGML_PREC_F32 on src1 of the Mistral 4
ffn_moe_downMUL_MAT_ID, and the Vulkansupports_opnow returns false for any MUL_MAT_ID with that flag. That includes the mat-vec path used for token generation, so every layer's down projection goes to the CPU and the graph is split per layer.GGML_VK_PERF_LOGGERconfirms the Q5_K/Q6_K MUL_MAT_ID ops are missing from the Vulkan timings.The rejection is needed for the mat-vec path as it is: with n=1/4/8 added to the existing "src1 f16 overflow" tests, Vulkan returns NaN for Q4_K and Q5_K at amax=1e5/3e5. The cause is MMVQ (src1 quantized to q8_1). With
GGML_VK_DISABLE_INTEGER_DOT_PRODUCT=1all of these cases pass. Q6_K and Q8_0 pass either way.This PR:
ggml_vk_mul_mat_vec_id_q_f16when the op has GGML_PREC_F32 setsupports_opwhen it would not use the mat-vec path (batched cases still fall back as before)Additional information
Hardware: AMD Ryzen AI Max (Strix Halo), Radeon 8060S (gfx1151), RADV / Mesa 26.0.8, Linux 7.0, uma: 1, int dot: 1.
Model: unsloth/Mistral-Small-4-119B-2603-GGUF UD-Q4_K_XL (gate_up_exps Q4_K, down_exps Q5_K/Q6_K).
llama-bench -ngl 99 -fa 1 -p 512 -n 32:Found with git bisect on a 4-layer cut of the same model (199 vs 28 t/s; 199 t/s with this PR).
test-backend-ops -o MUL_MAT_ID -b Vulkan0and-o MUL_MAT -b Vulkan0pass, including the new cases. Output of the full model with this PR is coherent at temp 0.CUDA has the same unconditional rejection in
supports_opand is probably affected in the same way. I can't test CUDA, so this PR only changes Vulkan.Requirements