Skip to content

KeyError: 'text_encoder_1_hidden_state' during training in BaseStableDiffusionXLSetup.predict #1651

Description

@hypocalcemia

What happened?

KeyError: 'text_encoder_1_hidden_state' during training in BaseStableDiffusionXLSetup.predict

Occurs after running for a few epochs.

Running on windows + installed with the provided installer in the repo.

Full traceback:

Traceback (most recent call last):
    File "D:\OneTrainer\modules\ui\TrainUIController.py", line 254, in __training_thread_function_impl
      trainer.train()
    File "D:\OneTrainer\modules\trainer\GenericTrainer.py", line 751, in train
      model_output_data = self.model_setup.predict(self.model, batch, self.config, train_progress)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\OneTrainer\modules\modelSetup\BaseStableDiffusionXLSetup.py", line 204, in predict
      text_encoder_1_output=batch[
                            ^^^^^^
  KeyError: 'text_encoder_1_hidden_state'
  Creating Backup workspace/run\backup\2026-07-26_19-20-14-backup-130-9-4
  Saving models/test.safetensors

What did you expect would happen?

Training would continue then finish.

Relevant log output

Traceback (most recent call last):
    File "D:\OneTrainer\modules\ui\TrainUIController.py", line 254, in __training_thread_function_impl
      trainer.train()
    File "D:\OneTrainer\modules\trainer\GenericTrainer.py", line 751, in train
      model_output_data = self.model_setup.predict(self.model, batch, self.config, train_progress)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\OneTrainer\modules\modelSetup\BaseStableDiffusionXLSetup.py", line 204, in predict
      text_encoder_1_output=batch[
                            ^^^^^^
  KeyError: 'text_encoder_1_hidden_state'
  Creating Backup workspace/run\backup\2026-07-26_19-20-14-backup-130-9-4
  Saving models/test.safetensors

Generate and upload debug_report.log

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfollowupFailure to provide config or other info or needs followup

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions