Repository navigation
llama : enable moe amax rescaling for laguna - #31147
Merged
Merged
Conversation
Assisted-by: Devin
ggerganov
approved these changes
Oct 25, 2026
CISC
approved these changes
Oct 26, 2026
Member
|
Split axis needs to be fixed https://github.com/ggml-org/llama.cpp/actions/runs/40192579226/job/121460068820?pr=31147#step:8:381 |
Member
|
@begcdn Apply this patch: diff --git a/src/llama-arch.cpp b/src/llama-arch.cpp
index 39e29d09a..3a5afe36f 100644
--- a/src/llama-arch.cpp
+++ b/src/llama-arch.cpp
@@ -1338,6 +1338,7 @@ bool llm_arch_supports_sm_tensor(const llm_arch & arch) {
case LLM_ARCH_MISTRAL4:
case LLM_ARCH_MELLUM: // [TAG_MOE_AMAX_SCALE]
case LLM_ARCH_FLINT: // [TAG_MOE_AMAX_SCALE]
+ case LLM_ARCH_LAGUNA: // [TAG_MOE_AMAX_SCALE]
case LLM_ARCH_KIMI_LINEAR:
case LLM_ARCH_BAILINGMOE3:
case LLM_ARCH_KIMI_K3: |
CISC
approved these changes
Oct 26, 2026
6 tasks
auRose94
pushed a commit
to auRose94/llama.cpp
that referenced
this pull request
Oct 28, 2026
* llama : enable moe amax rescaling for laguna Assisted-by: Devin * llama : declare laguna sm tensor support
yzhou51
pushed a commit
to yzhou51/llama.cpp
that referenced
this pull request
Oct 30, 2026
* llama : enable moe amax rescaling for laguna Assisted-by: Devin * llama : declare laguna sm tensor support
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.
Overview
Adds
LLM_ARCH_LAGUNAto the existingbuild_amax_src1_f16condition inbuild_moe_ffn, so Laguna applies the same f16 activation rescaling already used by Mistral4, Mellum and Flint.Without it, Laguna MoE models overflow on Metal when the prefill microbatch is 32 tokens or larger (#30896):
kernel_mul_mm_idstages the f32 activation throughhalfin shared memory, so gate/up outputs above 65504 become inf in the down projection. At smaller microbatches a different kernel path is used, which is why the failure only appears at ubatch >= 32.Verified locally on a Laguna-XS-2.1 slice: the src1 amax into
ffn_moe_downdropped from 103671.5 to 1018.9 with this change, and the unflagged MetalMUL_MAT_IDpath produces NaN for src1 ~1e5 at n >= 32 while CPU does not.Additional information
Ref: #30896, #30584
Requirements