Skip to content

Severe BUG: pos is unexpectedly all zero. #2276

Description

@chenjiasheng

Describe the bug

The pos here as well as the one bellow is unexpectedly zero-ed out by srcmask who has True values on pad positions instead of non-pad positions.
It is supposed to use srcmask_inverted when calling sinusoidal_positional_embed_encoder.
To prove this, just deliberately assign pos to zero with pos = 0 after sinusoidal_positional_embed_encoder , and you will get exactly the same output audio.

I suggest using length_to_mask() to get the mask instead of get_key_padding_mask, because a "<pad>" token in the middle of a sequence does need attention (this may happen for mel feature):

def length_to_mask(lens, max_len=None):
    if max_len is None:
        max_len = lens.max()
    return torch.arange(max_len)[None, :] < lens[:, None]

One more thing, I think a mask should have True values for non-pad positions as convention, otherwise we will name it "pad_mask".

Expected behaviour

pos should not be all 0.

To Reproduce

No response

Environment Details

No response

Relevant Log Output

No response

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions