Skip to content

dq_q2_0: keep the Q2_0 signed-zero fix on every HIP arch (#1474) - #1540

Closed
nekomario28 wants to merge 1 commit into
Niko1221:mainfrom
nekomario28:fix-1474-q2-zero-hip-guard
Closed

nekomario28 wants to merge 1 commit into
Niko1221:mainfrom
nekomario28:fix-1474-q2-zero-hip-guard

Conversation

@nekomario28

Copy link
Copy Markdown
Contributor

Summary

  • hip_q2_zero fails on gfx1201 (R9700) with ROCm 7.10: the half path folds a negative scale times +0 to +0, but the dq_q2_0 workaround was gated to (__gfx1012__ && HIP_VERSION_MAJOR < 7) || __gfx1151__ — the arch list only covers the reports seen so far, and gfx1201 on HIP 7 falls outside it.
  • Drop the arch/version conditions, keep __HIPCC__. The workaround writes the scale's sign bit for code 1, which is value-identical on targets whose compiler never folds — this matches the reporter's proposed fix.

Fixes #1474.

Test plan

  • amdclang++ -x hip -fsyntax-only --offload-arch=gfx1201 on src/kernels/cuda/iq_kernels.cu with the build's compat flags: clean
  • ctest -R hip_q2_zero on the reporter's R9700 / ROCm 7.10 build: expect PASS (128 signed-zero failures → 0)
  • CUDA builds unaffected (#if defined(__HIPCC__) only)

…o1221#1474)

The negative-scale-times-zero workaround was gated to gfx1012 on HIP < 7
and gfx1151 - the reports of the compiler fold so far. gfx1201 on ROCm
7.10 fails hip_q2_zero the same way (got 0x0000, expected 0x8000), so
the arch list only ever chased the newest report. The workaround writes
the scale's sign bit for code 1, which is value-identical on targets
whose compiler never folds: keep it on every HIP build.
@nekomario28

Copy link
Copy Markdown
Contributor Author

Obsolete: the fix is in main — src/kernels/cuda/iq_kernels.cu:1858 carries "7.10, #1474) fold the half path's negative scale times +0 to +0. Preserve the scale's sign…", and the community benchmark README for r9700 links this issue and PR by number. Closing rather than rebasing an empty change.

Niko1221 added a commit that referenced this pull request Oct 17, 2026
…, #1474)

The negative-scale-times-zero workaround was gated to an arch list (gfx1012 on
HIP < 7, gfx1151, gfx1200/gfx1201 since 0ff45cf); the list only ever chased
the newest report. The workaround writes the scale's sign bit for code 1, which
is value-identical on targets whose compiler never folds: keep it on every HIP
build. Ported from PR #1540 onto the tree that already carries the gfx1200/1201
entries; the comment text is adjusted.

Co-authored-by: nekomario28 <206304251+nekomario28@users.noreply.github.com>
@Niko1221

Copy link
Copy Markdown
Owner

Thanks nekomario28. The gfx1201 part was already in main (0ff45cf); we ported your generalisation to every HIP arch with you as co-author and hip_q2_zero passes on our R9700.

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.

hip_q2_zero fails on gfx1201 (R9700) with ROCm 7.10: Q2_0 signed-zero fix e9a5f8d is gated to gfx1012 / HIP < 7

2 participants