Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading quantized models from quanto directly #9058

Closed
sayakpaul opened this issue Aug 2, 2024 · 2 comments
Closed

Support loading quantized models from quanto directly #9058

sayakpaul opened this issue Aug 2, 2024 · 2 comments
Labels
stale Issues that haven't received updates

Comments

@sayakpaul
Copy link
Member

With more and more and larger and larger diffusion transformer models coming up, I think it makes sense to support the direct loading of quantized models from quanto.

Currently, the workflow to load a quantized model with quanto is simple:

from diffusers import DiffusionPipeline
from optimum.quanto import QuantizedPixArtTransformer2DModel
import torch

transformer = QuantizedPixArtTransformer2DModel.from_pretrained("pixart-sigma-fp8").to("cuda", torch.float16) 
pipe = DiffusionPipeline.from_pretrained(
    "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS", 
    transformer=None,
    torch_dtype=torch.float16,
).to("cuda")
pipe.transformer = transformer

We should be able to just do:

pipe = PixArtSigmaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS", 
-    transformer=None,
+    transformer=transformer,
    torch_dtype=torch.float16,
).to("cuda")

Currently, transformer=transformer would fail because there's no mapping here:

Thoughts @yiyixuxu @DN6?

Copy link

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Sep 14, 2024
@sayakpaul
Copy link
Member Author

Closing this issue because we will add quanto quantization backend after #9213 is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that haven't received updates
Projects
None yet
Development

No branches or pull requests

1 participant