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

Conversation

SunMarc
Copy link
Member

@SunMarc SunMarc commented Jun 6, 2024

What does this do ?

This PR fixes the no_split_modules for roberta xl model introduced in this PR #31223. Also, we need to change model_split_percents, so that we made sure to have enough space on the first gpu for the embeddings. The tests are passing:

tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py::XLMRobertaXLModelTest::test_cpu_offload If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
[2024-06-06 14:56:19,427] [INFO] [real_accelerator.py:191:get_accelerator] Setting ds_accelerator to cuda (auto detect)
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
PASSED
tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py::XLMRobertaXLModelTest::test_disk_offload_bin If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
PASSED
tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py::XLMRobertaXLModelTest::test_disk_offload_safetensors If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
PASSED
tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py::XLMRobertaXLModelTest::test_model_parallelism If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
If you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`
PASSED

cc @ydshieh since you pinged me on this one

@SunMarc SunMarc requested a review from ydshieh June 6, 2024 13:04
@SunMarc SunMarc requested a review from amyeroberts June 6, 2024 13:06
@@ -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!

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

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

Thank you for fixing it so quickly!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@amyeroberts amyeroberts merged commit 99895ae into main Jun 6, 2024
23 checks passed
@amyeroberts amyeroberts deleted the fix-roberta-xl-device-map branch June 6, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants