Skip to content

update mix test and low lantency test for dynamic-tokens.#376

Merged
Yael-X merged 2 commits intosgl-project:mainfrom
zhuyutong332:temp
Mar 4, 2026
Merged

update mix test and low lantency test for dynamic-tokens.#376
Yael-X merged 2 commits intosgl-project:mainfrom
zhuyutong332:temp

Conversation

@zhuyutong332
Copy link
Contributor

update mix test and low lantency test for dynamic-tokens.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zhuyutong332, 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 refactors and simplifies the low-latency and normal test suites for dynamic token handling. The changes primarily focus on improving consistency in token parameter naming, streamlining tensor initialization, and enhancing the robustness of validation logic, particularly concerning topk_idx padding and num_valid_tokens checks. These updates aim to make the tests more maintainable and accurate when dealing with varying token counts across ranks.

Highlights

  • Refactored Token Handling: The actual_num_tokens parameter has been consistently renamed to num_tokens across relevant test functions, simplifying the API and improving clarity.
  • Simplified Tensor Initialization: Tensor initialization logic for x, scores, topk_idx, and topk_weights has been streamlined, removing redundant conditional checks and directly using num_tokens.
  • Improved topk_idx Padding: A padding mechanism was introduced for topk_idx before all_gather_into_tensor to correctly handle scenarios where num_tokens is less than aligned_num_tokens.
  • Streamlined Validation Logic: The validation checks for num_valid_tokens and the calculation of expected output (expected_x) have been simplified by removing the all_actual_tokens variable and related loops.
  • Updated Argument Help Text: The help message for the --enable-dynamic-tokens argument was clarified to better describe its purpose.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/python/deepep/test_low_latency.py
    • Renamed actual_num_tokens to num_tokens in the test function signature.
    • Simplified tensor initialization for x, scores, topk_idx, and topk_weights by removing conditional blocks.
    • Implemented padding for topk_idx using torch.cat before dist.all_gather_into_tensor.
    • Removed local_actual_tokens and all_actual_tokens variables, simplifying the num_valid_tokens assertion.
    • Changed torch.allclose to torch.equal for recv_x_amin assertion.
    • Streamlined the calculation of diff and expected_x within the do_check block.
    • Updated the loop range for bandwidth calculation from actual_num_tokens to num_tokens.
    • Added a comment indicating that return_recv_hook=True is not currently supported.
    • Clarified the help message for the --enable-dynamic-tokens command-line argument.
  • tests/python/deepep/test_normal_and_low_latency.py
    • Renamed actual_num_tokens to num_tokens in the low_latency_test function signature.
    • Simplified tensor initialization for x, scores, topk_idx, and topk_weights by removing conditional blocks.
    • Removed the conditional if actual_num_tokens > 0 block for calculating diff and expected_x.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/pr-test-npu.yml
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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 refactors the low-latency and mixed-mode tests to properly support dynamic token counts across different ranks. The changes simplify the test logic by creating tensors with actual token sizes rather than pre-allocating for a maximum size. Padding is now correctly handled just before collective communication operations like all_gather, which require uniform tensor sizes. The correctness checks and overall test code are now much cleaner and more readable. These are excellent improvements. I have one minor suggestion to improve code formatting.

@zhuyutong332 zhuyutong332 force-pushed the temp branch 2 times, most recently from b49274a to 047d700 Compare February 25, 2026 03:42
@Yael-X Yael-X merged commit f54103d into sgl-project:main Mar 4, 2026
6 checks passed
zhuyutong332 added a commit to zhuyutong332/sgl-kernel-npu that referenced this pull request Mar 5, 2026
* upstream/main:
  update mix test and low lantency test for dynamic-tokens. (sgl-project#376)
  [WIP] Fix bs zero for deepep (sgl-project#385)
  Change hccl Init and SetCcTiling interface to V2 version to avoid compile warnings (sgl-project#387)
  bump version to 2026.03.01 (sgl-project#388)
  feat:[fused_sigmoid_gating_delta_rule_update_npu_kernel] support kda feature--to be aligned with sgl-kernel, for model kimi-linear (sgl-project#371)
  revise causal_conv1d: bugfix and enhance accuracy for model kimilinear (sgl-project#370)
zhuyutong332 added a commit to zhuyutong332/sgl-kernel-npu that referenced this pull request Mar 5, 2026
* upstream/main:
  update mix test and low lantency test for dynamic-tokens. (sgl-project#376)
  [WIP] Fix bs zero for deepep (sgl-project#385)
  Change hccl Init and SetCcTiling interface to V2 version to avoid compile warnings (sgl-project#387)
  bump version to 2026.03.01 (sgl-project#388)
  feat:[fused_sigmoid_gating_delta_rule_update_npu_kernel] support kda feature--to be aligned with sgl-kernel, for model kimi-linear (sgl-project#371)
  revise causal_conv1d: bugfix and enhance accuracy for model kimilinear (sgl-project#370)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants