fix(mm): handle integer state dict keys in probe #6051
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anAttributeError
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 ofAttributeError
.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