From 546ba84723c84dec3a6f8cc70e41408fd66efa67 Mon Sep 17 00:00:00 2001 From: somebody Date: Wed, 10 May 2023 19:10:23 -0500 Subject: [PATCH 1/3] Fix memory->genre bug in context viewer bar tooltip Crazy change I know --- static/koboldai.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/koboldai.js b/static/koboldai.js index cfc32d21..87beb954 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -4006,7 +4006,7 @@ function update_context(data) { document.getElementById('world_info_'+entry.uid).classList.add("used_in_game"); } break; - case 'memory': + case 'genre': genre_length += entry.tokens.length; break; case 'memory': From c16336f6467fe11a8644b551d5700986d2ef4bf6 Mon Sep 17 00:00:00 2001 From: somebody Date: Thu, 11 May 2023 17:10:19 -0500 Subject: [PATCH 2/3] Add traceback to debug log on fallback --- modeling/inference_models/hf_torch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modeling/inference_models/hf_torch.py b/modeling/inference_models/hf_torch.py index 990fabfc..14ddd7af 100644 --- a/modeling/inference_models/hf_torch.py +++ b/modeling/inference_models/hf_torch.py @@ -332,10 +332,13 @@ class HFTorchInferenceModel(HFInferenceModel): raise logger.warning(f"Fell back to GPT2LMHeadModel due to {e}") + logger.debug(traceback.format_exc()) + try: return GPT2LMHeadModel.from_pretrained(location, **tf_kwargs) except Exception as e: logger.warning(f"Fell back to GPTNeoForCausalLM due to {e}") + logger.debug(traceback.format_exc()) return GPTNeoForCausalLM.from_pretrained(location, **tf_kwargs) def get_hidden_size(self) -> int: From 3065c1b40e758993565ea212ccf9f3b0db5c7f0e Mon Sep 17 00:00:00 2001 From: somebody Date: Thu, 11 May 2023 17:10:43 -0500 Subject: [PATCH 3/3] Ignore missing keys in get_original_key --- modeling/inference_models/hf_torch.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modeling/inference_models/hf_torch.py b/modeling/inference_models/hf_torch.py index 14ddd7af..3f7c3967 100644 --- a/modeling/inference_models/hf_torch.py +++ b/modeling/inference_models/hf_torch.py @@ -465,19 +465,25 @@ class HFTorchInferenceModel(HFInferenceModel): device_map: Dict[str, Union[str, int]] = {} @functools.lru_cache(maxsize=None) - def get_original_key(key): - return max( - ( - original_key - for original_key in utils.module_names - if original_key.endswith(key) - ), - key=len, - ) + def get_original_key(key) -> Optional[str]: + key_candidates = [ + original_key + for original_key in utils.module_names + if original_key.endswith(key) + ] + + 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(): original_key = get_original_key(key) + if not original_key: + continue + if isinstance(value, lazy_loader.LazyTensor) and not any( original_key.startswith(n) for n in utils.layers_module_names ):