kohya-ss / kohya-ss/sd-scripts
LoHA error when using preset Full. RuntimeError: The size of tensor a (32) must match the size of tensor b (30) at non-singleton dimension 3
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Doesn't happen with the other presets.
`Traceback (most recent call last):
File "F:\kohya_ss-win\sdxl_train_network.py", line 189, in
trainer.train(args)
File "F:\kohya_ss-win\train_network.py", line 783, in train
noise_pred = self.call_unet(
File "F:\kohya_ss-win\sdxl_train_network.py", line 169, in call_unet
noise_pred = unet(noisy_latents, timesteps, text_embedding, vector_embedding)
File "F:\kohya_ss-win\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "F:\kohya_ss-win\venv\lib\site-packages\accelerate\utils\operations.py", line 680, in forward
return model_forward(*args, **kwargs)
File "F:\kohya_ss-win\venv\lib\site-packages\accelerate\utils\operations.py", line 668, in __call__
return convert_to_fp32(self.model_forward(*args, **kwargs))
File "F:\kohya_ss-win\venv\lib\site-packages\torch\amp\autocast_mode.py", line 14, in decorate_autocast
return func(*args, **kwargs)
File "F:\kohya_ss-win\library\sdxl_original_unet.py", line 1099, in forward
h = call_module(module, h, emb, context)
File "F:\kohya_ss-win\library\sdxl_original_unet.py", line 1088, in call_module
x = layer(x, emb)
File "F:\kohya_ss-win\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "F:\kohya_ss-win\library\sdxl_original_unet.py", line 343, in forward
x = torch.utils.checkpoint.checkpoint(create_custom_forward(self.forward_body), x, emb, use_reentrant=USE_REENTRANT)
File "F:\kohya_ss-win\venv\lib\site-packages\torch\utils\checkpoint.py", line 249, in checkpoint
return CheckpointFunction.apply(function, preserve, *args)
File "F:\kohya_ss-win\venv\lib\site-packages\torch\autograd\function.py", line 506, in apply
return super().apply(*args, **kwargs) # type: ignore[misc]
File "F:\kohya_ss-win\venv\lib\site-packages\torch\utils\checkpoint.py", line 107, in forward
outputs = run_function(*args)
File "F:\kohya_ss-win\library\sdxl_original_unet.py", line 339, in custom_forward
return func(*inputs)
File "F:\kohya_ss-win\library\sdxl_original_unet.py", line 331, in forward_body
return x + h
RuntimeError: The size of tensor a (32) must match the size of tensor b (30) at non-singleton dimension 3`
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce training with the preset Full and compare it with the presets that do not fail. Start at library/sdxl_original_unet.py, especially forward_body around line 331, then follow the call path from sdxl_train_network.py and train_network.py shown in the traceback. Done means the Full preset no longer raises the tensor-size mismatch during training.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100