MCPcopy Create free account
hub / github.com/huggingface/diffusers / _find_mismatched_keys

Function _find_mismatched_keys

src/diffusers/models/model_loading_utils.py:452–471  ·  view source on GitHub ↗
(
    state_dict,
    model_state_dict,
    loaded_keys,
    ignore_mismatched_sizes,
)

Source from the content-addressed store, hash-verified

450
451
452def _find_mismatched_keys(
453 state_dict,
454 model_state_dict,
455 loaded_keys,
456 ignore_mismatched_sizes,
457):
458 mismatched_keys = []
459 if ignore_mismatched_sizes:
460 for checkpoint_key in loaded_keys:
461 model_key = checkpoint_key
462 # If the checkpoint is sharded, we may not have the key here.
463 if checkpoint_key not in state_dict:
464 continue
465
466 if model_key in model_state_dict and state_dict[checkpoint_key].shape != model_state_dict[model_key].shape:
467 mismatched_keys.append(
468 (checkpoint_key, state_dict[checkpoint_key].shape, model_state_dict[model_key].shape)
469 )
470 del state_dict[checkpoint_key]
471 return mismatched_keys
472
473
474def _load_state_dict_into_model(

Callers 1

_load_shard_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…