ai-toolkit icon indicating copy to clipboard operation
ai-toolkit copied to clipboard

Z image slides Error message:Batch size of latents must be the same or half the batch size of text embeddings

Open lixida123 opened this issue 10 months ago • 8 comments

Traceback (most recent call last): Traceback (most recent call last): File "C:\Ai-toolkit\ai-toolkit\run.py", line 120, in File "C:\Ai-toolkit\ai-toolkit\run.py", line 120, in main()main() File "C:\Ai-toolkit\ai-toolkit\run.py", line 108, in main File "C:\Ai-toolkit\ai-toolkit\run.py", line 108, in main raise eraise e File "C:\Ai-toolkit\ai-toolkit\run.py", line 96, in main File "C:\Ai-toolkit\ai-toolkit\run.py", line 96, in main job.run()job.run() File "C:\Ai-toolkit\ai-toolkit\jobs\ExtensionJob.py", line 22, in run File "C:\Ai-toolkit\ai-toolkit\jobs\ExtensionJob.py", line 22, in run process.run()process.run() File "C:\Ai-toolkit\ai-toolkit\jobs\process\BaseSDTrainProcess.py", line 2174, in run File "C:\Ai-toolkit\ai-toolkit\jobs\process\BaseSDTrainProcess.py", line 2174, in run loss_dict = self.hook_train_loop(batch_list)loss_dict = self.hook_train_loop(batch_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\sd_trainer\SDTrainer.py", line 2060, in hook_train_loop File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\sd_trainer\SDTrainer.py", line 2060, in hook_train_loop loss = self.train_single_accumulation(batch)loss = self.train_single_accumulation(batch) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\sd_trainer\SDTrainer.py", line 1927, in train_single_accumulation File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\sd_trainer\SDTrainer.py", line 1927, in train_single_accumulation loss = self.get_guided_loss(loss = self.get_guided_loss( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\concept_slider\ConceptSliderTrainer.py", line 157, in get_guided_loss File "C:\Ai-toolkit\ai-toolkit\extensions_built_in\concept_slider\ConceptSliderTrainer.py", line 157, in get_guided_loss combo_pred = self.sd.predict_noise(combo_pred = self.sd.predict_noise( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Ai-toolkit\ai-toolkit\toolkit\models\base_model.py", line 822, in predict_noise File "C:\Ai-toolkit\ai-toolkit\toolkit\models\base_model.py", line 822, in predict_noise raise ValueError(raise ValueError( ValueErrorValueError: : Batch size of latents must be the same or half the batch size of text embeddingsBatch size of latents must be the same or half the batch size of text embeddings killer �ز���С������v1.0-Z image-Base: 0%| | 0/1000 [00:00<?, ?it/s]

lixida123 avatar Jan 28 '26 07:01 lixida123

Where is the base model visible? I only have the Turbo and De:Distilled model ?

hanswurst232 avatar Jan 28 '26 09:01 hanswurst232

Where is the base model visible? I only have the Turbo and De:Distilled model ?

git pull

Image

InB4DevOps avatar Jan 28 '26 09:01 InB4DevOps

I also got this problem trying to train a Z-image base LoRA, using batch 4 I tried to tick/untick Cache Text embeddings, tick/untick Unload TE, to no avail

Gave up and started with batch 1 again

Tablaski avatar Jan 28 '26 14:01 Tablaski

I also got this problem trying to train a Z-image base LoRA, using batch 4 I tried to tick/untick Cache Text embeddings, tick/untick Unload TE, to no avail

Gave up and started with batch 1 again

have you tried Gradient Accumulation? i'm currently experimenting with GA8 & Batch Size 1 (only 12GB VRAM here)

InB4DevOps avatar Jan 28 '26 15:01 InB4DevOps

https://github.com/ostris/ai-toolkit/pull/673

Armychimp avatar Jan 28 '26 20:01 Armychimp

#673

Thank you. I have solved this problem and started the training.

lixida123 avatar Jan 29 '26 06:01 lixida123

我在训练到500步左右 客户端会蹦是为什么,问AI说是因为采样的时候要重新调用vae蹦显存了,我是24g,训练的时候实际占用16g,训练klein都没有因为采样崩过,有大佬碰到同样的情况嘛,有没有解决方法

ouyang3333 avatar Jan 29 '26 08:01 ouyang3333

This should be solved in the latest version

jaretburkett avatar Mar 28 '26 19:03 jaretburkett