Skip to content

[Pytorch] Fix swizzle scale output shape in variable shape case - #3344

Merged
YangFei1990 merged 4 commits into
NVIDIA:mainfrom
YangFei1990:fix_swizzle_output
Aug 12, 2026
Merged

[Pytorch] Fix swizzle scale output shape in variable shape case#3344
YangFei1990 merged 4 commits into
NVIDIA:mainfrom
YangFei1990:fix_swizzle_output

Conversation

@YangFei1990

Copy link
Copy Markdown
Collaborator

Description

The swizzle scale output shape computation does not respect the first/last dim settings, which still always assume even split. This PR adds support for the variable shape case.

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

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: YangFei1990 <feiw@nvidia.com>
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR corrects grouped MXFP8 swizzle output allocation for variable-shaped tensors by preserving the existing scale-buffer shape.

  • Distinguishes variable-shaped grouped tensors from uniform-shaped tensors during scale allocation.
  • Adds regression coverage for imbalanced groups, empty groups, rowwise and columnwise scales, and requantization paths.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
transformer_engine/pytorch/csrc/extensions/swizzle.cpp Preserves scale-buffer capacity for variable-shaped grouped swizzles while retaining padded shape computation for uniform groups.
tests/pytorch/mxfp8/test_mxfp8_group_quantize_graph_safe.py Adds focused regression cases that validate shape preservation and per-group scale contents across rowwise, columnwise, empty-group, and requantization scenarios.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix_swizzle_out..." | Re-trigger Greptile

@YangFei1990

Copy link
Copy Markdown
Collaborator Author

/te-ci L1 pytorch

@vthumbe1503 vthumbe1503 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

@YangFei1990

Copy link
Copy Markdown
Collaborator Author

/te-ci L1 pytorch

@YangFei1990
YangFei1990 merged commit 1ad30c6 into NVIDIA:main Aug 12, 2026
28 of 33 checks passed
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