-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
set supports_gradient_checkpointing = False in SwitchTransformer #35249
base: main
Are you sure you want to change the base?
Conversation
Hi @nhamanasu Thank you for the PR. Although pytest-dev/pytest-subtests#169 is merged, we will still need to review the impact of installing and using In the meantime, #34806 should not be the cause of failing Change it to Could you check if |
Hi @ydshieh Thank you for your response! I got the situation (sorry for my misunderstanding). Related to SwitchTransformer, it currently has And also, SwitchTransformer has experts in MLP modules:
I think the last part should be the cause of non-gradient weights. So as you suggested, I think we need to set supports_gradient_checkpointing = False for this model. |
|
@@ -769,7 +769,7 @@ class SwitchTransformersPreTrainedModel(PreTrainedModel): | |||
|
|||
config_class = SwitchTransformersConfig | |||
base_model_prefix = "switch_transformers" | |||
supports_gradient_checkpointing = True | |||
supports_gradient_checkpointing = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simply remove this line as False
it the default value defined in
class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMixin, PeftAdapterMixin):
tests/test_modeling_common.py
Outdated
@@ -863,8 +863,7 @@ def check_training_gradient_checkpointing(self, gradient_checkpointing_kwargs=No | |||
] | |||
or not model_class.supports_gradient_checkpointing | |||
): | |||
# TODO (ydshieh): use `skipTest` once pytest-dev/pytest-subtests/pull/169 is merged | |||
# self.skipTest(reason=f"`supports_gradient_checkpointing` is False for {model_class.__name__}.") | |||
self.skipTest(reason=f"`supports_gradient_checkpointing` is False for {model_class.__name__}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert the change here :-)
Thanks. Just 2 nits and we are ready to go |
…nedModel since the default value is False
Thank you! I've reflected your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the iteration!
What does this PR do?
Recently, CircleCI's
tests_torch
sometimes fails (Reference: tests_torch - Failed), because some models which don't support gradient_checkpointing or have MoE module like SwitchTransformer will occasionally have weights without gradients.I found maybe-related PR: #34806, and the situation described in the PR was already fixed (pytest-dev/pytest-subtests#169 was already merged).
In #34806, @ydshieh said:
TODO (ydshieh): use skipTest once pytest-dev/pytest-subtests/pull/169 is merged
, so I reverted the stopgap fix.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
cc @ydshieh @muellerzr @SunMarc