-
Notifications
You must be signed in to change notification settings - Fork 342
enable 3d weights for NVFP4Tensor #3109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Stack from ghstack (oldest at bottom): |
🔗 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 FailuresAs of commit baf7568 with merge base 8955739 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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] |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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:
Reviewers:
Subscribers:
Tasks:
Tags: