Skip to content

Fix 24486: TP: allows the usage of 4-10 gpus for stepfun and laguna - #24554

Merged
JohannesGaessler merged 1 commit into
ggml-org:masterfrom
krampenschiesser:fix--TP--stepfun-3.7-8+gpus
Oct 23, 2026
Merged

JohannesGaessler merged 1 commit into
ggml-org:masterfrom
krampenschiesser:fix--TP--stepfun-3.7-8+gpus

Conversation

@krampenschiesser

@krampenschiesser krampenschiesser commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This fixes #24486 and allows the usage of 4-10 and probably more gpu's. I cannot test with <4 because of too little vram.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes I used llama.cpp and qwen3.5 122b as an advanced grep tool for discovering the codebase all code comes from me (as little as there is).

@krampenschiesser

Copy link
Copy Markdown
Contributor Author

I am seeing some problems with tensor splits by going larger with granularity. I will try to implement the discovery of additional tensors during the std::vec initialization. this will include the passthrough of the user data+model into the ggml_backend_meta_get_split_state function so I can ask the model about additional tensors by tensor name.
will post some logs tomorrow regarding the core issue with the graph.

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 22c7460 to 6df847c Compare June 16, 2026 07:45
@krampenschiesser krampenschiesser changed the title Fix 24486: TP: allows the usage of 8,9,10 gpus for stepfun Fix 24486: TP: allows the usage of 4-10 gpus for stepfun Jun 16, 2026
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

This is way better.
works in all configurations i could test (4-10 gpus) probably with 2,3 and 10+ too.
Tensor splits look better too.
Should be good for review.
@JohannesGaessler please take a look, i don't know if it is ok to add more model specific exceptions into the llama-model.cpp

@krampenschiesser
krampenschiesser marked this pull request as ready for review June 16, 2026 07:48
@JohannesGaessler

Copy link
Copy Markdown
Contributor

Sorry for only responding now. I agree that the granularity may need to be adjusted but this value must be derived from hyperparameters, not hard-coded. I don't have the model in question on my machine but based on the compute graph in step35.cpp the granularity should be hparams.n_head(il).

@krampenschiesser

Copy link
Copy Markdown
Contributor Author

that's a good idea. I will change that!

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch 2 times, most recently from 5099756 to 1ec7b8c Compare July 22, 2026 14:48
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

@JohannesGaessler sorry for the late fix. just remembered because laguna is failing with the same thing. so this would fix both.
it seems to be a general pattern as it affects more models, so would it make sense to remove the check for the model arch?

@krampenschiesser krampenschiesser changed the title Fix 24486: TP: allows the usage of 4-10 gpus for stepfun Fix 24486: TP: allows the usage of 4-10 gpus for stepfun and laguna Jul 22, 2026
@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 1ec7b8c to 31f63c6 Compare July 24, 2026 13:56
@twnznz

twnznz commented Jul 24, 2026

Copy link
Copy Markdown

anecdotally tested ok against b10107
poolside/Laguna-S-2.1-GGUF/laguna-s-2.1-Q8_0.gguf
6x Mi50 32GB - ROCm 7.13.0

@krampenschiesser

Copy link
Copy Markdown
Contributor Author

anecdotally tested ok against b10107 poolside/Laguna-S-2.1-GGUF/laguna-s-2.1-Q8_0.gguf 6x Mi50 32GB - ROCm 7.13.0

thank you for the testing! out of curiosity what pp/s tg/s do you get with the mi50 and -sm tensor vs -sm layer

Comment thread src/llama-model.cpp
Comment on lines +656 to +662
if (ud->model->arch == LLM_ARCH_STEP35 || ud->model->arch == LLM_ARCH_LAGUNA) {
GGML_ASSERT(segments.size() == 1);
const int64_t max_el = segments[0].first;
if (std::regex_match(tensor_name, pattern_attn_gate_weight)) {
return {hparams.n_head(il) / hparams.n_head_kv(il)};
}
}

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.

I don't think this is the right way to calculate the granularity. The logical interpretation is that this function should return a value to which the tensor dimension is rounded when splitting data between GPUs. That should be hparams.n_head(il), not the GQA ratio. (It may be that for some combinations of models and hardware an incorrect implementation happens to work by chance.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So I keep the architecture checks since it is needed for both to run with 4-10 gpus?
Or should i change this differently?

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.

The way tensors are named is a lot of the time inconsistent, so either way may need adjustements in the future. My intuition is that removing the check in this PR will have fewer issues in the future.

@twnznz

twnznz commented Jul 24, 2026 •

Copy link
Copy Markdown

anecdotally tested ok against b10107 poolside/Laguna-S-2.1-GGUF/laguna-s-2.1-Q8_0.gguf 6x Mi50 32GB - ROCm 7.13.0

thank you for the testing! out of curiosity what pp/s tg/s do you get with the mi50 and -sm tensor vs -sm layer

Layer:
llama-bench -m poolside/Laguna-S-2.1-GGUF/laguna-s-2.1-Q8_0.gguf -ngl 999 --flash-attn on
ggml_cuda_init: found 6 ROCm devices (Total VRAM: 196512 MiB):
Device 0: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
Device 1: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
Device 2: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
Device 3: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
Device 4: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
Device 5: AMD Instinct MI60 / MI50, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB

model size params backend ngl fa test t/s
laguna ?B Q8_0 119.91 GiB 117.56 B ROCm 999 1 pp512 221.91 ± 0.84
laguna ?B Q8_0 119.91 GiB 117.56 B ROCm 999 1 tg128 35.52 ± 0.22

build: 54ce507 (10111)

Tensor:
llama-bench -m poolside/Laguna-S-2.1-GGUF/laguna-s-2.1-Q8_0.gguf -ngl 999 --flash-attn on -sm tensor
..

model size params backend ngl sm fa test t/s
laguna ?B Q8_0 119.91 GiB 117.56 B ROCm 999 tensor 1 pp512 368.61 ± 1.80
laguna ?B Q8_0 119.91 GiB 117.56 B ROCm 999 tensor 1 tg128 35.99 ± 1.10

build: 54ce507 (10111)

So, not much in terms of tg, but a decent bump in pp.
Topology is
numa0-[pex0]-ROCm0 [PCIe 3.0 x16]
numa0-[pex0]-ROCm1 [PCIe 3.0 x16]
| < 2x QPI 9.6GT/s
numa1-[pex1]-ROCm2 [PCIe 3.0 x16]
numa1-[pex1]-ROCm3 [PCIe 3.0 x16]
numa1-[pex2]-ROCm4 [PCIe 3.0 x16]
numa1-[pex2]-ROCm5 [PCIe 3.0 x16]

numa to pex is PCIe 3.0 x16
p2p verified

EDIT: TG at deep context (270k) is MUCH faster; ~25tps (tensor) vs ~7tps (layer)

@krampenschiesser

Copy link
Copy Markdown
Contributor Author

EDIT: TG at deep context (270k) is MUCH faster; ~25tps (tensor) vs ~7tps (layer)

That's awesome!

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 31f63c6 to 2d807d0 Compare July 29, 2026 14:41
@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 2d807d0 to 22f16f4 Compare August 13, 2026 20:51
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

@CISC @JohannesGaessler how can I continue from here? imho this is a small isolated change to get 2 models to run in tensor parallel and not crash during load. What should I change?

@CISC

CISC commented Aug 14, 2026

Copy link
Copy Markdown
Member

@CISC @JohannesGaessler how can I continue from here? imho this is a small isolated change to get 2 models to run in tensor parallel and not crash during load. What should I change?

I'm not sure exactly what the suggested change is, this will have to wait for feedback from Johannes.

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 22f16f4 to b8ffdcd Compare August 20, 2026 00:14

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

Sorry for the long radio silence, I had taken a break from llama.cpp and am currently working through my backlog. Looking at the way the compute graph is being constructed the submitted implementation is correct after all. The wqkv_gate tensor is applied after FlashAttention and before the attention output matrix multiplication as a gate on the FA output. Therefore the granularity needs to be the number of Q heads per K/V head since that is the FA granularity. If you remove the unused variable I'll approve and merge.

Comment thread src/llama-model.cpp Outdated
@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from b8ffdcd to ddf8934 Compare October 14, 2026 14:26
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

@JohannesGaessler welcome back!
I removed the unused var and rebased

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from ddf8934 to 8b2327d Compare October 15, 2026 16:03
@JohannesGaessler JohannesGaessler added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 17, 2026
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

Maion-coder fails and only on mac, since my adjustments are guarded by a model arch check this is unrelated. probably a rerun needed?

0.04.188.520 I maion-coder          dense any      SOFT_MAX+ARGSORT+GET_ROWS+SUM_ROWS+CLAMP+DIV       2       0       0   7.23e-08   9.14e-07 FAIL

same model again in the llama-context test:



29: Test command: /home/runner/work/llama.cpp/llama.cpp/build/bin/test-llama-context "--models" "/home/runner/work/llama.cpp/llama.cpp/build/tests/test-models/"
29: Working Directory: .
29: Environment variables: 
29:  GGML_SCHED_DEBUG_REALLOC=1
29: Test timeout computed to be: 900
29: models in parallel: 1, threads per model: 4
29: Model                      baseline  seq_rm  state_load  cp_h  cp_d  cp_h_s  cp_d_s  rt    ps    rf    rot   frag  rollback  replay  shared
29: maion-coder-moe.gguf       OK        OK      FAIL        FAIL  FAIL  OK      OK      OK    OK    OK    OK    OK    SKIP      SKIP    SKIP  

@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 8b2327d to 96211ba Compare October 18, 2026 19:51
@krampenschiesser

Copy link
Copy Markdown
Contributor Author

Pushed up another rebase, fingers crossed.

@JohannesGaessler JohannesGaessler removed the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 18, 2026
@krampenschiesser
krampenschiesser force-pushed the fix--TP--stepfun-3.7-8+gpus branch from 96211ba to a13cd76 Compare October 20, 2026 14:35
@JohannesGaessler JohannesGaessler added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 23, 2026
@JohannesGaessler
JohannesGaessler merged commit 06230cb into ggml-org:master Oct 23, 2026
20 checks passed
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: TP: Stepfun 3.7 does not work with uneven splits (GGML_META_DEBUG=1)

4 participants