[ROCm] Use native HIP BF16 rounding in phi bfloat16#52
Open
austin1997 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Environment Adaptation
PR Types
Bug fixes
Description
当前 HIP 构建下
phi::dtype::bfloat16从 float 构造时直接截断高 16 bit,和 CUDA/CPU 路径的 round-to-nearest-even 行为不一致,导致bfloat16_test中的 bit 级转换检查失败。本 PR 为 HIP 编译器环境启用
hip_bfloat16头文件和PADDLE_HIP_BF16宏,并在phi::dtype::bfloat16中补齐hip_bfloat16构造、赋值和to_hip_bfloat16转换桥接。HIP 编译器路径使用hip_bfloat16的 native rounding;普通 host C++ 编译路径继续复用已有 CPU round-to-nearest-even fallback,避免 host-only 编译单元强依赖 HIP native 类型。是否引起精度变化
否。该修复统一 BF16 bit 级转换舍入行为,不改变既有 FP32 计算语义。
Test
prek run --files paddle/common/backend_header.h paddle/phi/common/bfloat16.henv TARGET=SKYLAKEX ninja -j 160 bfloat16_test./test/cpp/bfloat16_test