MCPcopy Index your code
hub / github.com/huggingface/diffusers / _maybe_warn_for_unhandled_keys

Function _maybe_warn_for_unhandled_keys

src/diffusers/utils/peft_utils.py:401–425  ·  view source on GitHub ↗
(incompatible_keys, adapter_name)

Source from the content-addressed store, hash-verified

399
400
401def _maybe_warn_for_unhandled_keys(incompatible_keys, adapter_name):
402 warn_msg = ""
403 if incompatible_keys is not None:
404 # Check only for unexpected keys.
405 unexpected_keys = getattr(incompatible_keys, "unexpected_keys", None)
406 if unexpected_keys:
407 lora_unexpected_keys = [k for k in unexpected_keys if "lora_" in k and adapter_name in k]
408 if lora_unexpected_keys:
409 warn_msg = (
410 f"Loading adapter weights from state_dict led to unexpected keys found in the model:"
411 f" {', '.join(lora_unexpected_keys)}. "
412 )
413
414 # Filter missing keys specific to the current adapter.
415 missing_keys = getattr(incompatible_keys, "missing_keys", None)
416 if missing_keys:
417 lora_missing_keys = [k for k in missing_keys if "lora_" in k and adapter_name in k]
418 if lora_missing_keys:
419 warn_msg += (
420 f"Loading adapter weights from state_dict led to missing keys in the model:"
421 f" {', '.join(lora_missing_keys)}."
422 )
423
424 if warn_msg:
425 logger.warning(warn_msg)

Callers 1

load_lora_adapterMethod · 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…