diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Compute embedding distances with torch.cdist

Open blefaudeux opened this issue 3 years ago • 3 comments

20Go -> 16Go Ram use for some workloads, same speed (you don´t have to materialize intermediates with torch.cdist)

blefaudeux avatar Nov 28 '22 18:11 blefaudeux

cc @patrickvonplaten, not what we discussed but this is an effective three liner

blefaudeux avatar Nov 28 '22 18:11 blefaudeux

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

LGTM! thanks!

kashif avatar Nov 28 '22 20:11 kashif

Hey @blefaudeux,

How to you use this feature I think it's only used in decoding if "force_not_quantize" is set to True no?

patrickvonplaten avatar Dec 01 '22 17:12 patrickvonplaten

Hey @blefaudeux,

How to you use this feature I think it's only used in decoding if "force_not_quantize" is set to True no?

It's in the superres path, not doing that just eats 4GB ram when decoding for nothing. It's very much not perfect though, I'm looking at better options, but better than not doing that :)

blefaudeux avatar Dec 01 '22 20:12 blefaudeux

improves on https://github.com/huggingface/diffusers/issues/1434

blefaudeux avatar Dec 01 '22 20:12 blefaudeux

cc @patil-suraj, if you're interested in high res superres

blefaudeux avatar Dec 02 '22 15:12 blefaudeux

Thanks a lot for the PR, this looks good to me! Will run the slow tests and then merge.

Also for high resolution upscaling, I'm exploring another option in #1521, and it seems to work well.

thanks for the link ! for this PR I think it's always worth it because no tradeoff, it's just better than the previous three lines, but it's not enough to enable high res that's for sure ! No issues with borders when splitting the decode ?

Another option if the convs were depth wise would have been to compute them depth-first (à la "Rerformer" years ago), but that's probably not a reasonable option so I guess that splitting is as good as it gets ?

blefaudeux avatar Dec 05 '22 20:12 blefaudeux