Skip to content

Conversation

nikhil-arm
Copy link
Contributor

@nikhil-arm nikhil-arm commented Aug 28, 2025

Purpose

Fix gptoss router layer to support quantization and remove hardcoded data type

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@mergify mergify bot added the gpt-oss Related to GPT-OSS models label Aug 28, 2025
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 refactors the router in the GptOssMoE layer to use ReplicatedLinear, which enables quantization support and removes a hardcoded bfloat16 dtype. This is a good improvement for flexibility and performance. However, the change also modifies the router's architecture by removing the bias term, which could be a critical issue if the original model checkpoints expect a bias. Overall, the changes are well-targeted to address the quantization issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The original implementation used torch.nn.Linear, which has bias=True by default. This change explicitly sets bias=False. This is a change in the model's architecture. If gpt-oss model checkpoints contain a bias term for the router, this change will cause weight loading to fail. If they do not contain a bias, then this change is a valuable correction, as the previous implementation would have used a randomly initialized bias, leading to incorrect behavior.

Copy link

mergify bot commented Aug 28, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @nikhil-arm.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 28, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is similar to glm4 moe, cannot use ReplicatedLinear

Copy link
Contributor Author

@nikhil-arm nikhil-arm Aug 28, 2025

Choose a reason for hiding this comment

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

Thanks for your review

Copy link
Contributor Author

@nikhil-arm nikhil-arm Aug 28, 2025

Choose a reason for hiding this comment

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

How should we handle the hardcoded dtype?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep the hardcode for now, and then can we add acomment like in glm moe to indicate that we cannot use ReplicatedLinear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The hardcode causes a data type missmatch issue when we load model in fp32 or half. The in and out tensor data type conversion for this layer is not handled correctly.

Copy link
Collaborator

@jeejeelee jeejeelee Aug 28, 2025

Choose a reason for hiding this comment

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

That makes sense, let's remove the hardcoded type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Nikhil Gupta <nikhil.gupta2@arm.com>
@nikhil-arm nikhil-arm changed the title [fix]: Allow router quantization in gptoss [fix]: remove data type hardcoding from gptoss model implementation Sep 17, 2025
@mergify mergify bot removed the needs-rebase label Sep 17, 2025
@nikhil-arm
Copy link
Contributor Author

@jeejeelee can you please review and merge this PR. thanks!

Copy link
Collaborator

@jeejeelee jeejeelee left a comment

Choose a reason for hiding this comment

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

Thank you

@github-project-automation github-project-automation bot moved this from In progress to Ready in gpt-oss Issues & Enhancements Sep 18, 2025
@jeejeelee jeejeelee added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 18, 2025
@jeejeelee jeejeelee enabled auto-merge (squash) September 18, 2025 16:20
@jeejeelee jeejeelee merged commit 064cac7 into vllm-project:main Sep 18, 2025
59 checks passed
debroy-rh pushed a commit to debroy-rh/vllm that referenced this pull request Sep 19, 2025
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
charlifu pushed a commit to ROCm/vllm that referenced this pull request Sep 25, 2025
…llm-project#23807)

Signed-off-by: Nikhil Gupta <nikhil.gupta2@arm.com>
Signed-off-by: charlifu <charlifu@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpt-oss Related to GPT-OSS models ready ONLY add when PR is ready to merge/full CI is needed
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants