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 accelerate tests for roberta xl #31288

Merged
merged 2 commits into from
Jun 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class XLMRobertaXLPreTrainedModel(PreTrainedModel):

config_class = XLMRobertaXLConfig
base_model_prefix = "roberta"
_no_split_modules = ["XLMRobertaXLEmbeddings", "XLMRobertaXLSelfAttention"]
_no_split_modules = ["XLMRobertaXLEmbeddings", "XLMRobertaXLLayer"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

if you can leave a comment (in the PR page is ok) why this fix the issue, that would be very nice as knowledge sharing ❤️ .

Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because there are a lot of residual connections at the level of the layer. So we need to make sure that all the ops that are happening inside of the layer stay on the same device. Otherwise, we would have to do manually move the tensors(.to(device) and this is not good. If you check other _no_split_modules with transformers architecture (llama, mistral ...), you will see that most of them have the layer class inside of it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot!


# Copied from transformers.models.bert.modeling_bert.BertPreTrainedModel._init_weights
def _init_weights(self, module):
Expand Down
2 changes: 2 additions & 0 deletions tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ class XLMRobertaXLModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTes
else {}
)

model_split_percents = [0.5, 0.85, 0.95]

# TODO: Fix the failed tests
def is_pipeline_test_to_skip(
self, pipeline_test_casse_name, config_class, model_architecture, tokenizer_name, processor_name
Expand Down
Loading