mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Ignore missing keys in get_original_key
This commit is contained in:
@@ -465,19 +465,25 @@ class HFTorchInferenceModel(HFInferenceModel):
|
|||||||
device_map: Dict[str, Union[str, int]] = {}
|
device_map: Dict[str, Union[str, int]] = {}
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=None)
|
@functools.lru_cache(maxsize=None)
|
||||||
def get_original_key(key):
|
def get_original_key(key) -> Optional[str]:
|
||||||
return max(
|
key_candidates = [
|
||||||
(
|
original_key
|
||||||
original_key
|
for original_key in utils.module_names
|
||||||
for original_key in utils.module_names
|
if original_key.endswith(key)
|
||||||
if original_key.endswith(key)
|
]
|
||||||
),
|
|
||||||
key=len,
|
if not key_candidates:
|
||||||
)
|
logger.debug(f"!!! No key candidates for {key}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
return max(key_candidates, key=len)
|
||||||
|
|
||||||
for key, value in model_dict.items():
|
for key, value in model_dict.items():
|
||||||
original_key = get_original_key(key)
|
original_key = get_original_key(key)
|
||||||
|
|
||||||
|
if not original_key:
|
||||||
|
continue
|
||||||
|
|
||||||
if isinstance(value, lazy_loader.LazyTensor) and not any(
|
if isinstance(value, lazy_loader.LazyTensor) and not any(
|
||||||
original_key.startswith(n) for n in utils.layers_module_names
|
original_key.startswith(n) for n in utils.layers_module_names
|
||||||
):
|
):
|
||||||
|
Reference in New Issue
Block a user