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

Mismatch shape when applying and merging a locon model to a SanaTransformer2DModel module #230

Open
frutiemax92 opened this issue Jan 6, 2025 · 0 comments

Comments

@frutiemax92
Copy link

frutiemax92 commented Jan 6, 2025

I have trained a locon model based on Efficient-Large-Model/Sana_1600M_1024px_diffusers that I want to apply and merge.
https://huggingface.co/docs/diffusers/en/api/models/sana_transformer2d

Here is a zero initialized rank 4 locon model (untrained)
0.zip

I'm getting a mismatch size error (expecting [11200, 11200, 3, 3] but got [11200, 1, 3, 3]:
image
image
image
image
image

import torch
from diffusers import SanaTransformer2
from lycoris import create_lycoris_from_weights
step = '0'
transformer = SanaTransformer2DModel.from_pretrained("Efficient-Large-Model/Sana_1600M_1024px_diffusers", subfolder='transformer').to(dtype=torch.float16)
transformer.train(False)
with torch.no_grad():
    lycoris_net, weights = create_lycoris_from_weights(1.0, '0.safetensors', transformer)
    lycoris_net.train(False)
    for lora in lycoris_net.loras:
        lora = lora.to(dtype=torch.float16, device='cuda:1')
    lycoris_net.apply_to()
    lycoris_net.merge_to()

pipe = SanaPipeline.from_pretrained(
  "Efficient-Large-Model/Sana_1600M_1024px_diffusers",
  torch_dtype=torch.float16,
  variant='fp16',
  transformer=transformer,
  vae = None
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant