Provide MaxText axes to cudnn_flash_te to correctly perform dbias reduction if required #2221
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.
Description
TransformerEngine, which is used for the
attention=cudnn_flash_te
attention backend, requires the physical mesh axis names to to correctly perform a dbias reduction across multiple devices.Currently in MaxText, we never perform as dbias reduction as the attention type of TE's
DotProductAttention
is always set to"no_bias"
(usage in attention_op.py). However, if this changes in the future or a user decides to modify this on their fork, an error will be raised due to MaxText not providing TE with it's mesh axis names associated with the parallelism types, e.g.fsdp_resource = "fsdp"
, etc.For all cases except when
cudnn_flash_te
is used with bias, this change is a no-op.All cases:
transformer_engine
package is not present, in which case this context does not set any state.transformer_engine
package is present. The context sets a particular state in TE for the mapping of physical axes to parallelism concepts, e.g. fsdp.cudnn_flash_te
is NOT used with"pre_scale_bias"
. The axis mapping from the context is unused and does not affect any other operations.cudnn_flash_te
is used with"pre_scale_bias"
. The axis info from the context is used and TE does not raise an error. Without this change in this PR, TE would raise an error here due to missing the axis info.Checklist
Before submitting this PR, please make sure (put X in square brackets):