huggingface / accelerate

🚀 A simple way to launch, train, and use PyTorch models on almost any device and distributed configuration, automatic mixed precision (including fp8), and easy-to-configure FSDP and DeepSpeed support
https://huggingface.co/docs/accelerate
Apache License 2.0
7.93k stars 966 forks source link

[feature request] Custom model filename in `Accelerator.save_model()` #2243

Closed arxyzan closed 1 month ago

arxyzan commented 11 months ago

Hello dear 🤗Accelerate team!

As far as I know, there is no option for defining any other weights file name other than the default pytorch_model.bin or model.safetensors files when using accelerator.save_model(). Is it possible to add an argument to this method to accept other filenames?

Note: According to the current procedures in the code, the filenames must either end with .bin or .safetensors.

This feature would help people who want to migrate their own code bases or libraries to 🤗Accelerate.

muellerzr commented 11 months ago

We can look at supporting this but it would be very limited to just save_model and specifically would be incompatible with other areas of the library such as save and load state.

This is because we’re consistent across transformers and accelerate in regards to naming conventions.

arxyzan commented 10 months ago

Dear @muellerzr, thanks for the fast response. You're right and I do know that it's because of the naming conventions that there would be no need for such feature. But if someone actually wants to use this method in their own library (e.g, an in-house library in the company that has different naming conventions) they would need to either reimplement the whole checkpoint sharding and names mapping themselves or implement such feature in a custom fork of accelerate to be able to save weights under different names than the ones in Transformers.

But overall, if you think this would be a limited and over-specific feature, I don't mind closing this issue.🤗