Skip to content
Open
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
6 changes: 3 additions & 3 deletions modeling/inference_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __enter__(self):
)

if use_core_manipulations.sample:
use_core_manipulations.old_sample = transformers.GenerationMixin.sample
transformers.GenerationMixin.sample = use_core_manipulations.sample
use_core_manipulations.old_sample = transformers.GenerationMixin._sample
transformers.GenerationMixin._sample = use_core_manipulations.sample

if use_core_manipulations.get_stopping_criteria:
use_core_manipulations.old_get_stopping_criteria = (
Expand All @@ -69,7 +69,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
), "Patch leak: THE MONKEYS HAVE ESCAPED"

if use_core_manipulations.old_sample:
transformers.GenerationMixin.sample = use_core_manipulations.old_sample
transformers.GenerationMixin._sample = use_core_manipulations.old_sample
else:
assert (
not use_core_manipulations.sample
Expand Down
2 changes: 1 addition & 1 deletion modeling/inference_models/hf_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def new_sample(self, *args, **kwargs):
kwargs.setdefault("pad_token_id", 2)
return new_sample.old_sample(self, *args, **kwargs)

new_sample.old_sample = transformers.GenerationMixin.sample
new_sample.old_sample = transformers.GenerationMixin._sample
use_core_manipulations.sample = new_sample

# PEFT Loading. This MUST be done after all save_pretrained calls are
Expand Down