Skip to content

[LFM2] Wire Lfm2MoeForCausalLM into the LFM2 serving override tables - #30780

Merged
mmangkad merged 3 commits into
sgl-project:mainfrom
tugot17:piotr/lfm2-moe-base-serving
Jul 29, 2026
Merged

mmangkad merged 3 commits into
sgl-project:mainfrom
tugot17:piotr/lfm2-moe-base-serving

Conversation

@tugot17

@tugot17 tugot17 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Lfm2MoeForCausalLM (LFM2-MoE, e.g. LFM2-8B-A1B) is a registered model, but it was missing from the serving override tables that the dense Lfm2ForCausalLM already uses. This adds it alongside the dense arch in three places:

  • _lfm2_overrides registry (arg_groups/overrides.py) - flashinfer attention-backend default on SM100
  • _MAMBA_RADIX_CACHE_ARCHS (arg_groups/overrides.py) - mamba radix cache eligibility
  • the LFM2 branch in server_args.py - triton-backend guard

Both 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

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment on lines +4511 to 4514
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", (

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.

medium

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\"
    )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tugot17
tugot17 marked this pull request as ready for review July 10, 2026 15:04
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@vincentzed

vincentzed commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Jul 28, 2026
@vincentzed

Copy link
Copy Markdown
Contributor

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 AttributeError: type object 'HWBackend' has no attribute 'MLX' — that enum member only landed on main afterwards (python/sglang/test/ci/ci_register.py), and the CPU shards are the fast-fail cascade off it. GitHub reruns pin the original merge commit, so rerunning again won't help.

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

@vincentzed

Copy link
Copy Markdown
Contributor

One addendum to the above: sglang CI has since entered maintenance mode (#21065) — check-changes now hard-requires every PR to contain base commit 4597dd4. So an empty commit won't cut it: merge latest main into the branch (or rebase onto it), then CI runs normally. Verified on my own PRs that a merge satisfies the gate.

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.
@tugot17
tugot17 force-pushed the piotr/lfm2-moe-base-serving branch from cbe2a18 to c645be8 Compare July 29, 2026 12:39
@mmangkad
mmangkad enabled auto-merge (squash) July 29, 2026 12:52
@mmangkad
mmangkad merged commit d19999b into sgl-project:main Jul 29, 2026
128 of 137 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants