Skip to content

Skip fetching unused next tile in Mxfp8 quantization kernel - #3500

Merged
ptrendx merged 1 commit into
NVIDIA:mainfrom
WanZzzzzz:quant-opt-skip
Sep 10, 2026
Merged

ptrendx merged 1 commit into
NVIDIA:mainfrom
WanZzzzzz:quant-opt-skip

Conversation

@WanZzzzzz

Copy link
Copy Markdown
Contributor

Description

Skip fetching the next unused tile in the for-loop logic. This optimization give 5% additional perf improvement for mxfp8 cast-only + swizzle kernel.

Fixes # (issue)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: qiyuw <qiyuw@nvidia.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Sep 9, 2026
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR optimizes the MXFP8 cast-only and swizzle kernel by avoiding a speculative fetch after the final iteration-space tile.

  • Adds an iteration-bound check to the pipelined prefetch condition.
  • Preserves fetching for all four tiles consumed by the reachable two-stage pipeline.
  • Avoids unnecessary wait and commit operations when there is no next tile.

Confidence Score: 5/5

The PR appears safe to merge because the added guard skips only an unused out-of-range prefetch while preserving every fetch required by the consumer pipeline.

The changed kernel has one reachable configuration with four iteration tiles and two pipeline stages. Tiles 0–3 are fetched before consumption, while the new condition becomes false only for next tile index 4 after tile 3 has already been staged.

Important Files Changed

Filename Overview
transformer_engine/common/cast/mxfp8/specialized/quantize_mxfp8.cuh Adds a correct iteration-space bound to prevent fetching a nonexistent tile after the last pipelined MXFP8 quantization iteration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  P["Prologue: fetch tile 0"] --> I0["Iteration 0: fetch tile 1; consume tile 0"]
  I0 --> I1["Iteration 1: fetch tile 2; consume tile 1"]
  I1 --> I2["Iteration 2: fetch tile 3; consume tile 2"]
  I2 --> I3["Iteration 3: skip next=4 fetch; consume tile 3"]
  I3 --> O["Commit output"]
Loading

Reviews (1): Last reviewed commit: "mxfp8 quant: skip fetching next tile" | Re-trigger Greptile

@tdophung tdophung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Oleg-Goncharov

Copy link
Copy Markdown
Collaborator

/te-ci

@Oleg-Goncharov Oleg-Goncharov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. We can merge it once the CI tests pass.

@ptrendx
ptrendx merged commit 1634a5a into NVIDIA:main Sep 10, 2026
30 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants