Skip to content

Conversation

@kkHuang-amd
Copy link
Collaborator

@kkHuang-amd kkHuang-amd commented Nov 7, 2025

Motivation

Handle multiple output number to solve the incorrect type in attention call when running deepseek mxfp4 model

Modifications

All used fused_rms_mxfp4_quant places

Accuracy Tests

Benchmarking and Profiling

# python3 benchmark/gsm8k/bench_sglang.py --num-questions 2000 --parallel 2000 --port 8000 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [01:23<00:00, 15.74it/s] Accuracy: 0.939 Invalid: 0.000 Latency: 84.240 s Output throughput: 1574.955 token/s

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kkHuang-amd, 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 resolves a critical runtime error affecting the fused_rms_mxfp4_quant function within the system. The issue stemmed from an updated return signature of this function, which was not correctly handled at its various call sites. By adjusting the unpacking of the function's outputs, this change ensures that deepseek mxfp4 models can operate without type errors during attention calculations, thereby restoring their intended functionality.

Highlights

  • Runtime Error Fix: Addresses a runtime error occurring when fused_rms_mxfp4_quant is called, specifically due to an incorrect number of return values being unpacked.
  • Function Signature Alignment: Updates call sites of fused_rms_mxfp4_quant to correctly handle its new return signature, which now includes additional outputs.
  • Deepseek MXFP4 Model Compatibility: Ensures proper functionality for deepseek mxfp4 models by resolving type inconsistencies in attention calls caused by the previous mismatch in return value handling.
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 addresses a runtime error caused by a change in the number of return values from the fused_rms_mxfp4_quant function. The changes correctly update the call sites to unpack the new number of return values across communicator.py and deepseek_v2.py. The fix is correct and directly addresses the issue. I have added a few suggestions to use extended iterable unpacking (*_) which would make the code more robust against potential future changes to the function's return signature.


if _use_aiter and _is_gfx95_supported and ("mxfp4" in qaunt_format):
hidden_states = fused_rms_mxfp4_quant(
hidden_states, _, _ = fused_rms_mxfp4_quant(
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness against future changes in the fused_rms_mxfp4_quant function's return signature, consider using *_ to capture all unused return values. This makes the code more resilient if the number of returned values changes again.

Suggested change
hidden_states, _, _ = fused_rms_mxfp4_quant(
hidden_states, *_ = fused_rms_mxfp4_quant(

else:
if _use_aiter and _is_gfx95_supported and ("mxfp4" in qaunt_format):
hidden_states, residual = fused_rms_mxfp4_quant(
hidden_states, _, residual = fused_rms_mxfp4_quant(
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness against future changes in the fused_rms_mxfp4_quant function's return signature, consider using *_ to capture all unused return values. This makes the code more resilient if the number of returned values changes again.

Suggested change
hidden_states, _, residual = fused_rms_mxfp4_quant(
hidden_states, *_, residual = fused_rms_mxfp4_quant(

else:
if _use_aiter_gfx95 and self.q_b_proj.weight.dtype == torch.uint8:
q, k_nope = fused_rms_mxfp4_quant(
q, k_nope, _ = fused_rms_mxfp4_quant(
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness against future changes in the fused_rms_mxfp4_quant function's return signature, consider using *_ to capture all unused return values. This also helps to fix the minor trailing whitespace issue.

Suggested change
q, k_nope, _ = fused_rms_mxfp4_quant(
q, k_nope, *_ = fused_rms_mxfp4_quant(

else:
if _use_aiter_gfx95 and self.q_b_proj.weight.dtype == torch.uint8:
q, k_nope = fused_rms_mxfp4_quant(
q, k_nope, _ = fused_rms_mxfp4_quant(
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness against future changes in the fused_rms_mxfp4_quant function's return signature, consider using *_ to capture all unused return values. This makes the code more resilient if the number of returned values changes again.

Suggested change
q, k_nope, _ = fused_rms_mxfp4_quant(
q, k_nope, *_ = fused_rms_mxfp4_quant(

@kkHuang-amd kkHuang-amd requested a review from ByronHsu as a code owner November 8, 2025 04:13
@github-actions github-actions bot added the amd label Nov 8, 2025
@HaiShaw HaiShaw merged commit 90401cf into sgl-project:main Nov 10, 2025
3 of 15 checks passed
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.

3 participants