Repository navigation
cuda: unblock mmq for MoE on sm_60 - #26264
Conversation
am17an
left a comment
There was a problem hiding this comment.
I have not tested this since I don't have a Pascal device but it looks to okay to me
|
I tested this PR and recorded the prefill results on 2x Tesla P100, stock master
Best config vs best config, on a 5-repeat re-run: +2.3%. I used The |
|
Yeah, reproducing with I guess I'll convert this to a draft until I can get a closer look at which quants make sense for the P100 to support for mmq. |
|
I ran some tests with exps quantized to most types, and there are some that get a lot worse with mmq, with others more than doubling. For most types, both
scripts used for testing_quants=(
Q1_0 Q2_0 Q4_0 Q4_1 Q5_0 Q5_1
IQ1_S IQ1_M IQ2_XXS IQ2_XS IQ2_S IQ3_XXS IQ3_S IQ4_XS IQ4_NL
Q2_K Q3_K Q4_K Q5_K Q6_K
)
for q in "${_quants[@]}"
do
llama-quantize --tensor-type "exps=$q" --tensor-type "blk|embd|out=q4_0" --imatrix Qwen3.6-35B-A3B-imatrix.gguf Qwen3.6-35B-A3B-BF16.gguf "qwen35moe-$q.gguf" "$q"
doneexport CUDA_VISIBLE_DEVICES=0,1
_quants=(
Q1_0 Q2_0 Q4_0 Q4_1 Q5_0 Q5_1
IQ1_S IQ1_M IQ2_XXS IQ2_XS IQ2_S IQ3_XXS IQ3_S IQ4_XS IQ4_NL
Q2_K Q3_K Q4_K Q5_K Q6_K
)
for q in "${_quants[@]}"
do
llama-bench -m "qwen35moe-$q.gguf" -lm dio -ngl 999 -ub 2048 -p 2048 -n 32 -sm layer,tensor
doneI'm planning to switch on quant type for the P100 in |
|
I've finished testing all quants that support mmq right now, here's the last few ones:
Apart from IQ1_M, which has no mmq (is this an oversight?), the only quants that do not benefit from mmq are Q2_K, Q4_K, Q5_K and Q6_K. Those quants will not use mmq on the P100 right now, but there's a TODO in there to check what the issue might be. |
|
@am17an would it be alright to ask for a re-review? If you need me to run more tests I can do so as well. I'm planning to look into tuning sm_60 mmq configs in a future PR unless you want it part of this one. K-quant changes will need to be a separate PR either way unless the slowdowns are just disastrous tuning. |
|
I don't have hardware to test this, so I would rely on other people's reports on this patch. |
|
I did a small test with Ornith-1.0-35B-UD-IQ4_NL.gguf, My pp stats in llama-server went from ~300 (layer, tensor was ~200) to ~900 (tensor). Token/s is close to the same 50-60. Very happy with this. But it did nothing on Q5_XL. |
|
From what I could see the slowdown was indeed just terrible tuning causing lots of spilling on the P100. I duplicated the mmq config ( @mb8565 , @Kenzu could I ask the both of you to retest with whatever models you were testing before, including the ones you didn't get any speed-ups with? You should get a small speed-up on I've been meaning to do a full tune of the mmq config, but the first results I got regressed for MoE so I'll have to do all of it again. |
IMbackK
left a comment
There was a problem hiding this comment.
looks fine to me, but cant test either
|
Retested on 2x Tesla P100 at master
You were right in July about the UD quant. Its I only re-ran the stock default. DeepSeek-V2-Lite-REAP48 does not load under |
|
Correcting the +99.8% from my last comment. Best against best on Qwen is +38.8%, which is 733.33 / 528.37. Those two runs were not the same setup. Four things were different. 733.33 is the stock default with Here are the three configs I skipped. All
|
* cuda: unblock mmq for MoE on sm_60 * cuda: duplicate mmq-config-pascal for dp4a and older * cuda: reduce occupancy on non-dp4a pascal for Q2_K, Q4_K, Q5_K, Q6_K
* cuda: unblock mmq for MoE on sm_60 * cuda: duplicate mmq-config-pascal for dp4a and older * cuda: reduce occupancy on non-dp4a pascal for Q2_K, Q4_K, Q5_K, Q6_K
* cuda: unblock mmq for MoE on sm_60 * cuda: duplicate mmq-config-pascal for dp4a and older * cuda: reduce occupancy on non-dp4a pascal for Q2_K, Q4_K, Q5_K, Q6_K
Overview
Tesla P100's get a nice (~20%) pp speedup by using mmq even without native dp4a. For
-sm tensorconfigurations with multiple cards, this increases to around a +100% pp speedup (for 2 cards, possibly more with more cards).This PR is similar to, but inverse of, it's inspiration: #24588, where gfx900 had mmq always turned on even without dp4a, and kept mmq for MoE. sm_60 will now use mmq, but only for MoE.
This might be relevant for even older NVidia hardware as well, but I only have access to a 4GB Quadro that might not be a good reference point (and no models that come to mind). For now it's gated to only the P100.
Additional information
Tests are on two P100 cards (powerlimited to 150W, connected via PCIe 3.0 x8). See comments below for tests for each quantization type (exps quantized to type tested, all other tensors Q4_0).
I tested single card performance for quantization types that fit on one card, and the speed-up closely matches
-sm layerimprovements.original test, prefer results in comments below
`GGML_CUDA_P2P=1 llama-batched-bench -dev CUDA0,CUDA1 -sm tensor -no-kvu -ngl all -fa on -fit off -ub 2048 -ctk q8_0 -ctv q8_0 -npp 0,128,512,1024,2048,4096,32768,65536 -ntg 128 -npl 1 -m Qwen3.6-35B-A3B-Q4.gguf`master:
this pr:
Requirements