Skip to content

Commit

Permalink
Fix recompiles if limit_hpu_graph is False (huggingface#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssarkar2 committed Jul 11, 2024
1 parent 6f4ddf0 commit b6d2f3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions optimum/habana/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1878,9 +1878,10 @@ def _greedy_search(
and not model_kwargs.get("reuse_cache", False)
and bucket_internal
):
# Pad the returned pask key values tensors from prefill phase forward run to maximum length
# Pad the returned past key values tensors from prefill phase forward run to maximum length
# before starting the decode phase.
self._pad_past_key_values(model_kwargs)
if outputs.past_key_values[0][0].shape[2] == model_inputs["input_ids"].shape[1]:
self._pad_past_key_values(model_kwargs)
model_kwargs["pad_done"] = True

if (
Expand Down Expand Up @@ -2297,9 +2298,10 @@ def _sample(
and not model_kwargs.get("reuse_cache", False)
and bucket_internal
):
# Pad the returned pask key values tensors from prefill phase forward run to maximum length
# Pad the returned past key values tensors from prefill phase forward run to maximum length
# before starting the decode phase.
self._pad_past_key_values(model_kwargs)
if outputs.past_key_values[0][0].shape[2] == model_inputs["input_ids"].shape[1]:
self._pad_past_key_values(model_kwargs)
model_kwargs["pad_done"] = True

if (
Expand Down

0 comments on commit b6d2f3d

Please sign in to comment.