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

Model merging utility scripts #138

Merged
merged 33 commits into from
Jun 4, 2024
Merged

Model merging utility scripts #138

merged 33 commits into from
Jun 4, 2024

Conversation

RyanJDick
Copy link
Collaborator

@RyanJDick RyanJDick commented May 31, 2024

This PR adds some new model merging utility scripts (LERP, SLERP, TIES, DARE), and improves the existing LoRA merge scripts.

The current list of model merging scripts is:

  • extract_lora_from_model_diff.py: Extract a LoRA model that represents the difference between two base models.
  • merge_lora_into_model.py: Merge a LoRA model into a base model to produce a new base model.
  • merge_models.py: Merge 2 or more base models to produce a single base model (using either LERP or SLERP).
  • merge_task_models_to_base_model.py: Merge 1 or more task-specific base models into a single starting base model (using either TIES or DARE). This merge strategy aims to preserve the task-specific behaviors of the task models while making only small changes to the original base model.

Left for future work:

  • Auto-detect SD vs. SDXL
  • Speed up merge_task_models_to_base_model.py by running on the GPU.
  • Add samples to the docs comparing the tradeoffs of the various merge approaches.
  • Add ability to use LoRA models as "task" models in merge_task_models_to_base_model.py.

…n result in drastically higher memory utilization (it seems like ther might be a bug in diffusers causing multiple copies of the weights to be held in memory).
… solve issue with dtype being changed during the calculation.
… diffusers and checkpoint files, and to support unet, te1, and te2 submodels.
@RyanJDick RyanJDick marked this pull request as ready for review June 4, 2024 12:49
@RyanJDick RyanJDick merged commit 0b44077 into main Jun 4, 2024
1 check passed
@RyanJDick RyanJDick deleted the model-merge branch June 4, 2024 12:55
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