Skip to content

ggml-hip : add -fno-finite-math-only alongside -ffast-math - #25373

Merged
IMbackK merged 1 commit into
ggml-org:masterfrom
asf0:ggml-hip/ffast-math-no-finite
Jul 7, 2026
Merged

IMbackK merged 1 commit into
ggml-org:masterfrom
asf0:ggml-hip/ffast-math-no-finite

Conversation

@asf0

@asf0 asf0 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Overview

Fixes #25361. PR #23862 enabled -ffast-math for HIP builds. Under ROCm/LLVM 22 -ffast-math implies -ffinite-math-only, which disables INFINITY / NaN and produces -Wnan-infinity-disabled warnings. With -Werror in CI this breaks the HIP job across all template instances that touch INFINITY in common.cuh (return -INFINITY;, make_half2(-INFINITY, -INFINITY)).

Add -fno-finite-math-only alongside -ffast-math to re-enable infinity/NaN handling while keeping the rest of fast-math. Equivalent to how CUDA builds use -use_fast_math (which does not disable infinity).

Additional information

Builds clean on Strix Halo (gfx1151), ROCm 7.2.4, Ubuntu 26.04, with -DCMAKE_HIP_FLAGS="-Werror -Wno-tautological-compare". No -Wnan-infinity-disabled warnings, all template instances compile.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, AI was used to investigate the build logs and identify the root cause. The fix itself was authored independently.

-ffast-math implies -ffinite-math-only under ROCm/clang 22, which
disables INFINITY/NaN and triggers -Wnan-infinity-disabled (errors
under -Werror in CI). Re-enable infinity handling without dropping
the rest of fast-math.

Fixes #25361
@asf0
asf0 requested a review from IMbackK as a code owner July 6, 2026 22:10
Copilot AI review requested due to automatic review settings July 6, 2026 22:10
@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Jul 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts ggml-hip build flags to keep -ffast-math enabled for performance while explicitly re-enabling non-finite math (INFINITY / NaN) on newer ROCm/LLVM toolchains where -ffast-math implies -ffinite-math-only, which can trigger -Wnan-infinity-disabled and break -Werror CI.

Changes:

  • Add -fno-finite-math-only alongside -ffast-math for HIP compilation to avoid INFINITY/NaN-related warnings becoming errors in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ORippler ORippler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Confirmed this fixes the repro in #25361

@ORippler

ORippler commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

I think it would be nice to adjust hip-quality-check to run on all changes associated with the hip backend in future:

diff --git a/.github/workflows/hip-quality-check.yml b/.github/workflows/hip-quality-check.yml
index 14b9f41a6..5d23f01cf 100644
--- a/.github/workflows/hip-quality-check.yml
+++ b/.github/workflows/hip-quality-check.yml
@@ -9,6 +9,8 @@ on:
       '.github/workflows/hip-quality-check.yml',
       '**/*.cu',
       '**/*.cuh',
+      'ggml/src/ggml-hip/CMakeLists.txt',
+      'ggml/src/ggml-cuda/vendors/hip.h',
       'scripts/hip/gcn-cdna-vgpr-check.py'
     ]
 
@@ -18,6 +20,8 @@ on:
       '.github/workflows/hip-quality-check.yml',
       '**/*.cu',
       '**/*.cuh',
+      'ggml/src/ggml-hip/CMakeLists.txt',
+      'ggml/src/ggml-cuda/vendors/hip.h',
       'scripts/hip/gcn-cdna-vgpr-check.py'
     ]

@IMbackK do you agree?

@IMbackK

IMbackK commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

yes, absolutely

@IMbackK
IMbackK merged commit 33ca0dc into ggml-org:master Jul 7, 2026
25 checks passed
ORippler added a commit that referenced this pull request Jul 8, 2026
Improvement of the CI to run on all hip-related changes as a follow-up to
#25373
so breakage is more likely to be caught in future
@Beinsezii Beinsezii mentioned this pull request Jul 9, 2026
1 task done
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
…25373)

-ffast-math implies -ffinite-math-only under ROCm/clang 22, which
disables INFINITY/NaN and triggers -Wnan-infinity-disabled (errors
under -Werror in CI). Re-enable infinity handling without dropping
the rest of fast-math.

Fixes ggml-org#25361
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
Improvement of the CI to run on all hip-related changes as a follow-up to
ggml-org#25373
so breakage is more likely to be caught in future
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
…25373)

-ffast-math implies -ffinite-math-only under ROCm/clang 22, which
disables INFINITY/NaN and triggers -Wnan-infinity-disabled (errors
under -Werror in CI). Re-enable infinity handling without dropping
the rest of fast-math.

Fixes ggml-org#25361
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
Improvement of the CI to run on all hip-related changes as a follow-up to
ggml-org#25373
so breakage is more likely to be caught in future
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: HIP CI is currently broken, likely by 23862

4 participants