Skip to content

Conversation

@kaniel-outis
Copy link
Contributor

@kaniel-outis kaniel-outis commented Jan 4, 2026

Motivation

Supports quantization mode for the dispatch normal operator.

Result and Report

Two 910B tested:python test_internode.py
Before:
Accuracy issues arise after enabling fp8 quantization mode.

After:
The accuracy is correct; the script has completed execution.

performance:
single operator:
bf16:[tuning] Dispatch (BF16) 37.41 GB/s (HCCS), 9.37 GB/s (RDMA), avg_t: 12495.23 us, notify_t: 3939.33 us
[tuning] Combine 52.73 GB/s (HCCS), 13.21 GB/s (RDMA), avg_t: 8864.13 us

int8:[tuning] Dispatch (INT8) 34.00 GB/s (HCCS), 8.52 GB/s (RDMA), avg_t: 6873.71 us, notify_t: 2805.58 us
[tuning] Combine 53.17 GB/s (HCCS), 13.32 GB/s (RDMA), avg_t: 8790.47 us

model:
bf16:
int8:

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kaniel-outis, 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 bug related to quantization in the A2 dispatch mechanism. It primarily introduces support for FP8 quantization by modifying the dispatch_normal_a2 kernel to correctly instantiate the CamMoeDistributeDispatchA2Layered operator with int8_t for a specific tiling configuration. The changes also include minor code cleanup and the addition of a debug print statement.

Highlights

  • FP8 Quantization Support: Introduced a new dispatch path for TILING_KEY_IS(2100001002) that utilizes int8_t for quantization within the CamMoeDistributeDispatchA2Layered operator, addressing a bug in A2 dispatch quantization.
  • Tiling Data Handling: Ensured correct retrieval of CamMoeDistributeDispatchA2TilingData by uncommenting the GET_TILING_DATA_WITH_STRUCT call for relevant tiling keys.
  • Code Cleanup and Debugging: Removed significant blocks of commented-out code and added a printf debug statement to the dispatch_normal_a2 kernel for better observability.

🧠 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.

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

The pull request modifies dispatch_normal_a2.cpp by adding a printf debugging statement, removing several blocks of commented-out code, and refactoring the GET_TILING_DATA_WITH_STRUCT call to be conditionally executed within specific TILING_KEY_IS branches. Specifically, it removes TILING_KEY_IS(2000000000) and TILING_KEY_IS(2000001000) blocks, adds GET_TILING_DATA_WITH_STRUCT to the TILING_KEY_IS(2100001000) block, and introduces a new TILING_KEY_IS(2100001002) block that initializes CamMoeDistributeDispatchA2Layered with int8_t and different template parameters. The review comment highlights that the newly added printf statement is for debugging and should be removed before merging to prevent log spam and performance degradation in production.

{
// REGISTER_TILING_DEFAULT(NotifyDispatchA2TilingData);
// GET_TILING_DATA_WITH_STRUCT(NotifyDispatchA2TilingData, tilingData, tiling);
printf("[dispatch_normal_a2] blockId: %d\n", GetBlockIdx());
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This printf statement appears to be for debugging purposes. It should be removed before merging to avoid spamming logs and potential performance degradation in production environments, especially within a kernel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

solved

@Yael-X
Copy link
Collaborator

Yael-X commented Jan 17, 2026

Please supplement the performance difference of a single operator before and after quantization and the performance difference of the end-to-end model before and after quantization.

DataCopyPad(tokenTempTensorU8_, xGMTensorU8_[(startTokenId + i) * tokenLenInStruct_],
tokenCopyParamsNoQuant, tokenPadParams);
}
SyncFunc<AscendC::HardEvent::V_MTE2>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a comment explaining what problems would occur if this synchronization is not added, and why adding this synchronization would prevent these problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

action="store_true",
help="Whether to enable diagnose for testing",
)
parser.add_argument(
Copy link
Collaborator

Choose a reason for hiding this comment

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

The switch for enabling or disabling quantization needs to be added to the test script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

)
if local_rank == 0:
print(
f'[tuning] Dispatch ({"FP8" if isinstance(current_x, tuple) else "BF16"}) {recv_bytes / 1e9 / t:.2f} GB/s (HCCS), '
Copy link
Collaborator

Choose a reason for hiding this comment

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

The logic for determining whether to enable quantization is incorrect here. Please correct it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

@kaniel-outis kaniel-outis left a comment

Choose a reason for hiding this comment

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

Add relative test cases to pr-test-npu.yml,but need a2 in CI

Kaniel_Zhou added 2 commits January 19, 2026 14:20
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