ggml: add fused sinkhorn op (eps + output-layout params)#2115
Merged
Conversation
ikawrakow
requested changes
Jul 12, 2026
| @@ -225,34 +225,13 @@ static ggml_tensor * openpangu_causal_conv(ggml_context * ctx, ggml_cgraph * gf, | |||
| // --- mHC Sinkhorn: h_res [S*S, T] -> doubly-stochastic per token, 20 iters (ends on col norm) --- | |||
| static ggml_tensor * openpangu_sinkhorn(ggml_context * ctx, ggml_tensor * h_res_flat, | |||
Owner
There was a problem hiding this comment.
There is no point in having this function now. You can just call ggml_sinkhorn from mhc_post.
Contributor
Author
There was a problem hiding this comment.
Done; wrapper removed!
ikawrakow
approved these changes
Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
openPangu's mHC runs Sinkhorn normalization as a graph chain at two sites per layer, roughly 240 nodes per layer of micro-ops on 4x4 matrices: 27907 graph nodes on the llama-server startup graph with the configuration below, 13463 with this PR. It adds
GGML_OP_SINKHORN, which does the whole normalization in one op (CPU and CUDA), and uses it in the openPangu graph. Suggested in #2065 review as a future improvement.The op takes the flat
[S*S, T]batch, supports 1 <= S <= 8, and carries eps and output-layout parameters, so the same construction in the DeepSeek V4 port under construction in #2110 can adopt it at its pre-reshape call site. openPangu would be the only caller; no other architecture's graph changes.Measured on the #2065 setup (RTX 4070, the #2065 Q4_K_M), warm back-to-back sweeps of
llama-sweep-bench -m <model> -c 34816 -ub 2048 -fa off -ngl 999 -ot exps=CPU -ctk q8_0 -ictk q8_0, main vs this branch, condensed from the 17-row sweep:TG is up 7.6-11.1% at every measured depth here and in an 8K sweep, single warm pass per cell; PP at ub 2048 is flat within run-to-run variation. The temp-0 needle output is byte-identical to main on both the CUDA and CPU paths, and a PPL spot check matches (1.2133 +/- 0.019 main, 1.2147 +/- 0.019 fused).