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

fix(mm): handle integer state dict keys in probe #6051

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

psychedelicious
Copy link
Collaborator

Summary

It's possible for a model's state dict to have integer keys, though we do not actually support such models.

As part of probing, we call key.startswith(...) on the state dict keys. This raises an AttributeError for integer keys.

This logic is in invokeai/backend/model_manager/probe.py:get_model_type_from_checkpoint

To fix this, we can cast the keys to strings first. The models w/ integer keys will still fail to be probed, but we'll get a InvalidModelConfigException instead of AttributeError.

Related Issues / Discussions

Closes #6044

QA Instructions

I'd like to get approval from @ljleb that this fixes the problem, but no worries if that's a bit too much work. I'm fairly confident that this change plus #6048 will resolve #6044 satisfactorily.

Merge Plan

N/A

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable) N/A

@ljleb
Copy link

ljleb commented Mar 26, 2024

I'd like to get approval from @ljleb that this fixes the problem, but no worries if that's a bit too much work. I'm fairly confident that this change plus #6048 will resolve #6044 satisfactorily.

I don't have yet a developer install. after a quick glance over the related section of the docs, if it is useful for me to do so, I think I can try to look into it tomorrow if I don't run into unexpected issues setting that up.

Don't hesitate to move forward with this if I take too long or my approval isn't necessary, there are too many things I am trying to do at the same time...

@hipsterusername hipsterusername force-pushed the psyche/fix/mm/cast_state_dict_keys_to_str branch from a6881ec to 7cb0b35 Compare March 26, 2024 21:41
@psychedelicious psychedelicious enabled auto-merge (rebase) March 26, 2024 22:22
It's possible for a model's state dict to have integer keys, though we do not actually support such models.

As part of probing, we call `key.startswith(...)` on the state dict keys. This raises an `AttributeError` for integer keys.

This logic is in `invokeai/backend/model_manager/probe.py:get_model_type_from_checkpoint`

To fix this, we can cast the keys to strings first. The models w/ integer keys will still fail to be probed, but we'll get a `InvalidModelConfigException` instead of `AttributeError`.

Closes #6044
@psychedelicious psychedelicious force-pushed the psyche/fix/mm/cast_state_dict_keys_to_str branch from 7cb0b35 to 9dd28fc Compare March 26, 2024 22:22
@psychedelicious psychedelicious merged commit 778922e into main Mar 26, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/fix/mm/cast_state_dict_keys_to_str branch March 26, 2024 22:30
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 python-tests PRs that change python tests
Projects
None yet
3 participants