Rework DFEs to work better with x0 models. Show their loss in the graph

This commit is contained in:
Jaret Burkett committed 2026-09-07 13:26:01 -06:00
1 parent 7690ea62c8
commit 3e1cb5f67f
2 files changed
+56 -28

No files matched your search

+4 -2
View File
@@ -403,11 +403,11 @@ class SDTrainer(BaseSDTrainProcess):
sd=self.sd
)
self.dfe.to(self.device_torch)
if hasattr(self.dfe, 'vision_encoder') and self.train_config.gradient_checkpointing:
if hasattr(self.dfe, 'vision_encoder'):
# must be set to train for gradient checkpointing to work
self.dfe.vision_encoder.train()
self.dfe.vision_encoder.gradient_checkpointing = True
elif hasattr(self.dfe, 'model') and self.train_config.gradient_checkpointing:
elif hasattr(self.dfe, 'model'):
if hasattr(self.dfe.model, 'enable_gradient_checkpointing'):
self.dfe.model.train()
self.dfe.model.enable_gradient_checkpointing()
@@ -750,6 +750,8 @@ class SDTrainer(BaseSDTrainProcess):
batch=batch,
scheduler=self.sd.noise_scheduler
)
dfe_loss = dfe_loss.mean()
self.additional_logs['loss/dfe'] = dfe_loss.item()
additional_loss += dfe_loss * self.train_config.diffusion_feature_extractor_weight
else:
raise ValueError(f"Unknown diffusion feature extractor version {self.dfe.version}")