Skip to content

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Oct 1, 2025

Summary:

Enables NVFP4Tensor to be created from a 3d weight. Note that slicing is gated to 2d tensors for now, we can enable that in a future PR if needed.

This is needed for vLLM stitching 2d weights into a 3d weight for MoEs.

Test Plan:

pytest test/prototype/mx_formats/ -s

Reviewers:

Subscribers:

Tasks:

Tags:

vkuzo added 7 commits October 1, 2025 11:07
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Oct 1, 2025

Copy link

pytorch-bot bot commented Oct 1, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit baf7568 with merge base 8955739 (image):
💚 Looks good so far! There are no failures yet. 💚

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

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

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 9f4b94d
ghstack-comment-id: 3357908175
Pull-Request: #3109
@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
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 2, 2025
Summary:

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 9beecf8
ghstack-comment-id: 3357908175
Pull-Request: #3109
@vkuzo vkuzo changed the base branch from gh/vkuzo/134/head to main October 2, 2025 11:34
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 2, 2025
Summary:

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: e0dbd18
ghstack-comment-id: 3357908175
Pull-Request: #3109
@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 2, 2025
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 2, 2025
Summary:

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: b53a9c2
ghstack-comment-id: 3357908175
Pull-Request: #3109
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 2, 2025
Summary:

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: a69b96d
ghstack-comment-id: 3357908175
Pull-Request: #3109
@vkuzo vkuzo changed the title [wip] enable 3d weights for NVFP4Tensor enable 3d weights for NVFP4Tensor Oct 2, 2025
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Oct 2, 2025
Summary:

doesn't work yet, stay tuned

this is needed for vLLM stitching 2d weights into a 3d weight for MoEs

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
ghstack-source-id: 9ab5657
ghstack-comment-id: 3357908175
Pull-Request: #3109
[ghstack-poisoned]
assert len(data_hp.shape) == 2, "unsupported"
M, K = data_hp.shape[0], data_hp.shape[1]
assert len(data_hp.shape) in (2, 3), "unsupported"
leading_dims, M, K = data_hp.shape[:-2], data_hp.shape[-2], data_hp.shape[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

just fyi, i think you can do:

*leading_dims, M, K = data_hp.shape

new = NVFP4Tensor(
new_qdata,
new_scale,
old._block_size,
Copy link
Contributor

Choose a reason for hiding this comment

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

would block size change with transpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently block_size is an integer for this tensor, 16 for NVFP4. If we change it to a multidimensional block, we'd have to update this code.

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