Skip to content

hip: fix bf16 WMMA operand vector type for gfx11/gfx12 - #30885

Merged
JohannesGaessler merged 1 commit into
ggml-org:masterfrom
waltercool:master
Oct 23, 2026
Merged

JohannesGaessler merged 1 commit into
ggml-org:masterfrom
waltercool:master

Conversation

@waltercool

@waltercool waltercool commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Overview

The __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (and _gfx12) builtins take their A/B operands as vectors of short (_ExtVector<16, short> / _ExtVector<8, short>), not __bf16. Declaring the fragments as ext_vector_type(N) __bf16 fails to compile:

error: cannot initialize a parameter of type 'short attribute((ext_vector_type(16)))' (vector of 16 'short' values) with an lvalue of type 'const bf16x16_t' (vector of 16 '__bf16' values)

short and __bf16 are both 16-bit and the value is only ever passed to the builtin via reinterpret_cast over raw bytes, so changing the element type is bit-identical. The operand type has been short since the builtin was introduced, so this works across LLVM/ROCm versions without a version gate. Fixes HIP builds for RDNA3 (gfx1150/1151) and RDNA4 (gfx1200/1201).

Additional information

Basically, it gives support for LLVM 23 for RDNA3 and RDNA4 GPUs, otherwise it fails to build with latest HIP/ROCm.

Fixes issue #30839

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes. Used it to analyze why my local build was failing, locate the LLVM documentation and fix the issue. Patch tested by myself on local gfx1151. There is no automation in the process, AI was solely used to ask questions and create the PR description according to contributing guidelines.

@waltercool
waltercool requested a review from a team as a code owner October 20, 2026 15:27
The __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (and _gfx12) builtins
take their A/B operands as vectors of short (_ExtVector<16, short> /
_ExtVector<8, short>), not __bf16. Declaring the fragments as
ext_vector_type(N) __bf16 fails to compile:

  error: cannot initialize a parameter of type 'short
  __attribute__((ext_vector_type(16)))' with an lvalue of type 'const
  bf16x16_t' (vector of 16 '__bf16' values)

short and __bf16 are both 16-bit and the value is only ever passed to
the builtin via reinterpret_cast over raw bytes, so changing the element
type is bit-identical. The operand type has been short since the builtin
was introduced, so this works across LLVM/ROCm versions without a
version gate. Fixes HIP builds for RDNA3 (gfx1150/1151) and RDNA4
(gfx1200/1201).

Signed-off-by: Pablo Cholaky <[email protected]>
@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 20, 2026
@JohannesGaessler
JohannesGaessler merged commit 9145ddb into ggml-org:master Oct 23, 2026
14 of 15 checks passed
adromir pushed a commit to adromir/llama-cpp-turboquant that referenced this pull request Oct 24, 2026
The __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (and _gfx12) builtins
take their A/B operands as vectors of short (_ExtVector<16, short> /
_ExtVector<8, short>), not __bf16. Declaring the fragments as
ext_vector_type(N) __bf16 fails to compile:

  error: cannot initialize a parameter of type 'short
  __attribute__((ext_vector_type(16)))' with an lvalue of type 'const
  bf16x16_t' (vector of 16 '__bf16' values)

short and __bf16 are both 16-bit and the value is only ever passed to
the builtin via reinterpret_cast over raw bytes, so changing the element
type is bit-identical. The operand type has been short since the builtin
was introduced, so this works across LLVM/ROCm versions without a
version gate. Fixes HIP builds for RDNA3 (gfx1150/1151) and RDNA4
(gfx1200/1201).

Signed-off-by: Pablo Cholaky <[email protected]>
(cherry picked from commit 9145ddb)
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
The __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (and _gfx12) builtins
take their A/B operands as vectors of short (_ExtVector<16, short> /
_ExtVector<8, short>), not __bf16. Declaring the fragments as
ext_vector_type(N) __bf16 fails to compile:

  error: cannot initialize a parameter of type 'short
  __attribute__((ext_vector_type(16)))' with an lvalue of type 'const
  bf16x16_t' (vector of 16 '__bf16' values)

short and __bf16 are both 16-bit and the value is only ever passed to
the builtin via reinterpret_cast over raw bytes, so changing the element
type is bit-identical. The operand type has been short since the builtin
was introduced, so this works across LLVM/ROCm versions without a
version gate. Fixes HIP builds for RDNA3 (gfx1150/1151) and RDNA4
(gfx1200/1201).

Signed-off-by: Pablo Cholaky <[email protected]>
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
The __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (and _gfx12) builtins
take their A/B operands as vectors of short (_ExtVector<16, short> /
_ExtVector<8, short>), not __bf16. Declaring the fragments as
ext_vector_type(N) __bf16 fails to compile:

  error: cannot initialize a parameter of type 'short
  __attribute__((ext_vector_type(16)))' with an lvalue of type 'const
  bf16x16_t' (vector of 16 '__bf16' values)

short and __bf16 are both 16-bit and the value is only ever passed to
the builtin via reinterpret_cast over raw bytes, so changing the element
type is bit-identical. The operand type has been short since the builtin
was introduced, so this works across LLVM/ROCm versions without a
version gate. Fixes HIP builds for RDNA3 (gfx1150/1151) and RDNA4
(gfx1200/1201).

Signed-off-by: Pablo Cholaky <[email protected]>
@BrewTestBot BrewTestBot mentioned this pull request Oct 28, 2026
1 task done
AngryLoki added a commit to AngryLoki/ggml that referenced this pull request Nov 26, 2026
Follow-up to ggml-org/llama.cpp#30885: the CDNA MFMA bf16 builtins
also take short vectors, so LLVM 23 rejects __bf16 for gfx908, gfx90a,
gfx942 and gfx950.
AngryLoki added a commit to AngryLoki/llama.cpp that referenced this pull request Nov 26, 2026
Follow-up to ggml-org#30885: the CDNA MFMA bf16 builtins
also take short vectors, so LLVM 23 rejects __bf16 for gfx908, gfx90a,
gfx942 and gfx950.
AngryLoki added a commit to AngryLoki/whisper.cpp that referenced this pull request Nov 26, 2026
Follow-up to ggml-org/llama.cpp#30885: the CDNA MFMA bf16 builtins
also take short vectors, so LLVM 23 rejects __bf16 for gfx908, gfx90a,
gfx942 and gfx950.
JohannesGaessler pushed a commit that referenced this pull request Nov 26, 2026
Follow-up to #30885: the CDNA MFMA bf16 builtins
also take short vectors, so LLVM 23 rejects __bf16 for gfx908, gfx90a,
gfx942 and gfx950.
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.

3 participants