Skip to content

[PyTorch] Definition of attention mask #614

Description

@Marks101

Hi team,

I am wondering about the definition of the attention mask in transformer-engine. I did not find an explanation in the docs. Does True mean that the position takes part in attention or that it is masked out?

These two code positions suggest that True means masked out:
https://github.com/NVIDIA/TransformerEngine/blob/main/tests/pytorch/test_numerics.py#L71
https://github.com/NVIDIA/TransformerEngine/blob/main/transformer_engine/pytorch/utils.py#L34

But for flash attention with padding, the cumulated sequence lengths are computed based on a sum over the mask. This suggests that it is vice versa:
https://github.com/NVIDIA/TransformerEngine/blob/main/transformer_engine/pytorch/attention.py#L180

Thanks for clarifying this!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions