Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean mt5 #419

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Clean mt5 #419

wants to merge 13 commits into from

Conversation

xiezipeng-ML
Copy link
Contributor

clean mt5,默认fuse_multihead_att和fuse_softmax,注释了model_type='t5'相关内容

@strint

This comment was marked as resolved.

# [bsz, tgt_len, num_heads, head_size] -> [bsz, tgt_len, num_heads * head_size]
# SBP sign: [S(0), S(2)]
# [S(0), S(2)] x [B, S(0)] = [S(0), P] -> [S(0), B]
context = flow._C.transpose(context, perm=(2, 0, 1, 3))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于今天提到的这里有个transpose操作的原因:

  • attention_scores, value = flow._C.fused_self_attention(...),这个fused_self_attention返回的tensor的shape是attention_scores:[batch_size, num_head, seq_len1, seq_len2]以及value:[bsz, num_head, seq_len, head_size],所以这里0维就是batch_size
  • 然后这里的context是由context = flow.matmul(attention_weights, value)得到,所以context的shape是 [bsz, num_head, seq_len, head_size],所以最后需要有这个transpose的操作,没改之前也有transpose的操作:context = context.transpose(1, 2),只不过现在交换了3个维度( context = flow._C.transpose(context, perm=(2, 0, 1, 3)))

@xiezipeng-ML xiezipeng-ML mentioned this pull request Nov 7, 2022
@xiezipeng-ML xiezipeng-ML requested review from oneflow-ci-bot and removed request for oneflow-ci-bot November 17, 2022 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants