[deepspeed / m2m_100] make deepspeed zero-3 work with layerdrop #16717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Same as I had to fix in
wav2vec2it looks that this fix should eventually go to all models that useLayerDrop. At least at the moment Deepspeed is not capable of randomly skipping layers, so this PR uses the same now well tested workaround I used inwav2vec2, where all layers always run when deepspeed zero-3 is detected, but the results are ignored if it was meant to be skipped.transformers/src/transformers/models/wav2vec2/modeling_wav2vec2.py
Lines 817 to 849 in 69233cf
Perhaps one day Deepspeed will be able to randomly skip layers, at the moment the solution is not the most efficient one. I made a request.
When ZeRO-3 is not used the original code path is taken.
The test exercising this code path will be merged as part of this huge additional tests set PR #12695 (it's been long overdue).
For posterity, the error for this issue will look something like:
Fixes: #16688
@patil-suraj, @sgugger