Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPT-J fix #359

Merged
merged 4 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions modeling/inference_models/hf_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,13 @@ def _get_model(self, location: str, tf_kwargs: Dict):
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:
Expand Down Expand Up @@ -462,19 +465,25 @@ def lazy_load_callback(
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
):
Expand Down
2 changes: 1 addition & 1 deletion static/koboldai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down