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

Work around missing core conversion model issue #5947

Merged
merged 1 commit into from Mar 14, 2024

Conversation

lstein
Copy link
Collaborator

@lstein lstein commented Mar 13, 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

This adds additional logic to the safetensors->diffusers conversion script to check for and install missing core conversion models at runtime.

I am not convinced that this fixes the underlying issue. There is already a check for missing core conversion models when the app starts up and unless the user ran with --ignore_missing_core_models we should never reach a state where the conversion script cannot find its models!

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Merge Plan

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?

@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Mar 13, 2024
@psychedelicious
Copy link
Collaborator

I'm suspicious about all the reports being about the same clip-vit-large-patch14 model. Would we expect more errors about other core models?

- This adds additional logic to the safetensors->diffusers conversion script
  to check for and install missing core conversion models at runtime.

- Fixes #5934
@psychedelicious psychedelicious force-pushed the bugfix/install-missing-core-models branch from 19a06aa to ff6eede Compare March 14, 2024 05:18
@psychedelicious psychedelicious enabled auto-merge (rebase) March 14, 2024 05:18
@psychedelicious psychedelicious merged commit 1bd8e33 into main Mar 14, 2024
14 checks passed
@psychedelicious psychedelicious deleted the bugfix/install-missing-core-models branch March 14, 2024 05:52
psychedelicious added a commit that referenced this pull request Mar 15, 2024
…s a helper function `install_dependencies` to check if the core conversion models are present, whenever we need to convert a model.

The configure script installs these conversion models:

- `openai/clip-vit-large-patch14`: SD1.x CLIPTokenizer & CLIPTextModel
- `stabilityai/stable-diffusion-2`: SD2.x CLIPTokenizer & CLIPTextModel
- `CLIP-ViT-bigG-14-laion2B-39B-b160k`: SDXL CLIPTokenizer & CLIPTextConfig (tokenizer 2)

The helper function checks for those and one additional model `CLIP-ViT-H-14-laion2B-s32B-b79K`: <https://github.com/invoke-ai/InvokeAI/blob/ff6eede710a0684e6c8d987ac57c9e9277862287/invokeai/backend/model_manager/convert_ckpt_to_diffusers.py#L85>

`CLIP-ViT-H-14-laion2B-s32B-b79K` appears to be installed only at runtime, but the codepath appears to be unreachable: `download_from_original_stable_diffusion_ckpt` must be called with `stable_unclip == "img2img"`, which never happens. I don't think we actually need this model installed.

This means the helper always fails and thinks a conversion model is missing, leading to the message. Even though no models are missing, we hit the HF API to attempt to install the models, which causes a brief pause.

This change resolves the issue:

- Use the list of models from the configurator (i.e. everything except `CLIP-ViT-H-14-laion2B-s32B-b79K`)
- Extract core models check logic from the `check_root` util into a function and use it in `install_dependencies`

Note: This makes the `install_dependencies` check redundant. I don't think the fix in <#5947> is addresses the issue.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants