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
[AMP] fix static promote #53439
[AMP] fix static promote #53439
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
…addle#53358)" This reverts commit 1bd468e.
…addlePaddle#53358)"" This reverts commit 31b9309.
…ePaddle#53225)"" This reverts commit 3da2fab.
@@ -196,8 +225,6 @@ def _update_list(self): | |||
elif op_name in self.gray_list: | |||
self.gray_list.remove(op_name) | |||
self.white_list.add(op_name) | |||
if op_name in _extra_unsupported_list: | |||
self.unsupported_list.remove(op_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# from black_list and unsupport_list. | ||
if op in ['lookup_table', 'lookup_table_v2']: | ||
continue | ||
if _need_keep_fp32(op, amp_lists.unsupported_list, use_fp16_guard): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为了解决transformer模型中出现的报错问题,同时为了动静态图在模型参数类型转换时行为统一:黑名单中的算子依然会保持fp16权重,仅不支持fp16的算子或者不在use_fp16_guard下的算子需要保持fp32权重。
PR最好merge下develop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Bug fixesPR changes
OthersDescription
fix static promote将因性能有问题而放入unsupprot_list中的算子放入黑名单中,以保证在O2模式下,只有3种场景权重会保持fp32:
一些模型中可能存在某些算子权重被后续在白名单中的算子使用,权重的名字同时在keep_fp32_var_names和to_fp16_var_names中,可能会导致权重var.dtype和存储的数据的dtype不同。解决方案:如果var在keep_fp32_var_names中,那么将从to_fp16_var_names移除
该场景在transformer模型中存在,修复以下报错问题