Skip to content

[ROCm] Preserve float bits in SIMT DPP reduction - #2089

Open
liminfei-amd wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
liminfei-amd:fix/2087-gfx1100-dpp-bitcast
Open

liminfei-amd wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
liminfei-amd:fix/2087-gfx1100-dpp-bitcast

Conversation

@liminfei-amd

Copy link
Copy Markdown

Summary

  • Preserve the floating-point accumulator bits around AMD's integer-typed
    __builtin_amdgcn_mov_dpp.
  • Add a gfx11 regression test for the fused Linear4bit path covering fp16,
    bf16, and fp32.

Fixes #2087.

Root cause

The HIP warp reduction passed a float directly to
__builtin_amdgcn_mov_dpp. With ROCm 6.4.4 / clang 19, this produces numeric
float-to-integer and integer-to-float conversions around the DPP move instead
of moving the accumulator's IEEE-754 bits.

Explicit __float_as_uint / __uint_as_float conversions generate the
expected bit-preserving v_mov_b32_dpp. This makes the intended operation
independent of compiler lowering and does not add a version-specific code
path.

ROCm 6.4.4 remains in the current bitsandbytes build matrix. A newer prebuilt
library passed the same numerical oracle, but the source should not rely on
compiler-dependent implicit conversions.

Validation

  • RX 7900 GRE / gfx1100, ROCm 6.4.4 / clang 19:
    • affected library and unmodified source: relative L1 error 0.125295
    • patched source: relative L1 error 0.002051
    • regression test: 3 failed before the fix, 3 passed after it
  • Patched ROCm 10 / clang 23 build: 3 passed.
  • CPU-only collection: 3 skipped cleanly.
  • pre-commit run --all-files: passed.

Only gfx1100 was physically tested. The exact affected ROCm 6.4 native library
was tested with torch 2.7.1 rather than the reporter's torch 2.9.1.

AI assistance was used for reproduction, diagnosis, and patch preparation. The
submitting human should review every changed line and the evidence before
publication.

The AMD mov_dpp builtin operates on integer bits. Explicitly bitcast the floating-point accumulator before and after each lane move so older ROCm compilers do not emit numeric float-to-integer conversions.

Add a gfx11 regression test covering the fused Linear4bit path for fp16, bf16, and fp32.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[BUG] NF4 Linear4bit wrong on gfx1100 (prebuilt ROCm 6.4 wheel); dequantize correct

1 participant