Skip to content

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Sep 26, 2025

Summary:

This is needed for saving HF models with mxfp4 weights to disk.

Test Plan:

pytest test/prototype/mx_formats/test_mx_tensor.py -s -k test_clone

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Sep 26, 2025

Copy link

pytorch-bot bot commented Sep 26, 2025

🔗 Helpful Links

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

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

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 Sep 26, 2025
vkuzo added a commit that referenced this pull request Sep 26, 2025
Summary:

This is needed for saving HF models with mxfp4 weights to disk.

Test Plan:

```bash
pytest test/prototype/mx_formats/test_mx_tensor.py -s -k test_clone
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 300a78b
ghstack-comment-id: 3336365476
Pull Request resolved: #3070
@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 Sep 26, 2025
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
memory_format = kwargs.get("memory_format", None)

if memory_format is not None:
clone_fn = lambda x: x.clone(memory_format=memory_format)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just avoid the if statement with clone_fn = lambda x: x.clone(**kwargs)? Do we need to explicitly exclude other kwargs and only include memory format if specified, for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is copy-pasta from

def nvfp4_clone(func, types, args, kwargs):
, IMO let's separate cleanup of this into a separate PR

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vkuzo vkuzo changed the base branch from gh/vkuzo/122/head to main September 26, 2025 19:33
@vkuzo vkuzo merged commit 35277b9 into main Sep 26, 2025
35 of 45 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