Upload folder using huggingface_hub
Browse files
scripts/training/run_train_flux_deepspeed.sh
CHANGED
|
@@ -33,8 +33,8 @@ accelerate launch \
|
|
| 33 |
"$PROJECT_DIR/scripts/training/train_flux_deepspeed.py" \
|
| 34 |
--embedding-dir "$EMBEDDING_DIR" \
|
| 35 |
--output-dir "/data0/checkpoints/flux_lora_ds" \
|
| 36 |
-
--batch-size
|
| 37 |
-
--gradient-accumulation
|
| 38 |
--learning-rate 1e-4 \
|
| 39 |
--lr-warmup-steps 500 \
|
| 40 |
--max-train-steps 100000 \
|
|
|
|
| 33 |
"$PROJECT_DIR/scripts/training/train_flux_deepspeed.py" \
|
| 34 |
--embedding-dir "$EMBEDDING_DIR" \
|
| 35 |
--output-dir "/data0/checkpoints/flux_lora_ds" \
|
| 36 |
+
--batch-size 1 \
|
| 37 |
+
--gradient-accumulation 8 \
|
| 38 |
--learning-rate 1e-4 \
|
| 39 |
--lr-warmup-steps 500 \
|
| 40 |
--max-train-steps 100000 \
|
scripts/training/train_flux_deepspeed.py
CHANGED
|
@@ -105,8 +105,8 @@ def main():
|
|
| 105 |
cache_dir=args.cache_dir,
|
| 106 |
)
|
| 107 |
|
| 108 |
-
#
|
| 109 |
-
|
| 110 |
|
| 111 |
lora_config = LoraConfig(
|
| 112 |
r=args.lora_rank,
|
|
@@ -116,6 +116,11 @@ def main():
|
|
| 116 |
)
|
| 117 |
transformer = get_peft_model(transformer, lora_config)
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
if accelerator.is_main_process:
|
| 120 |
transformer.print_trainable_parameters()
|
| 121 |
|
|
@@ -199,7 +204,7 @@ def main():
|
|
| 199 |
|
| 200 |
# Target: velocity (noise - signal)
|
| 201 |
target = noise - packed_latents
|
| 202 |
-
loss = F.mse_loss(model_pred, target)
|
| 203 |
|
| 204 |
accelerator.backward(loss)
|
| 205 |
|
|
|
|
| 105 |
cache_dir=args.cache_dir,
|
| 106 |
)
|
| 107 |
|
| 108 |
+
# Gradient checkpointing disabled: incompatible with PEFT LoRA on PyTorch 2.12
|
| 109 |
+
# (causes illegal memory access during backward). Batch 1 fits in 96GB without it.
|
| 110 |
|
| 111 |
lora_config = LoraConfig(
|
| 112 |
r=args.lora_rank,
|
|
|
|
| 116 |
)
|
| 117 |
transformer = get_peft_model(transformer, lora_config)
|
| 118 |
|
| 119 |
+
# Cast LoRA params to fp32 to avoid NaN gradients in bf16 backprop
|
| 120 |
+
for name, p in transformer.named_parameters():
|
| 121 |
+
if p.requires_grad:
|
| 122 |
+
p.data = p.data.float()
|
| 123 |
+
|
| 124 |
if accelerator.is_main_process:
|
| 125 |
transformer.print_trainable_parameters()
|
| 126 |
|
|
|
|
| 204 |
|
| 205 |
# Target: velocity (noise - signal)
|
| 206 |
target = noise - packed_latents
|
| 207 |
+
loss = F.mse_loss(model_pred.float(), target.float())
|
| 208 |
|
| 209 |
accelerator.backward(loss)
|
| 210 |
|