Skip to content

model: Minimax M3, Replace the CPU OP during prefill - #26297

Merged
am17an merged 1 commit into
ggml-org:masterfrom
timkhronos:MSA-Backend-Prefill
Jul 30, 2026
Merged

am17an merged 1 commit into
ggml-org:masterfrom
timkhronos:MSA-Backend-Prefill

Conversation

@timkhronos

Copy link
Copy Markdown
Contributor

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

@timkhronos
timkhronos requested a review from CISC as a code owner July 29, 2026 22:17
@github-actions github-actions Bot added the model Model specific label Jul 29, 2026

@am17an am17an left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this even go in 😅 ?

@am17an
am17an merged commit b2f2216 into ggml-org:master Jul 30, 2026
21 of 26 checks passed
@timkhronos
timkhronos deleted the MSA-Backend-Prefill branch July 31, 2026 01:05
@smalinin

Copy link
Copy Markdown
Contributor

Performance degradation, it works 2 times slower after the update
Before update I had about 24tok/sec for IQ3_S ( https://huggingface.co/AesSedai/MiniMax-M3-GGUF)
Now I have only 12-14tok/sec

@timkhronos

timkhronos commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

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 🤔

@smalinin

Copy link
Copy Markdown
Contributor

@timkhronos
I have retested with fresh binaries:
last fast release https://github.com/ggml-org/llama.cpp/releases?page=2#release-b10188

[59629] 3.07.319.463 I slot print_timing: id  0 | task 177 | n_decoded =    100, tg =  24.13 t/s, tg_3s =  24.13 t/s
[59629] 3.10.346.455 I slot print_timing: id  0 | task 177 | n_decoded =    171, tg =  23.85 t/s, tg_3s =  23.46 t/s
[59629] 3.13.380.557 I slot print_timing: id  0 | task 177 | n_decoded =    243, tg =  23.81 t/s, tg_3s =  23.73 t/s
[59629] 3.16.386.074 I slot print_timing: id  0 | task 177 | n_decoded =    314, tg =  23.77 t/s, tg_3s =  23.62 t/s
[59629] 3.19.393.668 I slot print_timing: id  0 | task 177 | n_decoded =    385, tg =  23.74 t/s, tg_3s =  23.61 t/s

the next releae https://github.com/ggml-org/llama.cpp/releases?page=2#release-b10189 works slow

[51623] 1.01.265.741 I slot print_timing: id  0 | task 0 | n_decoded =    100, tg =  14.86 t/s, tg_3s =  14.86 t/s
[51623] 1.04.267.882 I slot print_timing: id  0 | task 0 | n_decoded =    144, tg =  14.80 t/s, tg_3s =  14.66 t/s
[51623] 1.07.301.519 I slot print_timing: id  0 | task 0 | n_decoded =    189, tg =  14.81 t/s, tg_3s =  14.83 t/s
[51623] 1.10.304.280 I slot print_timing: id  0 | task 0 | n_decoded =    233, tg =  14.78 t/s, tg_3s =  14.65 t/s
[51623] 1.13.376.292 I slot print_timing: id  0 | task 0 | n_decoded =    277, tg =  14.70 t/s, tg_3s =  14.32 t/s
[51623] 1.16.396.297 I slot print_timing: id  0 | task 0 | n_decoded =    321, tg =  14.68 t/s, tg_3s =  14.57 t/s
[51623] 1.19.456.042 I slot print_timing: id  0 | task 0 | n_decoded =    366, tg =  14.69 t/s, tg_3s =  14.71 t/s

@Aidan24

Aidan24 commented Jul 31, 2026 •

Copy link
Copy Markdown

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:
cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="120" -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA_FA_ALL_QUANTS=ON -DGGML_CUDA_NCCL=OFF -DGGML_USE_NCCL=OFF

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:

0.49.463.219 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   4096, progress = 0.12, t =   3.18 s / 1289.87 tokens per second
0.51.289.356 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   6144, progress = 0.18, t =   5.00 s / 1228.39 tokens per second
0.53.316.565 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   8192, progress = 0.24, t =   7.03 s / 1165.48 tokens per second

With current master identical settings and prompt about 80 t/s:

1.07.570.085 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   2048, progress = 0.06, t =  24.07 s / 85.08 tokens per second
1.33.622.245 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   4096, progress = 0.12, t =  50.12 s / 81.72 tokens per second
2.00.695.855 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   6144, progress = 0.18, t =  77.20 s / 79.59 tokens per second

@smalinin

Copy link
Copy Markdown
Contributor

@timkhronos
Degradation for prefill is existed also:
for release b10188 prefill = 500 tok/sec
for release b10189 prefill = 250 tok/sec

@Aidan24

Aidan24 commented Jul 31, 2026

Copy link
Copy Markdown

Yes b10188 is a little slower but still fast on the prompt processing for me @ about 1120 t/s:

0.51.836.321 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   4096, progress = 0.12, t =   3.60 s / 1138.93 tokens per second
0.53.689.379 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   6144, progress = 0.18, t =   5.45 s / 1127.46 tokens per second
0.55.721.236 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   8192, progress = 0.24, t =   7.48 s / 1095.00 tokens per second

@Aidan24

Aidan24 commented Jul 31, 2026

Copy link
Copy Markdown

And b10189 is down to 77 t/s:

1.12.635.464 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   2048, progress = 0.06, t =  25.32 s / 80.89 tokens per second
1.40.310.327 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   4096, progress = 0.12, t =  52.99 s / 77.29 tokens per second
2.08.914.800 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   6144, progress = 0.18, t =  81.60 s / 75.29 tokens per second

I should add I using CUDA 13.3

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Tue_Jun__9_14:30:19_Pacific_Daylight_Time_2026
Cuda compilation tools, release 13.3, V13.3.73
Build cuda_13.3.r13.3/compiler.38244171_0

@smalinin

Copy link
Copy Markdown
Contributor

@timkhronos The size of CUDA buffers was increased x2, so everything works slow

@timkhronos

Copy link
Copy Markdown
Contributor Author

@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 CCCL_MAJOR_VERSION/CCCL_MINOR_VERSION in the toolkit's headers read below 3.2 and rerun the same test? My build is on CCCL 3.1.4 which would explain why I can't reproduce it.

@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.

@smalinin

smalinin commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

@timkhronos I use CUDA 13.0
The issue isn't related with CUDA, it is too complex issue, fix must be full updated

@timkhronos

Copy link
Copy Markdown
Contributor Author

@smalinin Yes, but you use the prebuilt binaries I believe? Those are compiled with -DGGML_CUDA_CUB_3DOT2=ON I am pretty sure, which forces them to use CCCL 3.2 which I think is the entire issue. Not strictly a cuda issue, but a compile one

@smalinin

smalinin commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

@timkhronos No, I build my binaries from source code always
Again, the problem isn't related with CUDA version, the issue is in the fix idea, it must be updated.

@timkhronos

Copy link
Copy Markdown
Contributor Author

@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?

@Aidan24

Aidan24 commented Jul 31, 2026

Copy link
Copy Markdown

It seems that CUDA toolkit 13.2 is also CCCL 3.2. I'll try an earlier one :(

@timkhronos

timkhronos commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

@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

@Aidan24

Aidan24 commented Jul 31, 2026 •

Copy link
Copy Markdown

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

-- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.1/include;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.1/include/cccl (found version "13.1.80")
-- CUDA Toolkit found
-- The CUDA compiler identification is NVIDIA 13.1.80 with host compiler MSVC 19.44.35221.0

Prompt processing back to about 1250 t/s

0.56.313.861 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   4096, progress = 0.12, t =   3.13 s / 1309.51 tokens per second
0.58.027.889 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   6144, progress = 0.18, t =   4.84 s / 1268.92 tokens per second
0.59.917.761 I slot print_timing: id  0 | task 0 | prompt processing, n_tokens =   8192, progress = 0.24, t =   6.73 s / 1216.91 tokens per second

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...

@smalinin

Copy link
Copy Markdown
Contributor

@timkhronos
I have RAM=224Gb VRAM=190Gb , the used IQ3_S=159Gb https://huggingface.co/AesSedai/MiniMax-M3-GGUF

./llama-server   --model ~/.models/AesSedai/MiniMax-M3-GGUF/MiniMax-M3-IQ3_S-00001-of-00005.gguf   --batch-size 4096   --ubatch-size 2048   --ctx-size 96000   --flash-attn on   --parallel 1   --threads 20   --temp 1.0 --top-p 0.95 --top-k 40 --no-mmproj --reasoning-budget 4096 --no-mmap --jinja -fit on
 0.10.793.488 I common_memory_breakdown_print: | memory breakdown [MiB]      | total    free     self   model   context   compute    unaccounted |
0.10.793.490 I common_memory_breakdown_print: |   - CUDA0 (RTX 4090)        | 48508 = 48099 + (46629 = 38202 +    4078 +    4349) +      -46220 |
0.10.793.490 I common_memory_breakdown_print: |   - CUDA1 (RTX 4090)        | 48508 = 48099 + (46715 = 38427 +    3515 +    4772) +      -46306 |
0.10.793.491 I common_memory_breakdown_print: |   - CUDA2 (RTX 4090 D)      | 48508 = 48137 + (46131 = 38076 +    3281 +    4773) +      -45760 |
0.10.793.491 I common_memory_breakdown_print: |   - CUDA3 (RTX 3090)        | 24124 = 23845 + (21826 = 15672 +    1406 +    4748) +      -21547 |
0.10.793.491 I common_memory_breakdown_print: |   - CUDA4 (Graphics Device) | 20052 = 19774 + (18236 = 11847 +    1640 +    4748) +      -17957 |
0.10.793.491 I common_memory_breakdown_print: |   - Host                    |                   9841 =  9364 +       0 +     476                |
0.10.822.624 I common_params_fit_impl: memory for test allocation by device:
0.10.822.627 I common_params_fit_impl: id=0, n_layer=18, n_part= 1, overflow_type=2, mem= 46629 MiB
0.10.822.628 I common_params_fit_impl: id=1, n_layer=15, n_part= 1, overflow_type=1, mem= 46715 MiB
0.10.822.628 I common_params_fit_impl: id=2, n_layer=14, n_part= 1, overflow_type=3, mem= 46131 MiB
0.10.822.628 I common_params_fit_impl: id=3, n_layer= 6, n_part= 1, overflow_type=3, mem= 21826 MiB
0.10.822.628 I common_params_fit_impl: id=4, n_layer= 8, n_part= 5, overflow_type=3, mem= 18236 MiB
0.10.822.630 I common_params_fit_impl: set ngl_per_device[4].(n_layer, n_part, overflow_type)=(8, 5, GATE), id_dense_start=4
0.10.822.631 I common_params_fit_impl:   - CUDA4 (NVIDIA Graphics Device)   :  8 layers ( 5 overflowing),  18236 MiB used,   1537 MiB free
0.10.822.634 I common_fit_params: successfully fit params to free device memory
0.10.822.637 I common_fit_params: fitting params to free memory took 9.90 seconds
0.10.846.471 I llama_model_loader: additional 4 GGUFs metadata loaded.
0.10.846.473 I llama_model_loader: loaded meta data with 57 key-value pairs and 1176 tensors from /home/sergei/.models/AesSedai/MiniMax-M3-GGUF/MiniMax-M3-IQ3_S-00001-of-00005.gguf (version GGUF V3 (latest))


0.13.241.387 I load_tensors: offloading output layer to GPU
0.13.241.389 I load_tensors: offloading 59 repeating layers to GPU
0.13.241.389 I load_tensors: offloaded 61/61 layers to GPU
0.13.241.393 I load_tensors:        CUDA0 model buffer size = 38202.46 MiB
0.13.241.393 I load_tensors:        CUDA1 model buffer size = 38427.51 MiB
0.13.241.393 I load_tensors:        CUDA2 model buffer size = 38076.78 MiB
0.13.241.394 I load_tensors:        CUDA3 model buffer size = 15672.11 MiB
0.13.241.394 I load_tensors:        CUDA4 model buffer size = 11847.76 MiB
0.13.241.394 I load_tensors:    CUDA_Host model buffer size =  9364.38 MiB
0.11.070.917 I common_params_fit_impl: trying to fit one extra layer with overflow_type=LAYER_FRACTION_ATTN
0.11.290.817 I common_memory_breakdown_print: | memory breakdown [MiB]      | total    free     self   model   context   compute    unaccounted |
0.11.290.819 I common_memory_breakdown_print: |   - CUDA0 (RTX 4090)        | 48508 = 48099 + (46268 = 33734 +    3609 +    8925) +      -45859 |
0.11.290.819 I common_memory_breakdown_print: |   - CUDA1 (RTX 4090)        | 48508 = 48099 + (46445 = 30588 +    2812 +   13044) +      -46036 |
0.11.290.819 I common_memory_breakdown_print: |   - CUDA2 (RTX 4090 D)      | 48508 = 48137 + (46449 = 30591 +    2812 +   13045) +      -46078 |
0.11.290.819 I common_memory_breakdown_print: |   - CUDA3 (RTX 3090)        | 24124 = 23845 + (21695 = 12961 +     937 +    7796) +      -21416 |
0.11.290.819 I common_memory_breakdown_print: |   - CUDA4 (Graphics Device) | 20052 = 19774 + (18549 =  8182 +    3750 +    6616) +      -18270 |
0.11.290.820 I common_memory_breakdown_print: |   - Host                    |                  36009 = 35532 +       0 +     476                |
0.11.319.414 I common_params_fit_impl: memory for test allocation by device:
0.11.319.418 I common_params_fit_impl: id=0, n_layer=16, n_part= 1, overflow_type=3, mem= 46268 MiB
0.11.319.418 I common_params_fit_impl: id=1, n_layer=12, n_part= 1, overflow_type=2, mem= 46445 MiB
0.11.319.418 I common_params_fit_impl: id=2, n_layer=12, n_part= 1, overflow_type=1, mem= 46449 MiB
0.11.319.418 I common_params_fit_impl: id=3, n_layer= 4, n_part= 0, overflow_type=4, mem= 21695 MiB
0.11.319.418 I common_params_fit_impl: id=4, n_layer=17, n_part=15, overflow_type=1, mem= 18549 MiB
0.11.319.420 I common_params_fit_impl: set ngl_per_device[4].(n_layer, n_part, overflow_type)=(17, 15, ATTN), id_dense_start=4
0.11.319.420 I common_params_fit_impl:   - CUDA4 (NVIDIA Graphics Device)   : 17 layers (15 overflowing),  18549 MiB used,   1224 MiB free
0.11.319.422 I common_fit_params: successfully fit params to free device memory
0.11.319.426 I common_fit_params: fitting params to free memory took 10.34 seconds
0.11.342.959 I llama_model_loader: additional 4 GGUFs metadata loaded.
0.11.342.961 I llama_model_loader: loaded meta data with 57 key-value pairs and 1176 tensors from /home/sergei/.models/AesSedai/MiniMax-M3-GGUF/MiniMax-M3-IQ3_S-00001-of-00005.gguf (version GGUF V3 (latest))


0.11.465.030 I load_tensors: loading model tensors, this can take a while... (load_mode = none)
0.19.867.659 I load_tensors: offloading output layer to GPU
0.19.867.661 I load_tensors: offloading 59 repeating layers to GPU
0.19.867.661 I load_tensors: offloaded 61/61 layers to GPU
0.19.867.664 I load_tensors:        CUDA0 model buffer size = 33734.19 MiB
0.19.867.665 I load_tensors:        CUDA1 model buffer size = 30588.45 MiB
0.19.867.665 I load_tensors:        CUDA2 model buffer size = 30591.45 MiB
0.19.867.666 I load_tensors:        CUDA3 model buffer size = 12961.37 MiB
0.19.867.666 I load_tensors:        CUDA4 model buffer size =  8182.63 MiB
0.19.867.667 I load_tensors:    CUDA_Host model buffer size = 35532.91 MiB

Anayze fix with chatgpt:

Problems in #26297:

  • CUDA DeviceTopK runs row-by-row when nrows > 1, causing thousands of launches and severe prefill regression with CCCL 3.2.
  • The selection-mask path is built even when K == nblk, although all blocks are selected.
  • Per-layer MSA views and intermediates inflate compute buffers, causing --fit to offload more model data to CPU.
  • The mask chain (top_k → cast → repeat → set_rows → cont → add) creates excessive kernel launches and memory traffic.
  • Simply disabling GGML_OP_CUSTOM for RPC would introduce GPU→CPU→GPU synchronization.

Required fixes:

  • Use batched bitonic/segmented argsort for multi-row CUDA TopK.
  • Skip block selection entirely when K == nblk.
  • Reuse MSA views and mask state across sparse layers.
  • Fuse TopK mask construction in the CUDA backend.
  • Keep the RPC graph composed of standard GGML operations—no CUSTOM op or CPU fallback.

@timkhronos

timkhronos commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

@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)

@Aidan24

Aidan24 commented Jul 31, 2026 •

Copy link
Copy Markdown

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.
However I do get the error:

0.57.655.628 E ggml_backend_cuda_buffer_type_alloc_buffer: allocating 54112.66 MiB on device 1: cudaMalloc failed: out of memory
0.57.655.635 E ggml_gallocr_reserve_n_impl: failed to allocate CUDA1 buffer of size 56741232640
0.57.655.637 E graph_reserve: failed to allocate compute buffers

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:

llama-server -m C:\models\IQ4_XS\MiniMax-M3-IQ4_XS-00001-of-00006.gguf -c 50000 --load-mode none --no-mmap --no-ui --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 --cache-type-k f16 --cache-type-v f16

16.38.682.355 I slot print_timing: id  0 | task 2683 | n_decoded =    100, tg =  30.12 t/s, tg_3s =  30.12 t/s
16.41.696.219 I slot print_timing: id  0 | task 2683 | n_decoded =    174, tg =  27.47 t/s, tg_3s =  24.55 t/s
16.44.718.975 I slot print_timing: id  0 | task 2683 | n_decoded =    246, tg =  26.29 t/s, tg_3s =  23.82 t/s

Still on b10189 at the moment.

@timkhronos

timkhronos commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

@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. llama-server -m models/MiniMax-M3-Q4_K_M-00001-of-00007.gguf --threads 16 --threads-batch 16 --batch-size 2048 -ub 2048 --ctx-size 50000 -ngl 999 -ot "blk\.(0|1|2)\.ffn_.*=CUDA0" -ot "blk\..*_exps\.=CPU" --chat-template-file Minimax.jinja -lv 4 --no-mmap --mmproj models/mmproj-MiniMax-M3-BF16.gguf --image-max-tokens 1728 --cache-ram 0 --parallel 1 --fit off -ctk f16 -ctv f16

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?

@Aidan24

Aidan24 commented Aug 1, 2026

Copy link
Copy Markdown

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.

@Aidan24

Aidan24 commented Aug 1, 2026

Copy link
Copy Markdown

Finally built the cpp-Top-K branch with

Cuda compilation tools, release 13.2, V13.2.86
Build cuda_13.2.r13.2/compiler.37953736_0

I'm afraid I no longer have the same prompt to load, but with a shorter one it seems very fast @ ~1600 t/s:
1.12.288.837 I slot print_timing: id 0 | task 0 | prompt processing, n_tokens = 6144, progress = 0.82, t = 3.75 s / 1639.89 tokens per second

@Aidan24

Aidan24 commented Aug 1, 2026 •

Copy link
Copy Markdown

@timkhronos Interestingly even with Q8_0 for kv cache I'm still seeing:

1.06.520.077 E ggml_backend_cuda_buffer_type_alloc_buffer: allocating 51748.72 MiB on device 1: cudaMalloc failed: out of memory
1.06.520.084 E ggml_gallocr_reserve_n_impl: failed to allocate CUDA1 buffer of size 54262464512
1.06.520.086 E graph_reserve: failed to allocate compute buffers
1.06.520.107 W sched_reserve: compute buffer allocation failed, retrying without pipeline parallelism
1.07.304.130 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 50176, kv_unified = 'false'

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
llama-server -m C:\models\IQ4_XS\MiniMax-M3-IQ4_XS-00001-of-00006.gguf -c 50000 --load-mode none --no-mmap --no-ui --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,10 -sm layer -ub 2048 -b 2048 --cache-type-k q8_0 --cache-type-v q8_0

And after the model is loaded and the prompt processed, this is what is showing available:

Sat Aug  1 13:44:11 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 596.86                 Driver Version: 596.86         CUDA Version: 13.2     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA RTX PRO 6000 Blac...  WDDM  |   00000000:01:00.0  On |                    0 |
| 30%   55C    P8             28W /  300W |   72856MiB /  97887MiB |      3%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA RTX PRO 6000 Blac...  WDDM  |   00000000:02:00.0 Off |                    0 |
| 30%   46C    P8             13W /  300W |   77475MiB /  97887MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   2  NVIDIA RTX PRO 6000 Blac...  WDDM  |   00000000:8C:00.0 Off |                    0 |
| 30%   35C    P8             12W /  600W |   76059MiB /  97887MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

-Update-
So, it turns out that after I updated the BIOS on my Asus ProArt Z890-CREATOR WIFI motherboard from 2101 to 2302 all the cudaMalloc errors went away and all the GPU VRAM can be used. Now I can fit well over 200,000 context size no problem.

huaxel pushed a commit to huaxel/strix-llama.cpp that referenced this pull request Aug 2, 2026
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model Model specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: RPC crash with Minimax M3 MSA

5 participants