diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

[Proposal] Support saving to safetensors

Open MatthieuBizien opened this issue 2 years ago • 1 comments

Follow-up of https://github.com/huggingface/diffusers/pull/1357, and mimics Transformers https://github.com/huggingface/transformers/pull/20321/files#diff-82b93b530be62e40679876a764438660dedcd9cc9e33c2374ed21b14ebef5dba

MatthieuBizien avatar Nov 30 '22 17:11 MatthieuBizien

The documentation is not available anymore as the PR was closed or merged.

@Narsil what do you think?

patrickvonplaten avatar Dec 01 '22 17:12 patrickvonplaten

Great work @MatthieuBizien - thanks for the PR :-)

patrickvonplaten avatar Dec 02 '22 17:12 patrickvonplaten

Hello @Narsil @patrickvonplaten 👋! Awesome to see this merged.

I am wondering if you have latency figures that compare loading a Stable Diffusion pipeline with and without safetensors on GPUs. Documentation elsewhere seems to suggest this should be faster. I am wondering if that's actually the case and, if so, how much faster that is.

luiscape avatar Dec 02 '22 18:12 luiscape

It's really hard to answer in general. It will skip a cpu allocation and create objects directly on the gpu (using SAFETENSORS_FAST_GPU=1 environment variable). For cpu the loading part should be almost instant in a lot of cases. But it does depend on hardware.

Here is someone that had lots of success apparently.

https://gist.github.com/xrpgame/8f756f99b00b02697edcd5eec5202c59?permalink_comment_id=4388611#gistcomment-4388611

Some report barely a change.

Personally it's mostly 2x. Didn't see anyone observing it being slower though.

So I guess you're going to have to measure😉

Narsil avatar Dec 03 '22 16:12 Narsil