Skip to content

fix(pcg,mm): fix zeroing of input_embeds when replay PCG#22229

Merged
ispobock merged 1 commit into
sgl-project:mainfrom
cs-cat:pcg-mm-fix
Apr 7, 2026
Merged

fix(pcg,mm): fix zeroing of input_embeds when replay PCG#22229
ispobock merged 1 commit into
sgl-project:mainfrom
cs-cat:pcg-mm-fix

Conversation

@cs-cat
Copy link
Copy Markdown
Contributor

@cs-cat cs-cat commented Apr 7, 2026

Motivation

Before PCG replay, there was an error in the buffer clearing logic for multimodal models. The shape of buffers.input_embeds is (num_tokens, num_dim), and existing code incorrectly cleared it using the second dimension index. In some cases (num_dim > static_num_tokens), this could cause input_embeds to retain content from the previous inference, potentially leading to incorrect inference results. This PR uses the correct clearing logic, indexing in the tokens dimension.

For maintainers: I'm unsure if this issue causes a decrease in multimodal model accuracy and is related to some issues. It seems that PCG for multimodal models is not enabled by default for all models. I tested Qwen 3.5-27B on a sglang build that fixes the graph recompile and was able to reproduce the issue mentioned in this PR. The shape of input_embeds is (4096, 5120), and static_num_tokens = 4096.

Modifications

The logic for clearing inputs_embeds has been corrected before replaying the multimodal model PCG.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@cs-cat cs-cat requested a review from hebiao064 as a code owner April 7, 2026 02:58
@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!

@cs-cat
Copy link
Copy Markdown
Contributor Author

cs-cat commented Apr 7, 2026

@Oasis-Git @ch-wan Could you please review this?

Copy link
Copy Markdown
Collaborator

@Oasis-Git Oasis-Git left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. It is correct.

@ispobock
Copy link
Copy Markdown
Collaborator

ispobock commented Apr 7, 2026

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci label Apr 7, 2026
@ispobock ispobock merged commit 233f3e3 into sgl-project:main Apr 7, 2026
143 of 162 checks passed
liuhuijiayou pushed a commit to liuhuijiayou/sglang that referenced this pull request Apr 7, 2026
liuhuijiayou pushed a commit to liuhuijiayou/sglang that referenced this pull request Apr 7, 2026
yhyang201 pushed a commit to yhyang201/sglang that referenced this pull request Apr 22, 2026
caitengwei pushed a commit to caitengwei/sglang that referenced this pull request Jun 1, 2026
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.

3 participants