Skip to content

model: support nvidia/Llama-3_3-Nemotron-Super-49B-v1#9067

Merged
zhyncs merged 11 commits intosgl-project:mainfrom
netanel-haber:feature/support-nvidia-llama-3_3-nemotron-super-49b-v1
Aug 17, 2025
Merged

model: support nvidia/Llama-3_3-Nemotron-Super-49B-v1#9067
zhyncs merged 11 commits intosgl-project:mainfrom
netanel-haber:feature/support-nvidia-llama-3_3-nemotron-super-49b-v1

Conversation

@netanel-haber
Copy link
Copy Markdown
Contributor

@netanel-haber netanel-haber commented Aug 11, 2025

Based on: #5073

Motivation

Add support for nvidia/Llama-3_3-Nemotron-Super-49B-v1 and v1.5.

Modifications

Porting nemotron_nas from VLLM.

Sanity Testing

`python3 -m sglang.bench_one_batch` vs `python3.12 scripts/playground/reference_hf.py` - H200 140GB
SGLang Huggingface
V1
prefill logits (final): tensor([[ 5.9375,  3.2188,  0.0713,  ..., -1.8594, -1.8594, -1.8594],
        [ 5.1875,  3.6094,  2.0781,  ..., -1.7344, -1.7344, -1.7344],
        [ 8.9375,  3.7031,  2.6562,  ..., -1.4844, -1.4844, -1.4844]],
       device='cuda:0') 

========== Prompt 0 ==========
<|begin_of_text|>The capital of France is Paris. It is the most populous city in the European Union. Paris is known 

========== Prompt 1 ==========
<|begin_of_text|>The capital of the United Kindom is London. It is one of the most famous cities in the world. London is 

========== Prompt 2 ==========
<|begin_of_text|>Today is a sunny day and I like to go out for a walk. I put on my sunglasses and start walking. 
========== Prompt 0 ==========
prefill logits (final) tensor([ 5.9414,  3.2168,  0.1160,  ..., -1.8398, -1.8389, -1.8389],
       device='cuda:0')
<|begin_of_text|>The capital of France is Paris. It is the most populous city in the European Union. Paris is known

========== Prompt 1 ==========
prefill logits (final) tensor([ 5.2070,  3.5918,  2.0625,  ..., -1.7412, -1.7402, -1.7393],
       device='cuda:0')
<|begin_of_text|>The capital of the United Kindom is London. London is one of the world's great cities, with a rich history

========== Prompt 2 ==========
prefill logits (final) tensor([ 8.9688,  3.7168,  2.6758,  ..., -1.5098, -1.5098, -1.5098],
       device='cuda:0')
<|begin_of_text|>Today is a sunny day and I like to go out for a walk. I put on my sunglasses and start walking.
V1.5
prefill logits (final): tensor([[ 5.3438,  3.4062,  0.4180,  ..., -0.9844, -0.9844, -0.9844],
        [ 5.0000,  3.9688,  2.1562,  ..., -0.2158, -0.2148, -0.2139],
        [ 9.5000,  3.7500,  1.8125,  ...,  1.4219,  1.4219,  1.4219]],
       device='cuda:0') 

========== Prompt 0 ==========
<|begin_of_text|>The capital of France is Paris, which is also the most populous city in the country. Paris is known 

========== Prompt 1 ==========
<|begin_of_text|>The capital of the United Kindom is London. London is a very big city with a population of over 8 million 

========== Prompt 2 ==========
<|begin_of_text|>Today is a sunny day and I like to take a walk in the park. The sun is shining brightly and the birds 
========== Prompt 0 ==========
prefill logits (final) tensor([ 5.3281,  3.3945,  0.4124,  ..., -0.9619, -0.9619, -0.9614],
       device='cuda:0')
<|begin_of_text|>The capital of France is Paris, which is also the most populous city in the country. Paris is known

========== Prompt 1 ==========
prefill logits (final) tensor([ 5.0273,  3.9844,  2.1836,  ..., -0.2290, -0.2281, -0.2275],
       device='cuda:0')
<|begin_of_text|>The capital of the United Kindom is London. London is a very big city with a population of over 8 million

========== Prompt 2 ==========
prefill logits (final) tensor([9.4922, 3.7500, 1.8008,  ..., 1.4160, 1.4160, 1.4160], device='cuda:0')
<|begin_of_text|>Today is a sunny day and I like to take advantage of the good weather to go for a walk. I put on

MMLU-Pro on V1.5: Published HF Results vs. SgLang run

SgLang: Reproduction and Results
  • Backend: python -m sglang.launch_server --model-path "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5" --host 0.0.0.0 --port 30000 --served-model-name "Llama-3_3-Nemotron-Super-49B-v1_5" --context-length 65536 --random-seed 1 --trust-remote-code --dp-size 5
  • Frontend: lm_eval --model local-chat-completions --model_args model=nvidia/Llama-3_3-Nemotron-Super-49B-v1_5,base_url=http://localhost:30000/v1/chat/completions,api_key=EMPTY,num_concurrent=320,timeout=3600 --tasks mmlu_pro --apply_chat_template --system_instruction "" --gen_kwargs temperature=0.6,top_p=0.95,do_sample=true,seed=1 --log_samples
Tasks Value ± Stderr
mmlu_pro (n-shot 5) 0.7853 ± 0.0036
- biology 0.8856 ± 0.0119
- business 0.8454 ± 0.0129
- chemistry 0.8489 ± 0.0106
- computer_science 0.8049 ± 0.0196
- economics 0.8235 ± 0.0131
- engineering 0.6749 ± 0.0151
- health 0.7396 ± 0.0154
- history 0.6745 ± 0.0240
- law 0.5967 ± 0.0148
- math 0.9141 ± 0.0076
- other 0.7327 ± 0.0146
- philosophy 0.6794 ± 0.0209
- physics 0.8483 ± 0.0100
- psychology 0.7957 ± 0.0143

Checklist

  • Format your code according to the Code Formatting with Pre-Commit.
  • Add unit tests as outlined in the Running Unit Tests.
  • Update documentation / docstrings / example tutorials as needed, according to Writing Documentation.
  • Provide throughput / latency benchmark results and accuracy evaluation results as needed, according to Benchmark and Profiling and Accuracy Results.
  • For reviewers: If you haven't made any contributions to this PR and are only assisting with merging the main branch, please remove yourself as a co-author when merging the PR.

Please feel free to join our Slack channel at https://slack.sglang.ai/ to discuss your PR.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @netanel-haber, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented a new feature to support the nvidia/Llama-3_3-Nemotron-Super-49B-v1 model within the system. This involved adding the complete model architecture, including its decoder layers and overall structure, and integrating it with the existing framework's components like the language model head and sampler. Additionally, I've updated model configuration logic to correctly handle this new model type and made significant improvements to the underlying utility functions, enhancing support for pipeline parallelism and refining the weight loading process for better flexibility and robustness.

Highlights

  • New Model Support: I've added comprehensive support for the nvidia/Llama-3_3-Nemotron-Super-49B-v1 model, which includes defining its specific architecture and ensuring compatibility with the existing framework.
  • Nemotron-NAS Model Implementation: I've introduced a new file, python/sglang/srt/models/nemotron_nas.py, which contains the full implementation of the Nemotron-NAS model, including its decoder layers, main model structure, and causal language model capabilities.
  • Model Configuration Update: I've updated the model_config.py to correctly calculate the number of KV heads for nemotron-nas models, ensuring proper configuration and operation.
  • Framework Utility Enhancements: I've significantly refactored and enhanced the utility functions in utils.py, particularly improving support for pipeline parallelism and introducing a more robust and flexible weight loading mechanism with AutoWeightsLoader and PPMissingLayer.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 nvidia/Llama-3_3-Nemotron-Super-49B-v1 model. The changes include a new model definition file, updates to the model configuration to handle this new architecture, and modifications to utility functions. While the core model implementation seems reasonable, there are some issues with the pipeline parallelism setup in the new model file that need to be addressed. Additionally, a critical issue was found in python/sglang/srt/utils.py where necessary imports were removed, which would cause runtime errors.

@netanel-haber netanel-haber force-pushed the feature/support-nvidia-llama-3_3-nemotron-super-49b-v1 branch from e8a40a5 to 33ab5b2 Compare August 11, 2025 09:21
@netanel-haber netanel-haber force-pushed the feature/support-nvidia-llama-3_3-nemotron-super-49b-v1 branch 6 times, most recently from e7dd0af to e97839d Compare August 11, 2025 14:11
@netanel-haber netanel-haber force-pushed the feature/support-nvidia-llama-3_3-nemotron-super-49b-v1 branch from b97d9d1 to 259e251 Compare August 11, 2025 15:05
@netanel-haber netanel-haber marked this pull request as ready for review August 11, 2025 15:16
@netanel-haber
Copy link
Copy Markdown
Contributor Author

Tagged @merrymercy @zhyncs in the community slack PR channel

Comment thread python/sglang/srt/models/nemotron_nas.py Outdated
Comment thread python/sglang/srt/models/nemotron_nas.py Outdated
Comment thread python/sglang/srt/models/nemotron_nas.py Outdated
Comment thread python/sglang/srt/models/nemotron_nas.py Outdated
Comment thread python/sglang/srt/models/nemotron_nas.py Outdated
@mickqian mickqian changed the title Feature: Support nvidia/Llama-3_3-Nemotron-Super-49B-v1 model: support nvidia/Llama-3_3-Nemotron-Super-49B-v1 Aug 12, 2025
@netanel-haber netanel-haber force-pushed the feature/support-nvidia-llama-3_3-nemotron-super-49b-v1 branch from b3c3bdb to 5169de4 Compare August 14, 2025 15:05
@netanel-haber netanel-haber requested a review from mickqian August 14, 2025 16:53
@netanel-haber
Copy link
Copy Markdown
Contributor Author

Hey @zhyncs - I think all of the failing tests are due to general flakiness and nothing to do with my changes, and Mick approved. What should my next steps be?

@zhyncs zhyncs merged commit 845d12a into sgl-project:main Aug 17, 2025
62 of 68 checks passed
narutolhy pushed a commit to narutolhy/sglang that referenced this pull request Aug 17, 2025
@b8zhong b8zhong mentioned this pull request Aug 18, 2025
81 tasks
MahmoudAshraf97 pushed a commit to MahmoudAshraf97/sglang that referenced this pull request Sep 8, 2025
@netanel-haber netanel-haber deleted the feature/support-nvidia-llama-3_3-nemotron-super-49b-v1 branch October 28, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants