Skip to content

CUDA: fix round issue, under MSVC the CPU and GPU agree - #30229

Merged
JohannesGaessler merged 1 commit into
ggml-org:masterfrom
KafKafrnZ:fix-cuda-round-msvc
Oct 9, 2026
Merged

JohannesGaessler merged 1 commit into
ggml-org:masterfrom
KafKafrnZ:fix-cuda-round-msvc

Conversation

@KafKafrnZ

@KafKafrnZ KafKafrnZ commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Overview

I found the issue with the GPU round(x) code , when llama.cpp was compiled on windows with MSVC . With the MSVC that round(x) call compiled differently for GPU and for CPU and gave different answers on every exact half . Linux build uses gcc that's why no one noticed this on Linux . The f16 and bf16 tests are low precision number type cause of which random test values landed on half like .5 , for fix round(x) became roundf(x) so nvidia documents it as rounding halves away from zero.

fixes #29406

Additional information

This was done on my setup ( RTX 5070 Ti Laptop, Windows 11, CUDA 13.4.59, MSVC 14.51)
results ( Earlier cause of f16 and bf16 9 of 18 tests failed on my RTX 5070 Ti , after roundf(x) fix whole test suite passes)

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, I used AI to help me find out Blackwell GPU specific bugs i can work on , then it helped me install the toolchain + reproduce the exact bug and suggested the fix which I then reviewed and tested myself

@KafKafrnZ
KafKafrnZ requested a review from a team as a code owner October 9, 2026 12:11
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Oct 9, 2026
@ggml-gh-bot

This comment was marked as resolved.

@ggml-gh-bot ggml-gh-bot Bot added the draft PR will be changed to draft by github-actions bot label Oct 9, 2026
@github-actions
github-actions Bot marked this pull request as draft October 9, 2026 12:17
@github-actions github-actions Bot removed the draft PR will be changed to draft by github-actions bot label Oct 9, 2026
@CISC
CISC marked this pull request as ready for review October 9, 2026 12:29
@JohannesGaessler
JohannesGaessler merged commit 79e2e74 into ggml-org:master Oct 9, 2026
18 checks passed
ckti pushed a commit to ckti/llama.cpp-consolidated that referenced this pull request Oct 12, 2026
@BrewTestBot BrewTestBot mentioned this pull request Oct 15, 2026
1 task done
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: CUDA ROUND rounds half to even with an MSVC host compiler (test-backend-ops ROUND f16 fails)

3 participants