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

Remove core conversion models #5981

Merged
merged 4 commits into from
Mar 18, 2024

Conversation

lstein
Copy link
Collaborator

@lstein lstein commented Mar 17, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Have you discussed this change with the InvokeAI team?

  • Yes
  • No, because:

Have you updated all relevant documentation?

  • Yes
  • No

Description

We've been using a forked copy of the diffusers safetensors->diffusers model conversion code, which was hacked to read CLIP and the other models needed for conversion from the local invokeai root models directory. This was getting unsustainable as the code bases diverged, and also required the installation and maintenance of the "core/convert" directory.

This PR gets rid of the hacked conversion code and reverts to using the native diffusers methods. Core convert models are no longer installed at root configure time. Instead we rely on the HuggingFace hub system to download the conversion models if and when they are needed. They are relatively small and the initial delay seems minor.

Conversion of SD-1, SD-2 (both epsilon and v-prediction), SDXL, VAE and ControlNet SD-1/2 models has been tested. ControlNet SDXL models are still a WIP due to the need for some work on the prober.

The main implication of this change is that InvokeAI is no longer internet-independent and will need an internet connection at least the first time a safetensors file needs to be converted. However, there are several other places where the "no internet" rule is already violated, and I suggest that we abandon this principle.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

  1. Remove or move $INVOKEAI_ROOT/models/.cache
  2. Move $INVOKEAI/models/core/convert
  3. Try generating with an unconverted .safetensors model.

Merge Plan

Merge when approved.

Added/updated tests?

  • Yes
  • No : please replace this line with details on why tests
    have not been included

[optional] Are there any post deployment tasks we need to perform?

Lincoln Stein added 3 commits March 17, 2024 09:58
- No longer install core conversion models. Use the HuggingFace cache to load
  them if and when needed.

- Call directly into the diffusers library to perform conversions with only shallow
   wrappers around them to massage arguments, etc.

- At root configuration time, do not create all the possible model subdirectories,
  but let them be created and populated at model install time.

- Remove checks for missing core conversion files, since they are no
  longer installed.
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files services PRs that change app services labels Mar 17, 2024
@hipsterusername
Copy link
Member

Makes sense to me

@psychedelicious psychedelicious merged commit a6d64f6 into main Mar 18, 2024
14 checks passed
@psychedelicious psychedelicious deleted the optimization/remove-core-conversion-models branch March 18, 2024 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend PRs that change backend files python PRs that change python files services PRs that change app services
Projects
None yet
3 participants