[BUG] Packed THD MLA value padding may affect attention backend availability on Blackwell
Describe the bug
MultiLatentAttention._prepare_mla_core_attention_value pads the value tensor
to the query/key head dimension whenever packed THD format is used and the
dimensions differ.
For an MLA configuration with a query/key head dimension of 192 and a value head dimension of 128, this changes the value head dimension to 192 before calling core attention. The output is trimmed back to 128 afterward.
On sm100 Blackwell, this appears able to make Transformer Engine reject the cuDNN fused-attention training path because the padded value dimension is greater than 128. This can leave no available attention backend in a context-parallel training configuration, even though preserving the original value dimension allows the configuration to proceed.
The unconditional padding may therefore turn an otherwise supported unequal-dimension attention operation into an unsupported equal-dimension one.
Steps/Code to reproduce bug
In a Blackwell training configuration using MLA with packed THD input and different query/key and value head dimensions:
- Run a forward and backward pass with the current implementation.
- Observe that
_prepare_mla_core_attention_valuepads the value tensor to the query/key head dimension. - Record the attention backend selection result or resulting error.
- Repeat while preserving the original value head dimension.
A useful reproducer would show that preserving the original value dimension allows the same configuration to proceed where the padded version does not.
The smallest focused reproducer is expected to require one sm100 Blackwell GPU. Reproducing the downstream end-to-end failure may require at least two GPUs because the observed configuration uses context parallelism.
SkyRL has observed this in a larger training configuration and carries the workaround linked below. I have not reduced it to a standalone Megatron-LM reproducer against current main.
Expected behavior
Padding the MLA value tensor for packed THD input should not make an otherwise supported training configuration lose all available attention backends.
Additional context
SkyRL currently works around this on Blackwell by preserving the original value dimension:
Relevant upstream code:
Source: NVIDIA/Megatron-LM