Automated PR - 2026-01-12

This commit is contained in:
sync-bot
2026-01-12 14:14:33 +00:00
parent 628956009c
commit e5a15a4777
14 changed files with 66 additions and 31 deletions
@@ -253,6 +253,10 @@ checkpoints:
# Set to -1 to keep all checkpoints
keep_last_n: -1
# Precision to use when saving checkpoint weights
# Options: "bfloat16" (default, smaller files) or "float32" (full precision)
precision: "bfloat16"
# -----------------------------------------------------------------------------
# Flow Matching Configuration
# -----------------------------------------------------------------------------
@@ -263,6 +263,10 @@ checkpoints:
# Set to -1 to keep all checkpoints
keep_last_n: 3
# Precision to use when saving checkpoint weights
# Options: "bfloat16" (default, smaller files) or "float32" (full precision)
precision: "bfloat16"
# -----------------------------------------------------------------------------
# Flow Matching Configuration
# -----------------------------------------------------------------------------
@@ -292,8 +292,9 @@ Model checkpointing configuration.
```yaml
checkpoints:
interval: 250 # Steps between checkpoint saves (null = disabled)
keep_last_n: 3 # Number of recent checkpoints to retain
interval: 250 # Steps between checkpoint saves (null = disabled)
keep_last_n: 3 # Number of recent checkpoints to retain
precision: bfloat16 # Precision for saved weights (bfloat16 or float32)
```
**Key parameters:**
@@ -302,6 +303,7 @@ checkpoints:
|---------------|------------------------------------------------------------------------|
| `interval` | Steps between intermediate checkpoint saves (set to `null` to disable) |
| `keep_last_n` | Number of most recent checkpoints to keep (-1 = keep all) |
| `precision` | Precision for saved checkpoint weights: `"bfloat16"` (default) or `"float32"` |
### HubConfig
@@ -350,6 +350,11 @@ class CheckpointsConfig(ConfigBaseModel):
ge=-1,
)
precision: Literal["bfloat16", "float32"] = Field(
default="bfloat16",
description="Precision to use when saving checkpoint weights. Options: 'bfloat16' or 'float32'.",
)
class HubConfig(ConfigBaseModel):
"""Configuration for Hugging Face Hub integration"""
@@ -873,6 +873,9 @@ class LtxvTrainer:
save_dir.mkdir(exist_ok=True, parents=True)
# Determine save precision
save_dtype = torch.bfloat16 if self._config.checkpoints.precision == "bfloat16" else torch.float32
# For LoRA: extract only adapter weights; for full: use as-is
if is_lora:
unwrapped = self._accelerator.unwrap_model(self._transformer, keep_torch_compile=False)
@@ -885,9 +888,15 @@ class LtxvTrainer:
# Convert to ComfyUI-compatible format (add "diffusion_model." prefix)
state_dict = {f"diffusion_model.{k}": v for k, v in state_dict.items()}
# Cast to configured precision
state_dict = {k: v.to(save_dtype) if isinstance(v, Tensor) else v for k, v in state_dict.items()}
# Save to disk
save_file(state_dict, saved_weights_path)
else:
# Cast to configured precision
full_state_dict = {k: v.to(save_dtype) if isinstance(v, Tensor) else v for k, v in full_state_dict.items()}
# Save to disk
self._accelerator.save(full_state_dict, saved_weights_path)