Skip to content

Conversation

JustinTong0323
Copy link
Collaborator

@JustinTong0323 JustinTong0323 commented Oct 6, 2025

Motivation

Fix the issue below, which is caused by #10042

It looks like #10611 should be included in the latest release lmsysorg/sglang:v0.5.3-cu129 and lmsysorg/sglang:v0.5.3rc2-cu129 . but when i try python3 -m sglang.launch_server --model-path=nvidia/Llama-4-Scout-17B-16E-Instruct-FP8 --tp=8 --trust-remote-code --mem-fraction-static 0.7 --context-length=131072 --attention-backend=fa3 --enable-multimodal --tool-call-parser=pythonic --chat-template=llama-4 --cuda-graph-max-bs=48 --host=0.0.0.0 --speculative-algorithm=EAGLE3 --speculative-num-steps=3 --speculative-eagle-topk=4 --speculative-num-draft-tokens=8 --speculative-draft-model-path=/models/llama-4-scout-eagle/state_7 --port=8000
i now see the error

2025-10-06 17:09:50 TP6] Scheduler hit an exception: Traceback (most recent call last):
  File "/sgl-workspace/sglang/python/sglang/srt/managers/scheduler.py", line 2847, in run_scheduler_process
    scheduler = Scheduler(
                ^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/managers/scheduler.py", line 396, in __init__
    self.tp_worker = TpWorkerClass(
                     ^^^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/managers/tp_worker.py", line 100, in __init__
    self.model_runner = ModelRunner(
                        ^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/model_executor/model_runner.py", line 298, in __init__
    self.initialize(min_per_gpu_memory)
  File "/sgl-workspace/sglang/python/sglang/srt/model_executor/model_runner.py", line 345, in initialize
    self.load_model()
  File "/sgl-workspace/sglang/python/sglang/srt/model_executor/model_runner.py", line 789, in load_model
    self.model = get_model(
                 ^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/model_loader/__init__.py", line 28, in get_model
    return loader.load_model(
           ^^^^^^^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/model_loader/loader.py", line 494, in load_model
    self.load_weights_and_postprocess(
  File "/sgl-workspace/sglang/python/sglang/srt/model_loader/loader.py", line 502, in load_weights_and_postprocess
    model.load_weights(weights)
  File "/sgl-workspace/sglang/python/sglang/srt/models/mllama4.py", line 660, in load_weights
    if self._handle_stacked_params(
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/models/mllama4.py", line 719, in _handle_stacked_params
    param = params_dict[transformed_name]
            ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'language_model.model.layers.29.self_attn.qkv_proj.k_scale'

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Copy link
Contributor

Summary of Changes

Hello @JustinTong0323, 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!

This pull request addresses a logical flaw in the Llama4ForConditionalGeneration model's parameter remapping mechanism. It refines the condition within the _handle_scale_remapping function to ensure that scale parameters are correctly identified as 'handled,' encompassing scenarios where a parameter's name is changed as well as those where no remapping is necessary but the parameter still falls under the handling scope. This fix enhances the robustness and accuracy of parameter processing for Llama4 models.

Highlights

  • Logic Correction: Corrected the conditional logic within the _handle_scale_remapping method in Llama4ForConditionalGeneration to accurately determine when a scale parameter has been handled.
  • Parameter Remapping: The remapping logic now correctly accounts for cases where maybe_remap_kv_scale_name returns None (indicating no remapping occurred but the parameter is still considered handled) or when a remapping results in a different name.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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
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 corrects the logic for handling scale parameter remapping during model weight loading. The previous logic failed to correctly skip scale parameters that could not be remapped, potentially leading to errors. The new logic ensures that both unmappable and successfully remapped scale parameters are considered 'handled' and skipped by the loading loop. I've suggested a minor simplification to the return statement to improve readability.

JustinTong0323 and others added 2 commits October 6, 2025 15:46
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@JustinTong0323
Copy link
Collaborator Author

cc @BowenBao @HaiShaw @kkHuang-amd for review.

@HaiShaw
Copy link
Collaborator

HaiShaw commented Oct 7, 2025

cc @BowenBao

Copy link
Contributor

@BowenBao BowenBao left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@zhyncs zhyncs merged commit fd8a0b2 into sgl-project:main Oct 7, 2025
55 of 62 checks passed
PrinsYin pushed a commit to PrinsYin/sglang that referenced this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants