Skip to content

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Oct 1, 2025

Summary:

Makes NVFP4Tensor._scale_e4m3 shape be consistent with NVFP4Tensor.shape. Specifically:

  1. if the scales are not swizzled, contiguous data shape (M, K) corresponds to scale shape (M, K // 16)
  2. if the scales are swizzled, contiguous data shape (M, K) corresponds to scale shape (ceil_div(M, 128) * 32, ceil_div(K, 64) * 16)

If we transpose axes 0 and 1, both qdata and scale now get transposed.

I want this because we need to reason about scales when combining 2d MoE weights into 3d weights, and having the scale shape match the data will make that reasoning easier (in a future PR).

Test Plan:

tests pass on a B200:

pytest test/prototype/mx_formats/ -s

also, a dense model quantized with torchao nvfp4 runs in vLLM before and after this PR

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Oct 1, 2025

vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 99359fb
ghstack-comment-id: 3357503258
Pull-Request: #3108
Copy link

pytorch-bot bot commented Oct 1, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3108

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 08e9d13 with merge base 9368b28 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 1, 2025
@vkuzo
Copy link
Contributor Author

vkuzo commented Oct 1, 2025

need to fix swizzle slicing tests

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: dc4970e
ghstack-comment-id: 3357503258
Pull-Request: #3108
@vkuzo vkuzo added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Oct 1, 2025
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: d02e473
ghstack-comment-id: 3357503258
Pull-Request: #3108
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 2d32a48
ghstack-comment-id: 3357503258
Pull-Request: #3108
@vkuzo vkuzo changed the title [wip] make scale shape 2d and match qdata shape in NVFP4Tensor make scale shape 2d and match qdata shape in NVFP4Tensor Oct 1, 2025
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 6d5cad3
ghstack-comment-id: 3357503258
Pull-Request: #3108
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 6d5cad3
ghstack-comment-id: 3357503258
Pull-Request: #3108
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 1, 2025
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 9dd2ad6
ghstack-comment-id: 3357503258
Pull-Request: #3108
@vkuzo vkuzo merged commit 1d64cbb into main Oct 1, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants