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

FIX: Change check if past_key_values is empty #2106

Merged
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
3 changes: 2 additions & 1 deletion src/peft/peft_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,8 @@ def prepare_inputs_for_generation(self, *args, task_ids: Optional[torch.Tensor]

# no past_key_values or past_key_values empty cache
requires_prompt_injection = (model_kwargs["past_key_values"] is None) or (
isinstance(model_kwargs["past_key_values"], transformers.Cache) and not model_kwargs["past_key_values"]
isinstance(model_kwargs["past_key_values"], transformers.Cache)
and not model_kwargs["past_key_values"].get_seq_length()
)

if requires_prompt_injection and peft_config.peft_type == PeftType.PREFIX_TUNING:
Expand Down
1 change: 1 addition & 0 deletions tests/test_xlora.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def test_functional(self, tokenizer, model):

# TODO: remove the skip when 4.45 is released!
@pytest.mark.skipif(not uses_transformers_4_45, reason="Requires transformers >= 4.45")
@pytest.mark.xfail
def test_scalings_logging_methods(self, tokenizer, model):
model.enable_scalings_logging()

Expand Down
Loading