Sana icon indicating copy to clipboard operation
Sana copied to clipboard

RuntimeError: mat1 and mat2 shapes cannot be multiplied (600x2048 and 2304x2240)

Open mingziwen opened this issue 7 months ago • 1 comments

When I use the downloaded model weights for inference:

python inference.py
--config=/code/configs/sana_config/1024ms/Sana_1600M_img1024.yaml
--model_path=/models/Sana_1.6_1024/Sana_1600M_1024px_BF16/checkpoints/Sana_1600M_1024px_BF16.pth
--txt_file=/code/asset/samples/samples_mini.txt

An error occurs: RuntimeError: mat1 and mat2 shapes cannot be multiplied (600x2048 and 2304x2240)

mingziwen avatar Apr 18 '25 07:04 mingziwen

Have you changed anything?

lawrence-cj avatar May 08 '25 05:05 lawrence-cj

Same Error

`[AutoencoderDC] Loading model from /xcloud-shared/models/hub/models--mit-han-lab--dc-ae-f32c32-sana-1.1-diffusers/snapshots/6f7b3f3b289a439a11ef4fb1034989fd4b9a4766 Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [03:23<00:00, 101.77s/it] use pe: False, pos embed type: sincos, position embed interpolation: 1.0, base size: 32 attention type: linear; ffn type: glumbconv; self-attn qk norm: False; cross-attn type: flash; cross-attn qk norm: False; autocast linear attn: False 2025-07-11 05:08:13 - [Sana] - INFO - SanaMS:SanaMS_1600M_P1_D20, Model Parameters: 1,604,462,752 2025-07-11 05:08:13 - [Sana] - INFO - Generating sample from ckpt: /xcloud-shared/models/hub/models--Efficient-Large-Model--Sana_1600M_1024px/snapshots/f69c052d762128f96927aa87fac6204978bddc8e/checkpoints/Sana_1600M_1024px.pth [Sana] Loading model from /xcloud-shared/models/hub/models--Efficient-Large-Model--Sana_1600M_1024px/snapshots/f69c052d762128f96927aa87fac6204978bddc8e/checkpoints/Sana_1600M_1024px.pth 2025-07-11 05:12:51 - [Sana] - WARNING - Missing keys: ['pos_embed'] 2025-07-11 05:12:51 - [Sana] - WARNING - Unexpected keys: [] 2025-07-11 05:12:51 - [Sana] - INFO - Saving images at /xcloud-shared/models/hub/models--Efficient-Large-Model--Sana_1600M_1024px/snapshots/f69c052d762128f96927aa87fac6204978bddc8e/vis 2025-07-11 05:12:51 - [Sana] - INFO - Eval first 10/10 samples 2025-07-11 05:12:53 - [Sana] - INFO - Sampler flow_dpm-solver 2025-07-11 05:12:53 - [Sana] - INFO - Setting back to classifier-free 2025-07-11 05:12:53 - [Sana] - INFO - Inference with torch.bfloat16, guidance_type: classifier-free, flow_shift: 3.0 custom_epochunknown_stepunknown_scale4.5_step20_size1024_bs1_sampflow_dpm-solver_seed0_bfloat16_flowshift3.0_imgnums100000 Using GPU: 0: 0-30000: 0%| | 0/10 [00:00<?, ?batch/s] Traceback (most recent call last): File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 441, in model_fn noise_uncond, noise = noise_pred_fn(x_in, t_in, cond=c_in).chunk(2) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 386, in noise_pred_fn output = model(x, t_input, cond, **model_kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_multi_scale.py", line 370, in call return self.forward(*args, **kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_multi_scale.py", line 320, in forward y = self.y_embedder(y, self.training, mask=mask) # (N, D) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_blocks.py", line 716, in forward caption = self.y_proj(caption) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/timm/models/layers/mlp.py", line 27, in forward x = self.fc1(x) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 117, in forward return F.linear(input, self.weight, self.bias) RuntimeError: mat1 and mat2 shapes cannot be multiplied (600x2048 and 2304x2240)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/jupyter/Sana/scripts/inference.py", line 452, in visualize( File "/opt/conda/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) File "/home/jupyter/Sana/scripts/inference.py", line 208, in visualize samples = dpm_solver.sample( File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 1529, in sample model_prev_list = [self.model_fn(x, t)] File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 689, in model_fn return self.data_prediction_fn(x, t) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 677, in data_prediction_fn noise = self.noise_prediction_fn(x, t) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 671, in noise_prediction_fn return self.model(x, t) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 616, in self.model = lambda x, t: model_fn(x, t.expand(x.shape[0])) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 443, in model_fn noise_uncond, noise = noise_pred_fn(x_in, t_in, cond=c_in)[0].chunk(2) File "/home/jupyter/Sana/diffusion/model/dpm_solver.py", line 386, in noise_pred_fn output = model(x, t_input, cond, **model_kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_multi_scale.py", line 370, in call return self.forward(*args, **kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_multi_scale.py", line 320, in forward y = self.y_embedder(y, self.training, mask=mask) # (N, D) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/home/jupyter/Sana/diffusion/model/nets/sana_blocks.py", line 716, in forward caption = self.y_proj(caption) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/timm/models/layers/mlp.py", line 27, in forward x = self.fc1(x) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 117, in forward return F.linear(input, self.weight, self.bias) RuntimeError: mat1 and mat2 shapes cannot be multiplied (600x2048 and 2304x2240)`

seemandharGoogle avatar Jul 10 '25 22:07 seemandharGoogle