Skip to content

[release/2.12] Rename duplicate hiprtc names for jit to avoid symbol collision#3303

Merged
pragupta merged 1 commit into
ROCm:release/2.12from
dnikolaev-amd:hiprc_fp2bf16_fix_2.12
Jun 15, 2026
Merged

[release/2.12] Rename duplicate hiprtc names for jit to avoid symbol collision#3303
pragupta merged 1 commit into
ROCm:release/2.12from
dnikolaev-amd:hiprc_fp2bf16_fix_2.12

Conversation

@dnikolaev-amd

Copy link
Copy Markdown

This file is excluded from hipify (see tools/amd_build/build_amd.py), so it ships its own self-contained __nv_bfloat16 type plus the __float2bfloat16/__bfloat162float conversions for the runtime-compiled fuser kernel. Starting with ROCm 7.x, hiprtc auto-injects a runtime header (hiprtc_runtime.h) that also defines __float2bfloat16 returning __hip_bfloat16. Since C++ cannot overload on return type alone, the two definitions collide. Rather than gate on ROCM_VERSION (a build-time value that does not reliably track whether the runtime hiprtc actually provides these symbols), we keep PyTorch's own round-to-nearest-even implementation and rename our private definitions via the preprocessor so they cannot clash. hiprtc's definitions remain (parsed earlier in the translation unit) but go unused. These #defines must stay in effect for the rest of the kernel source -- do NOT #undef them, since the emitted kernel body calls these conversions after this header is spliced in.

Pull Request resolved: pytorch#185656
Approved by: https://github.com/jeffdaily

(cherry picked from commit 5ca8c13)

https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

pytorch#185656)

This file is excluded from hipify (see tools/amd_build/build_amd.py), so it
ships its own self-contained __nv_bfloat16 type plus the
__float2bfloat16/__bfloat162float conversions for the runtime-compiled fuser
kernel. Starting with ROCm 7.x, hiprtc auto-injects a runtime header
(hiprtc_runtime.h) that also defines __float2bfloat16 returning
__hip_bfloat16. Since C++ cannot overload on return type alone, the two
definitions collide. Rather than gate on ROCM_VERSION (a build-time value
that does not reliably track whether the *runtime* hiprtc actually provides
these symbols), we keep PyTorch's own round-to-nearest-even implementation
and rename our private definitions via the preprocessor so they cannot
clash. hiprtc's definitions remain (parsed earlier in the translation unit)
but go unused. These #defines must stay in effect for the rest of the kernel
source -- do NOT #undef them, since the emitted kernel body calls these
conversions after this header is spliced in.

Pull Request resolved: pytorch#185656
Approved by: https://github.com/jeffdaily

(cherry picked from commit 5ca8c13)
@rocm-repo-management-api

Copy link
Copy Markdown

Jenkins build for 632dfe3f1e3916894ac7240618407e3ff72ce58d commit is in progress
Links: Pipeline Overview / Build artifacts

@pragupta
pragupta merged commit 6aad4ef into ROCm:release/2.12 Jun 15, 2026
0 of 2 checks passed
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.

3 participants