Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(experimental) Allow EMA on LoRA/Lycoris networks #1170

Merged
merged 13 commits into from
Nov 19, 2024
Merged

Conversation

bghira
Copy link
Owner

@bghira bghira commented Nov 17, 2024

  • Refactor EMAModel to handle LoRA/Lycoris type networks instead of full model
  • Quantise the EMAModel at startup when the trained model is as well
  • Load state dictionary in a way that is compatible with quantised EMA model
  • Save state dictionary in a way that is compatible with quantised EMA model
  • EMA validations overhaul
    • lycoris support
    • peft standard LoRA
      • determine a reliable method for temporarily replacing LoRA with EMA for inference
    • full model checkpoint training
    • optional side-by-side validations
    • optional EMA-only validations
  • Model card details for EMA
  • Save/load as safetensors file instead of pytorch raw export
  • Ability to export EMA model at the end of training
  • Export EMA model in a way that is compatible with typical adapter loading methods
    • Full model export
    • Standard PEFT LoRA export / loading
    • Lycoris library export / loading

@bghira bghira force-pushed the feature/ema-for-lora branch from fd4de68 to 0fba5f6 Compare November 17, 2024 18:41
@bghira
Copy link
Owner Author

bghira commented Nov 18, 2024

extended model benchmarking to include EMA vs Checkpoint.

to demonstrate the concept this is LR 8e-3 over a single step where EMA updates every step.

image

every 100th step EMA updating at the same LR for just a single step (so EMA = base model)

image

…toring the lycoris weights during ema enable/disable
@bghira
Copy link
Owner Author

bghira commented Nov 18, 2024

currently PEFT Standard LoRA has EMA validations forcibly disabled during startup.

the validation class doesn't correctly load/unload the EMA weights from the model. more development is required for that.

though now, Lycoris + EMA is working really nicely.

@bghira bghira merged commit a85c6be into main Nov 19, 2024
1 check passed
@bghira bghira deleted the feature/ema-for-lora branch November 19, 2024 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant