Skip to content

graph : use fill instead of scale_bias in grouped expert selection#17867

Merged
CISC merged 2 commits into
masterfrom
cisc/use-fill-instead-of-scale-bias
Dec 8, 2025
Merged

graph : use fill instead of scale_bias in grouped expert selection#17867
CISC merged 2 commits into
masterfrom
cisc/use-fill-instead-of-scale-bias

Conversation

@CISC

@CISC CISC commented Dec 8, 2025

Copy link
Copy Markdown
Member

Since all major backends (CUDA, Metal and Vulkan) support the fill op now use that instead of scale_bias.

@CISC
CISC requested a review from ggerganov December 8, 2025 18:46
@ggerganov

Copy link
Copy Markdown
Member

Instead of using the explicit ggml_fill_inplace, leave this to the allocator by adding the op to ggml-alloc.c::ggml_op_can_inplace. Would also need to remove the restrict classifier in the CUDA implementation.

@CISC

CISC commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

Instead of using the explicit ggml_fill_inplace, leave this to the allocator by adding the op to ggml-alloc.c::ggml_op_can_inplace. Would also need to remove the restrict classifier in the CUDA implementation.

Ah, didn't know about that, I'll change it to just ggml_fill.

I'll look into the rest for another PR where/how is the decision to do it in place done?

@ggerganov

Copy link
Copy Markdown
Member

Generally, avoid using explicit _inplace ops unless you need to modify some buffer permanently (e.g. a KV cache).

I'll look into the rest for another PR where/how is the decision to do it in place done?

The logic for that is in ggml_gallocr_allocate_node. If one of the parents of the op is suitable, the result will reuse it's memory making the op effectively inplace.

@CISC

CISC commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

@ggerganov Hmmm, it won't reuse it for FILL, it's skipping it here:

not reusing parent ffn_moe_probs_biased-19 (reshaped) for node_1556 as (nil) is external

@ggerganov

Copy link
Copy Markdown
Member

I think this means that the parent buffer is on a different backend buffer - this is expected to not be able to inplace.

@CISC

CISC commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

I think this means that the parent buffer is on a different backend buffer - this is expected to not be able to inplace.

Ah, this might be why:

not reusing parent blk.19.exp_probs_b.bias for ffn_moe_probs_biased-19 as 0x7e10eba4b800 is external

@CISC

CISC commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

It's a little odd that ggml_fill_inplace works fine then, but I guess it's an ordering issue, I tried forcing ggml_gallocr_allocate_node to do it for FILL and then it just outputs ?.

@CISC
CISC merged commit c8554b6 into master Dec 8, 2025
76 of 78 checks passed
@CISC
CISC deleted the cisc/use-fill-instead-of-scale-bias branch December 8, 2025 20:30
0Marble pushed a commit to 0Marble/llama.cpp that referenced this pull request Dec 18, 2025
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
Anico2 added a commit to Anico2/llama.cpp that referenced this pull request Jan 15, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
…17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
phibya pushed a commit to ziee-ai/llama.cpp that referenced this pull request May 29, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request May 30, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…gml-org#17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
MrLordCat referenced this pull request in MrLordCat/llama.cpp-with-GUI Jul 16, 2026
…17867)

* use fill instead of scale_bias in grouped expert selection

* do not explicitly use _inplace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants