-
Notifications
You must be signed in to change notification settings - Fork 35
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
RuntimeError: The size of tensor a (128) must match the size of tensor b (2) at non-singleton dimension 6 #7
Comments
I tried the same thing, I guess their pipeline just doesn't support quantized Transformer yet. |
It's strange, isn't it? Why is it that after the model is quantized, the emb shape doesn't match instead of other errors? 31G VRAM also exceeds my limit. |
well, I assume their pipeline are data type sensitive, you may notice that in their sample code, they do: transformer = FluxTransformer2DModel.from_pretrained( if you comment the second line, there will be data type unmatch error. So I guess quantized models are not supported yet for this pipeline. |
I also encountered this problem when I ran the code in main.py directly. Have you ever had this problem without quantize? |
Try downgrade your diffusers==0.30.2 and transformers==4.42.0 |
OK, I'll try. Thanks! |
升级COMFYUI就这样 |
Poking into line ~1780 of Obviously this is a hacky solution and ideally diffusers itself would fix what's going on, or people can figure out some kind of workaround outside the diffusers library. # YiYi to-do: refactor rope related functions/classes
def apply_rope(xq, xk, freqs_cis):
xq_ = xq.float().reshape(*xq.shape[:-1], -1, 1, 2)
xk_ = xk.float().reshape(*xk.shape[:-1], -1, 1, 2)
xq_out = freqs_cis[..., 0] * xq_[..., 0] + freqs_cis[..., 1] * xq_[..., 1]
xk_out = freqs_cis[..., 0] * xk_[..., 0] + freqs_cis[..., 1] * xk_[..., 1]
return xq_out.reshape(*xq.shape).type_as(xq), xk_out.reshape(*xk.shape).type_as(xk)
if image_rotary_emb is not None:
from .embeddings import apply_rotary_emb
query, key = apply_rope(query, key, image_rotary_emb)
#query = apply_rotary_emb(query, image_rotary_emb)
#key = apply_rotary_emb(key, image_rotary_emb) |
@vbuterin that worked wonders, thank you
|
In order to reduce the memory usage, I use optimize.quanto to quantize transformer, controlnet, and t5encoder in fp8, but I encounter an error
my code is here:
And the complete error message is as follows:
I printed the shapes of some variables in apply_rotary_emb function , as follows,
The text was updated successfully, but these errors were encountered: