Skip to content

Conversation

@idoh
Copy link
Contributor

@idoh idoh commented Nov 13, 2025

The current convert_to_hf.py does not support export_dtype, which makes it float32 by default. This PR adds support for export dtypes of ["float16", "bfloat16", "float32"].

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2025
Copy link
Contributor

@wwwjn wwwjn left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, I have a basic question - When do we need low precision weights?


@torch.inference_mode()
def convert_to_hf(input_dir, output_dir, model_name, model_flavor, hf_assets_path):
if model_name == "flux":
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we are removing this line here? Could you provide some tests results (can be simple as a screenshot or terminal outputs) to show it still works for FLUX model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I removed it because the import didn't make sense anymore as the flux folder was moved from experiments to the main models folders. So now it does not require "special" treatment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding when to use low precision, it is more space efficient, especially when uploading checkpoints to cloud storage. I kept the default export fp32 but IMO making bf16 the default export type makes more sense as most models that are uploaded today are in bf16.

@wwwjn
Copy link
Contributor

wwwjn commented Nov 15, 2025

Thank you! Could you fix the lint error from CI?

@idoh idoh force-pushed the hf-conversion-dtype branch from 8edfa3d to 9ce21b6 Compare November 16, 2025 17:49
@idoh
Copy link
Contributor Author

idoh commented Nov 16, 2025

@wwwjn Thanks, I fixed it so now the linting should pass.

Copy link
Contributor

@tianyu-l tianyu-l left a comment

Choose a reason for hiding this comment

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

sgtm

@tianyu-l tianyu-l merged commit 22e959a into pytorch:main Nov 17, 2025
8 of 9 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 Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants