Repository navigation
model: Minimax M3, Replace the CPU OP during prefill - #26297
Conversation
am17an
left a comment
There was a problem hiding this comment.
How did this even go in 😅 ?
|
Performance degradation, it works 2 times slower after the update |
|
Hm, I can't say I can reproduce this. Prefill and decode speed are the same for me before and after with prefill at ~480 tok/s and decode at ~7.8 tok/s respectively. If anything I'd expect this to be faster for gpu heavy setups. The changes here should have only altered the prefill behavior as well 🤔 |
|
@timkhronos the next releae https://github.com/ggml-org/llama.cpp/releases?page=2#release-b10189 works slow |
|
I'm also seeing a massive slowdown from b10142 to the current master. I thought it was something in my settings as I'm new to this so, I been messing with them, but now have run both b10142 and current master, both built with the same build and launch settings: I'll try and build something in the middle to see when it started. I'm running 3 x RTX 6000 pro, all layers on GPU. llama-server -m C:\models\IQ4_XS\MiniMax-M3-IQ4_XS-00001-of-00006.gguf -c 50000 --load-mode none --no-ui --no-kv-offload --prio 2 --parallel 1 --flash-attn on --slots --cache-ram 0 --host 127.0.0.1 --port 8080 --jinja -ngl 99 --fit off --tensor-split 11,11,9 -sm layer -ub 2048 -b 2048 --threads 12 --cache-type-k f16 --cache-type-v f16 --spec-type ngram-mod --spec-ngram-mod-n-match 24 --spec-ngram-mod-n-min 48 --spec-ngram-mod-n-max 64 With b10142 prompt processing about 1250 t/s: With current master identical settings and prompt about 80 t/s: |
|
@timkhronos |
|
Yes b10188 is a little slower but still fast on the prompt processing for me @ about 1120 t/s: |
|
And b10189 is down to 77 t/s: I should add I using CUDA 13.3 |
|
@timkhronos The size of CUDA buffers was increased x2, so everything works slow |
|
@smalinin @Aidan24 Thanks, that's both very useful. I have a good idea of what it might be. I think cuda's top_k takes a much slower path when compiled with CCCL>=3.2, and this might be the first model that feeds it large batch shapes. I'll write up my full theory, but if you both could run a quick test to confirm it: @Aidan24 Cuda 13.3 bundle a CCCL >= 3.2 I think. Could you please rebuild master against an older toolkit? 13.2 or older. Anything where @smalinin if you were able to build from source with a cuda toolkit that's <= 13.2 with the default flags the same comparassion would help. |
|
@timkhronos I use CUDA 13.0 |
|
@smalinin Yes, but you use the prebuilt binaries I believe? Those are compiled with |
|
@timkhronos No, I build my binaries from source code always |
|
@smalinin Thanks, I thought by fresh binaries you meant the release zips. In that case your issue looks to be a different one from Aidan internally. The new graph allocates a larger compute buffer/ moves some of it from the cpu onto the gpu, which can displace weights on memory tight setup. If you can confirm it then I'll see what I could do about it. Could you please post your Ram + Vram, your gguf's size, the Cuda0 compute buffer size/ compute buffer lines from model load for both builds, and your offloaded layers line for both plus your launch command? |
|
It seems that CUDA toolkit 13.2 is also CCCL 3.2. I'll try an earlier one :( |
|
@Aidan24 Sorry, my bad, my driver's cuda version was 13.2, but my toolkit was 13.1. Could you please try with that? That should bundle a CCCL version below <3.2 |
|
Sorry that took a while, I had a crash. I may have a heat issue... That seems to have cracked it. b10189 built with CUDA Toolkit 13.1 Prompt processing back to about 1250 t/s Now all I have to do is find out what I fiddled with that has slowed down my generation from about 30 t/s to 1.5 t/s... |
|
@timkhronos Anayze fix with chatgpt: Problems in #26297:
Required fixes:
|
|
@Aidan24 Thank you, this helped pin down your half. I think you and @smalinin ran into two separate issues both caused by this PR. Your issue is that the new batch calls ggml_top_k on HD * n_tps rows. In top-k.cu when CCCL version is >= 3.2, the implementation is a sequential loop, one DeviceTopK::MaxPairs dispatch per row. The decode branch only ever has around ~8 rows, so this was mostly harmless with the cpu op for prefill. During batch with -ub 2048, that's up to ~16k serialized dispatches per layer per ubatch. With CCCL < 3.2 (what I was building with), the op compiles to a batched argsort which is a single launch for all rows, which is much faster. I think this may also be why your decode got slower, since you are using speculative decoding which verifies batches that are n_tokens > 1, and therefore take the new batched branch as well, whereas previously the custom op handled the selection In fact I think this might start becoming an issue if more people start upgrading their toolkits and or as more models begin using top-k for batch processing. This should affect everyone with CCCL 3.2 or newer/ toolkit 13.2 or newer. I think this could become problematic as this can't really be bisected to any llama commit. I'll open a PR adding an nrows check to top-k that falls back to the existing batched argsort instead of the per_row DeviceTopK. I'd appreciate it if you were able to test if that fixes it for you. on 13.2/13.3. @smalinin I think your issue is that since the reserve time is a worst case and the new graph materializes intermediates the old custom op never did, it allocates enough extra space where it pushes enough weights off your gpu(s) that you experience the slow down. That is my best theory for your case. If you could please provide the logs I asked for I'll look into your issues as well (I just saw you did, I'll take a look after the Top-k thing) |
|
It turns out that if I remove the --no-kv-offload it goes from 1.5 t/s generation to ~30 t/s generation. Which is the opposite of what I would expect. But still runs OK and fast. I'm not sure why it's trying to allocate that much more memory on device 1 because of removing -no-kv-offload, and anyway I have a total of about 60 GB VRAM unused as far as I can see, but I am new to this so might be misunderstanding how this works. With 288GB VRAM and a IQ4_XS model and 50k context, I would have though it should all fit in VRAM easily. This is what I am now starting with:
Still on b10189 at the moment. |
|
@Aidan24 --no-kv-offload keeps the kv cache on your system ram, which is why you slowed down with it so much I am pretty sure. And you should be fitting comfortably, I am able to run the model on a single 5090 + 256gb system ram, and I am running Q4_k_m. This is how I launch in case it helps anyhing. With that my compute buffer size is 5Gb. Also when you have the time could you please try building #26390 with your 13.3 toolkit to see if it resolves the massive prompt processing regression with CCCL >= 3.2? |
|
Thanks, I got my understanding of kv offload completely the wrong way round. I am trying to build with 13.2.2 but my machine has had a total meltdown. I think I maybe didn't cleanly remove something Nvidia when changing versions or had a driver mismatch. It got into a memory management and page fault in non paged area boot loop. I'm rebuilding it now and will test as soon as I can. |
|
Finally built the cpp-Top-K branch with I'm afraid I no longer have the same prompt to load, but with a shorter one it seems very fast @ ~1600 t/s: |
|
@timkhronos Interestingly even with Q8_0 for kv cache I'm still seeing: All 3 graphics cards are showing space available. Do I need to adjust the tensor split so most of the available space is on device 1? I've not seen this with any other model, I seem to be able to utilize a much higher proportion of the available space. This is what I started it with this time And after the model is loaded and the prompt processed, this is what is showing available: -Update- |
Overview
Replaces the previous prefill only cpu MSA block selection op with one built out of stock ggml operations.
Should eliminate the gpu -> cpu ->gpu sync trip during prefill. Also fixes: #26260.
On my offload setup, with the majority of the model in system ram, this produced no measurable performance change, but I'd expect the impact to be greater for fully GPU resident setups.
Additional information
Requirements