Repository navigation
[Model] Add support for Nanbeige4.2 - #32151
Merged
Merged
Conversation
zqlcode
requested review from
Fridge003,
JustinTong0323,
Ying1123,
hnyls2002,
ispobock and
merrymercy
as code owners
July 23, 2026 05:21
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
hnyls2002
approved these changes
Sep 3, 2026
Collaborator
|
/tag-and-rerun-ci |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
This was referenced Sep 5, 2026
StevenChenSE
pushed a commit
to StevenChenSE/sglang
that referenced
this pull request
Sep 6, 2026
Co-authored-by: root <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]>
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.
Motivation
Add day-0 / native SGLang support for Nanbeige4.2, which uses a custom looped Transformer architecture (
model_type=nanbeige,NanbeigeForCausalLM).Model / weights: (https://huggingface.co/Nanbeige/Nanbeige4.2-3B)
Modifications
NanbeigeConfig(python/sglang/srt/configs/nanbeige.py) and register it in config / HF config registry.python/sglang/srt/models/nanbeige.py:layer_idper loop for KV cache / CUDA graphNanbeigeForCausalLM+NanbeigeForSequenceClassification(EntryClass)model_config.py:num_attention_layers = num_hidden_layers * num_loopsforNanbeigeForCausalLM.layer_setup.py(expandModuleListattentions, sort bylayer_id; also covernum_loops/loop_num).--tool-call-parser nanbeige→Qwen3CoderDetector--reasoning-parser nanbeige→Qwen3DetectorImpact
This PR is primarily a model registration + architecture enablement change. It does not modify the shared serving/runtime path for existing models.
The only non-registration runtime touch is in
layer_setup.py, which generalizes loop-model attention collection so Prefill CUDA Graph can correctly indexRadixAttentionbylayer_idfornum_loops > 1. Behavior for non-loop models is unchanged.Accuracy Tests
gsm8k

Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #33857111747
Latest PR Test (Extra): ❌ Run #33857111409
Latest PR Test (AMD ROCm 7.2): ❌ Run #33857111640