Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/transformers/models/mamba2/modeling_mamba2.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,8 @@ def prepare_inputs_for_generation(
attention_mask: Optional[torch.Tensor] = None,
**kwargs,
):
if input_ids.shape[1] == 0:
past_len = inputs_embeds.shape[1]
if inputs_embeds is not None:
past_len = inputs_embeds.shape[1] + input_ids.shape[1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no longer the past length, but the current length 😉 Otherwise as this is used to create the cache positions, this is valid 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough :p

else:
past_len = input_ids.shape[1]
if use_cache:
Expand Down