Skip to content

add mxfp8 and nvfp4 support to safetensors#3668

Merged
liangel-02 merged 1 commit into
mainfrom
mx_safetensors
Feb 16, 2026
Merged

add mxfp8 and nvfp4 support to safetensors#3668
liangel-02 merged 1 commit into
mainfrom
mx_safetensors

Conversation

@liangel-02

@liangel-02 liangel-02 commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

As title.

@pytorch-bot

pytorch-bot Bot commented Jan 21, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8bd3bbc with merge base 561b50b (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 Jan 21, 2026
@liangel-02 liangel-02 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Jan 21, 2026
@liangel-02 liangel-02 marked this pull request as ready for review January 21, 2026 19:49
@liangel-02 liangel-02 requested a review from jerryzh168 January 21, 2026 19:49
@jerryzh168

Copy link
Copy Markdown
Contributor

I see, cc @vkuzo should we just change all the attribute names to be public? e.g. _orig_dtype --> orig_dtype and _is_swizzled_scales --> is_swizzled_scales in NVFP4Tensor (

tensor_attribute_names = [
"block_size",
"_orig_dtype",
]
optional_tensor_data_names = ["per_tensor_scale", "act_per_tensor_scale"]
optional_tensor_attribute_names = [
"_is_swizzled_scales",
)

@vkuzo

vkuzo commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

I see, cc @vkuzo should we just change all the attribute names to be public? e.g. _orig_dtype --> orig_dtype and _is_swizzled_scales --> is_swizzled_scales in NVFP4Tensor (

tensor_attribute_names = [
"block_size",
"_orig_dtype",
]
optional_tensor_data_names = ["per_tensor_scale", "act_per_tensor_scale"]
optional_tensor_attribute_names = [
"_is_swizzled_scales",

)

sounds good, as long as we are clear there is no BC on this as its in prototype

@jerryzh168

Copy link
Copy Markdown
Contributor

yeah it's clear I think, since these are imported from prototype folder.

@liangel-02 maybe first open a PR to change these names first, then we can remove the workaround in this PR

Comment thread torchao/prototype/safetensors/safetensors_utils.py
Comment thread test/prototype/safetensors/test_safetensors_support.py Outdated
@liangel-02 liangel-02 force-pushed the mx_safetensors branch 2 times, most recently from c94be30 to 07650dd Compare February 11, 2026 16:43

@jerryzh168 jerryzh168 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

changes looks good, please add test with checkpoints as well to make sure it works e2e (can either upload to https://huggingface.co/torchao-testing or just test with personal id)

@liangel-02

Copy link
Copy Markdown
Contributor Author

changes looks good, please add test with checkpoints as well to make sure it works e2e (can either upload to https://huggingface.co/torchao-testing or just test with personal id)

@jerryzh168 i uploaded both checkpoints to https://huggingface.co/torchao-testing, see https://huggingface.co/torchao-testing/Qwen3-8B-NVFP4-safetensors and https://huggingface.co/torchao-testing/Qwen3-8B-MXFP8-safetensors. merging now!

@liangel-02 liangel-02 merged commit 5906856 into main Feb 16, 2026
19 checks passed
@jerryzh168

Copy link
Copy Markdown
Contributor

@liangel-02 thanks, please update the model card of these checkpoints on repro instructions as well: https://huggingface.co/torchao-testing/Qwen3-8B-NVFP4-safetensors, example: https://huggingface.co/torchao-testing/opt-125m-Float8WeightOnlyConfig-v2-0.15.0

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.

3 participants