PaddleNLP icon indicating copy to clipboard operation
PaddleNLP copied to clipboard

[Bug]: 混合精度类型提升不符合预期

Open ZHUI opened this issue 1 year ago • 1 comments

软件环境

- paddlepaddle:
- paddlepaddle-gpu: 
- paddlenlp:

重复问题

  • [X] I have searched the existing issues

错误描述

类型提升不符合预期

稳定复现步骤 & 代码

import paddle

print(paddle.version.commit)

a = paddle.ones([1], dtype="float32")

with paddle.amp.auto_cast(enable=True, custom_white_list=None, custom_black_list=None, level='O2', dtype='float16', use_promote=True):
    o = paddle.outer(a, a)
    b = paddle.matmul(a, a)
    c = a * a
    d = a - a

print(o.dtype)
print(b.dtype)
print(c.dtype)
print(d.dtype)

print("\n")

with paddle.amp.auto_cast(enable=True, custom_white_list=None, custom_black_list=None, level='O2', dtype='float16', use_promote=False):
    o = paddle.outer(a, a)
    b = paddle.matmul(a, a)
    c = a * a
    d = a - a

print(o.dtype)
print(b.dtype)
print(c.dtype)
print(d.dtype)
2fbebfd87839a9512f8b82fe2e012aa756ab3012
paddle.float16
paddle.float16
paddle.float32
paddle.float32


paddle.float16
paddle.float16
paddle.float16
paddle.float16

ZHUI avatar Dec 08 '23 08:12 ZHUI

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] avatar Feb 07 '24 00:02 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。

github-actions[bot] avatar Feb 21 '24 00:02 github-actions[bot]