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
9 changes: 9 additions & 0 deletions tests/models/t5gemma/test_modeling_t5gemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ def prepare_config_and_inputs(self):
input_ids = torch.where(input_ids == self.bos_token_id, 42, input_ids)
decoder_input_ids = torch.where(decoder_input_ids == self.bos_token_id, 42, decoder_input_ids)

# Avoid leading PAD tokens from inputs.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we probably better to force this for all model tester classes

# `T5GemmaForTokenClassification` and `T5GemmaForSequenceClassification` specify `use_cache=False` when
# calling `self.model`. For `self.use_attention_mask=False` case below, the model goes through
# `make_default_2d_attention_mask`. When there are some pad tokens at the beginning of a sequence, it can't
# attend to any place, and the computed mask `[-3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38]`
# causes larger differences in some equivalence tests.
# Let's avoid such leading PAD tokens.
decoder_input_ids[:, 0] = self.pad_token_id + 1

attention_mask = None
decoder_attention_mask = None
if self.use_attention_mask:
Expand Down