Repository navigation
[LFM2] Wire Lfm2MoeForCausalLM into the LFM2 serving override tables - #30780
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the Lfm2MoeForCausalLM model architecture by registering it for LFM2 overrides and applying the same model-specific adjustments as Lfm2ForCausalLM. The review feedback highlights a potential issue where the assertion preventing the use of the triton attention backend can be bypassed if the backend is not explicitly specified, as the check runs before the default backend is resolved. It is recommended to move this validation to a later stage in the configuration process to ensure it is robustly enforced.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| elif model_arch in ["Lfm2ForCausalLM", "Lfm2MoeForCausalLM"]: | ||
| # Attention backend selection moved to the override registry | ||
| # (arg_groups/overrides.py: _lfm2_overrides). | ||
| assert resolved_view(self).attention_backend != "triton", ( |
There was a problem hiding this comment.
Issue: Assertion Bypassed for Default Fallback Backend
The assertion assert resolved_view(self).attention_backend != "triton" is executed during _handle_model_specific_adjustments, which runs before the default attention backend is resolved by _attention_backend_default in _handle_attention_backend_compatibility.
If a user does not explicitly specify --attention-backend, resolved_view(self).attention_backend is None at this stage. The assertion None != "triton" passes silently. Later, if the system falls back to "triton" as the default backend (e.g., if FlashInfer is unavailable), the model will attempt to run with "triton", completely bypassing this safety check and leading to a runtime crash.
Recommendation
To make this validation robust, we should perform this check in _handle_attention_backend_compatibility right after _attention_backend_default has been resolved. For example:
# Inside _handle_attention_backend_compatibility:
run_post_process_pass(self, _attention_backend_default)
# Validate that models requiring non-triton backends do not fall back to triton
attention_backend = resolved_view(self).attention_backend
model_arch = model_config.hf_config.architectures[0]
if model_arch in [\"Lfm2ForCausalLM\", \"Lfm2MoeForCausalLM\", \"NemotronHForCausalLM\", \"NemotronHPuzzleForCausalLM\"]:
assert attention_backend != \"triton\", (
f\"{model_arch} does not support triton attention backend, \"
\"as the first layer might not be an attention layer\"
)There was a problem hiding this comment.
This assert already exists for the dense Lfm2ForCausalLM; this PR only adds Lfm2MoeForCausalLM to the same list. The fallback-to-triton ordering concern applies equally to the existing code, so it is better handled as a separate change than in this 3-line parity PR.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/rerun-failed-ci |
|
CI update: the base-a-test-cpu / build-test failures here are a stale-merge-SHA artifact, not this PR. The rerun reused the July 10 merge commit, which dies on @tugot17 could you push a refresh to the branch (merge main or an empty commit)? That regenerates the merge ref and CI should go green — the 3-line diff itself is untouched by any of this. |
|
One addendum to the above: sglang CI has since entered maintenance mode (#21065) — |
Lfm2MoeForCausalLM (LFM2-MoE, e.g. LFM2-8B-A1B) is a registered model but was missing from the override tables the dense Lfm2ForCausalLM already uses: the attention-backend override registry (flashinfer default on SM100), the mamba-radix-cache arch set, and the triton-backend guard in server_args. Add it alongside the dense arch so base MoE serving gets the same backend/cache defaults.
cbe2a18 to
c645be8
Compare
What
Lfm2MoeForCausalLM(LFM2-MoE, e.g. LFM2-8B-A1B) is a registered model, but it was missing from the serving override tables that the denseLfm2ForCausalLMalready uses. This adds it alongside the dense arch in three places:_lfm2_overridesregistry (arg_groups/overrides.py) - flashinfer attention-backend default on SM100_MAMBA_RADIX_CACHE_ARCHS(arg_groups/overrides.py) - mamba radix cache eligibilityserver_args.py- triton-backend guardBoth archs are the same LFM2 hybrid (ShortConv + attention) family, so MoE should get the same backend/cache defaults as dense.
Testing
Base (non-spec) LFM2-8B-A1B serving on 1xH100: server starts, selects the backend through the registry, initializes
MambaRadixCache, and generates. 3 lines, no behavior change for any other arch.CI States
Latest PR Test (Base): ⏳ Run #30457880680
Latest PR Test (Extra): ❌ Run #30457880433