Summary
train_leco.py and sdxl_train_leco.py's setup_parser() never register --sample_every_n_epochs / --sample_every_n_steps, but verify_training_args() in library/args.py unconditionally accesses args.sample_every_n_epochs and args.sample_every_n_steps:
if args.sample_every_n_epochs is not None and args.sample_every_n_epochs <= 0:
...
if args.sample_every_n_steps is not None and args.sample_every_n_steps <= 0:
...
Since these two scripts don't call whatever add_*_arguments() helper registers those sample-related flags, argparse.Namespace never gets a sample_every_n_epochs / sample_every_n_steps attribute, and this line raises AttributeError — before training starts.
Steps to reproduce
Run either script with a minimal valid LECO config:
accelerate launch train_leco.py \
--pretrained_model_name_or_path="model.safetensors" \
--prompts_file="prompts.toml" \
--output_dir="output" \
--output_name="test"
main() calls args_util.verify_training_args(args), which hits:
AttributeError: 'Namespace' object has no attribute 'sample_every_n_epochs'
(Same issue in sdxl_train_leco.py.)
Suggested fix
Either:
- Register
--sample_every_n_epochs and --sample_every_n_steps in LECO's setup_parser() with default=None (even if unused, so verify_training_args()'s generic checks don't fail), or
- Guard the two checks in
verify_training_args() with getattr(args, "sample_every_n_epochs", None) / getattr(args, "sample_every_n_steps", None) instead of direct attribute access, consistent with how getattr(args, "train_inpainting", False) is already handled a few lines above in the same function.
Option 2 is more robust against future scripts that similarly opt out of the sample-image machinery.
Context
Found while adding LECO GUI support in kohya_ss (bmaltais/kohya_ss#3539). Not a GUI-side bug — this is purely in the training script / arg verification, hence filing here rather than downstream.
Summary
train_leco.pyandsdxl_train_leco.py'ssetup_parser()never register--sample_every_n_epochs/--sample_every_n_steps, butverify_training_args()inlibrary/args.pyunconditionally accessesargs.sample_every_n_epochsandargs.sample_every_n_steps:Since these two scripts don't call whatever
add_*_arguments()helper registers those sample-related flags,argparse.Namespacenever gets asample_every_n_epochs/sample_every_n_stepsattribute, and this line raisesAttributeError— before training starts.Steps to reproduce
Run either script with a minimal valid LECO config:
main()callsargs_util.verify_training_args(args), which hits:(Same issue in
sdxl_train_leco.py.)Suggested fix
Either:
--sample_every_n_epochsand--sample_every_n_stepsin LECO'ssetup_parser()withdefault=None(even if unused, soverify_training_args()'s generic checks don't fail), orverify_training_args()withgetattr(args, "sample_every_n_epochs", None)/getattr(args, "sample_every_n_steps", None)instead of direct attribute access, consistent with howgetattr(args, "train_inpainting", False)is already handled a few lines above in the same function.Option 2 is more robust against future scripts that similarly opt out of the sample-image machinery.
Context
Found while adding LECO GUI support in kohya_ss (bmaltais/kohya_ss#3539). Not a GUI-side bug — this is purely in the training script / arg verification, hence filing here rather than downstream.