Fix pipeline parallelism with FusedAttn #635
Merged
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.
This is a temporary workaround just for release 1.3 for the issue introduced in #497 (the actual fix getting into main is #630). The issue is that the code currently assumes that it is possible to use the layer_number (specifically layer_number being equal to 1) to cache the cu_seqlens needed for fused attention. There are a few problems with this assumption (e.g. it does not check that the seqlen did not actually change from the usage in the first layer), but in the case of pipeline parallelism it breaks completely inside NeMo, since there the layers are numbered globally and so some ranks never set layer_number == 1 to any layer.
In this commit I did not remove the global variables used for caching in order to minimize the changes introduced.