Skip to content

vulkan: Update topk_moe fusion to handle gpt's late softmax#16656

Merged
0cc4m merged 5 commits into
ggml-org:masterfrom
jeffbolznv:topk_gpt
Oct 29, 2025
Merged

vulkan: Update topk_moe fusion to handle gpt's late softmax#16656
0cc4m merged 5 commits into
ggml-org:masterfrom
jeffbolznv:topk_gpt

Conversation

@jeffbolznv

Copy link
Copy Markdown
Contributor

Based on #16649.

@jeffbolznv jeffbolznv requested a review from 0cc4m as a code owner October 18, 2025 21:34
@github-actions github-actions Bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Oct 18, 2025
@jeffbolznv

Copy link
Copy Markdown
Contributor Author

CC @am17an I've included the ggml_check_edges change in this PR.

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

I understand what this change is doing, but how do I test it? The topk_moe tests pass before and after this change. Which model architectures correspond to the three modes?

Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp Outdated
@am17an

am17an commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

I understand what this change is doing, but how do I test it? The topk_moe tests pass before and after this change. Which model architectures correspond to the three modes?

Usually I put a debug statement printing the number of nodes fused. We'll need to come up with a better way to assert that the nodes were actually fused

@jeffbolznv

Copy link
Copy Markdown
Contributor Author

I understand what this change is doing, but how do I test it? The topk_moe tests pass before and after this change. Which model architectures correspond to the three modes?

I've added some logging in the latest commit that I use to verify fusion and the effects of graph_optimize. You can see the whole sequence of ops without a sync in between, which implies the fusion is working.

Early softmax w/norm: qwen3
Early softmax w/o norm: deepseek2
Late softmax: gpt-oss

@jeffbolznv

Copy link
Copy Markdown
Contributor Author

I've rebased this and updated it to handle the clamp added in #16655.

@github-actions github-actions Bot added the testing Everything test related label Oct 26, 2025

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

LGTM

@0cc4m

0cc4m commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Are the non-Vulkan changes fine @slaren ?

Comment thread ggml/src/ggml-impl.h Outdated
Co-authored-by: Diego Devesa <slarengh@gmail.com>
@0cc4m 0cc4m merged commit 10fcc41 into ggml-org:master Oct 29, 2025
60 of 63 checks passed
Anico2 added a commit to Anico2/llama.cpp that referenced this pull request Jan 15, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on #16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in #16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
phibya pushed a commit to ziee-ai/llama.cpp that referenced this pull request May 29, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request May 30, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…#16656)

* vulkan: Update topk_moe fusion to handle gpt's late softmax

Based on ggml-org#16649.

* Add ggml_check_edges

* Add sync logging to show fusion effects

* handle clamp added in ggml-org#16655

* Update ggml/src/ggml-impl.h

Co-authored-by: Diego Devesa <slarengh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning testing Everything test related Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants