Skip to content

Commit 5362d5a

Browse files
Add missing hipBLASLt library folder and fix some building instructions (#22)
* Updating llama.cpp is not needed anymore. Please check: https://github.com/ggml-org/llama.cpp/blob/master/ggml/src/ggml-cuda/vendors/hip.h#L145 * Fix gfx targets, RDNA and commercial names * Add missing hipblaslt library folder * Update HIP version check is not needed anymore. Please check https://github.com/ggml-org/llama.cpp/blob/master/ggml/src/ggml-cuda/vendors/hip.h#L145 * Add missing hipblaslt library folder * Another fix for RDNA3/4 commercial names * GGML_HIP_FORCE_ROCWMMA_FATTN_GFX12 flag is not needed any more due to llama.cpp rocWMMA updates: ggml-org/llama.cpp#16221 * Delete GGML_HIP_FORCE_ROCWMMA_FATTN_GFX12 flag * Add gfx1101 and gfx1102 targets --------- Co-authored-by: Daniel Holanda <[email protected]>
1 parent 07ccd4e commit 5362d5a

File tree

3 files changed

+50
-56
lines changed

3 files changed

+50
-56
lines changed

.github/workflows/build-llamacpp-rocm.yml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,6 @@ jobs:
266266
# Show current commit info
267267
Write-Host "Current llama.cpp commit:"
268268
git log --oneline -1
269-
270-
- name: Update HIP version check
271-
run: |
272-
cd llama.cpp
273-
$hipFile = "ggml\src\ggml-cuda\vendors\hip.h"
274-
if (Test-Path $hipFile) {
275-
$content = Get-Content $hipFile -Raw
276-
$updatedContent = $content -replace 'HIP_VERSION >= 70000000', 'HIP_VERSION >= 50600000'
277-
Set-Content $hipFile $updatedContent -NoNewline
278-
Write-Host "Updated HIP version check in $hipFile"
279-
} else {
280-
Write-Host "Warning: $hipFile not found"
281-
}
282269
283270
# - name: Apply rocWMMA patch (non-interactive)
284271
# shell: bash
@@ -296,7 +283,7 @@ jobs:
296283
echo Input target: %current_target%
297284
298285
if "%current_target%"=="gfx110X" (
299-
set "mapped_target=gfx1100"
286+
set "mapped_target=gfx1100;gfx1101;gfx1102"
300287
) else if "%current_target%"=="gfx1151" (
301288
set "mapped_target=gfx1151"
302289
) else if "%current_target%"=="gfx120X" (
@@ -334,7 +321,6 @@ jobs:
334321
-DGGML_OPENMP=OFF ^
335322
-DGGML_CUDA_FORCE_CUBLAS=OFF ^
336323
-DGGML_HIP_ROCWMMA_FATTN=OFF ^
337-
-DGGML_HIP_FORCE_ROCWMMA_FATTN_GFX12=OFF ^
338324
-DLLAMA_CURL=OFF ^
339325
-DGGML_NATIVE=OFF ^
340326
-DGGML_STATIC=OFF ^
@@ -393,6 +379,21 @@ jobs:
393379
} else {
394380
Write-Host "Warning: rocblas\library folder not found at: $rocblasLibPath"
395381
}
382+
383+
# Copy the hipblaslt\library folder and all its contents
384+
$hipblasltLibPath = Join-Path $rocmBinPath "hipblaslt\library"
385+
if (Test-Path $hipblasltLibPath) {
386+
Write-Host "Copying hipblaslt\library folder and all contents..."
387+
$destHipblasltPath = Join-Path $buildBinPath "hipblaslt\library"
388+
Copy-Item -Path $hipblasltLibPath -Destination $destHipblasltPath -Recurse -Force
389+
Write-Host "Copied: hipblaslt\library folder with all contents"
390+
391+
# List the contents of the copied hipblaslt\library folder
392+
Write-Host "Contents of hipblaslt\library:"
393+
Get-ChildItem $destHipblasltPath -Recurse | Select-Object FullName, Length | Format-Table -AutoSize
394+
} else {
395+
Write-Host "Warning: rocblas\library folder not found at: $rocblasLibPath"
396+
}
396397
397398
Write-Host "ROCm core files successfully copied to build directory"
398399
} else {
@@ -654,17 +655,6 @@ jobs:
654655
# Show current commit info
655656
echo "Current llama.cpp commit:"
656657
git log --oneline -1
657-
658-
- name: Update HIP version check
659-
run: |
660-
cd llama.cpp
661-
hip_file="ggml/src/ggml-cuda/vendors/hip.h"
662-
if [ -f "$hip_file" ]; then
663-
sed -i 's/HIP_VERSION >= 70000000/HIP_VERSION >= 50600000/g' "$hip_file"
664-
echo "Updated HIP version check in $hip_file"
665-
else
666-
echo "Warning: $hip_file not found"
667-
fi
668658
669659
#- name: Apply rocWMMA patch (non-interactive)
670660
# run: |
@@ -679,11 +669,11 @@ jobs:
679669
echo "Input target: $current_target"
680670
681671
if [ "$current_target" = "gfx110X" ]; then
682-
mapped_target="gfx1100"
672+
mapped_target="gfx1100;gfx1101;gfx1102"
683673
elif [ "$current_target" = "gfx1151" ]; then
684674
mapped_target="gfx1151"
685675
elif [ "$current_target" = "gfx120X" ]; then
686-
mapped_target="gfx1200,gfx1201"
676+
mapped_target="gfx1200;gfx1201"
687677
else
688678
mapped_target="$current_target"
689679
fi
@@ -707,7 +697,6 @@ jobs:
707697
-DGGML_OPENMP=OFF \
708698
-DGGML_CUDA_FORCE_CUBLAS=OFF \
709699
-DGGML_HIP_ROCWMMA_FATTN=OFF \
710-
-DGGML_HIP_FORCE_ROCWMMA_FATTN_GFX12=OFF \
711700
-DLLAMA_CURL=OFF \
712701
-DGGML_NATIVE=OFF \
713702
-DGGML_STATIC=OFF \
@@ -736,6 +725,22 @@ jobs:
736725
else
737726
echo "Warning: rocblas/library folder not found at: $rocblas_lib_path"
738727
fi
728+
729+
# Copy the hipblaslt/library folder and all its contents
730+
hipblaslt_lib_path="/opt/rocm/lib/hipblaslt/library"
731+
if [ -d "$hipblaslt_lib_path" ]; then
732+
echo "Copying hipblaslt/library folder and all contents..."
733+
dest_hipblaslt_path="$build_bin_path/hipblaslt/library"
734+
mkdir -p "$(dirname "$dest_hipblaslt_path")"
735+
cp -r "$hipblaslt_lib_path" "$(dirname "$dest_hipblaslt_path")/"
736+
echo "Copied: hipblaslt/library folder with all contents"
737+
738+
# List the contents of the copied hipblaslt/library folder
739+
echo "Contents of hipblaslt/library:"
740+
find "$dest_hipblaslt_path" -type f -exec ls -la {} \; | head -20
741+
else
742+
echo "Warning: hipblaslt/library folder not found at: $hipblaslt_lib_path"
743+
fi
739744
740745
# Copy required ROCm libraries to build directory
741746
# If artifacts from ROCm or Llama.cpp change, you may need to update this list

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ We provide nightly builds of **llama.cpp** with **AMD ROCm™ 7** acceleration b
3232

3333
This build specifically targets the following GPU architectures:
3434
- **gfx1151** (STX Halo GPUs) - Ryzen AI MAX+ Pro 395
35-
- **gfx120X** (RDNA4 GPUs) - includes AMD Radeon AI PRO R9700, RX 9070 XT/GRE/9070, RX 9060 XT
36-
- **gfx110X** (RDNA3 GPUs) - includes AMD Radeon PRO W7900/W7800/W7700/V710, RX 7900 XTX/XT/GRE, RX 7800 XT, RX 7700 XT
35+
- **gfx120X** (RDNA4 GPUs) - includes AMD Radeon RX 9070 XT/GRE/9070, RX 9060 XT/9060
36+
- **gfx110X** (RDNA3 GPUs) - includes AMD Radeon PRO W7900/W7800/W7700/W7600, RX 7900 XTX/XT/GRE, RX 7800 XT, RX 7700 XT/7700, RX 7600 XT/7600
3737

3838
**All builds include ROCm™ 7 built-in** - no separate ROCm™ installation required!
3939

docs/manual_instructions.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ I used chocolatey, but you can also install those manually.
4242
* Setp 6: Add `C:\opt\rocm\lib\llvm\bin` to path
4343
* Step 7: clone llamacpp
4444

45-
### Part 3: Updating llama.cpp
46-
47-
Open `C:\<YOUR_LLAMACPP_PATH>\ggml\src\ggml-cuda\vendors\hip.h` and replace `HIP_VERSION >= 70000000` with `HIP_VERSION >= 50600000`
48-
49-
### Part 4: Building Llama.cpp + ROCm
45+
### Part 3: Building Llama.cpp + ROCm
5046

5147
Open `x64 Native Tools Command Prompt` and run the following commands:
5248

@@ -115,17 +111,7 @@ sudo apt install -y cmake ninja-build git wget
115111
git clone https://github.com/ggerganov/llama.cpp.git
116112
```
117113

118-
### Part 3: Updating llama.cpp
119-
120-
> **Note**: This step is identical to the [Windows Part 3](#part-3-updating-llamacpp) above, with the same file modification.
121-
122-
Navigate to your llama.cpp directory and update the HIP version check:
123-
```bash
124-
cd llama.cpp
125-
sed -i 's/HIP_VERSION >= 70000000/HIP_VERSION >= 50600000/g' ggml/src/ggml-cuda/vendors/hip.h
126-
```
127-
128-
### Part 4: Building Llama.cpp + ROCm
114+
### Part 3: Building Llama.cpp + ROCm
129115

130116
Run the following commands to build llama.cpp with ROCm support:
131117

@@ -150,7 +136,6 @@ cmake .. -G Ninja \
150136
-DGGML_OPENMP=OFF \
151137
-DGGML_CUDA_FORCE_CUBLAS=OFF \
152138
-DGGML_HIP_ROCWMMA_FATTN=ON \
153-
-DGGML_HIP_FORCE_ROCWMMA_FATTN_GFX12=OFF \
154139
-DLLAMA_CURL=OFF \
155140
-DGGML_NATIVE=OFF \
156141
-DGGML_STATIC=OFF \
@@ -162,7 +147,7 @@ cmake --build . -j $(nproc)
162147

163148
> **Note**: Adjust the `-DAMDGPU_TARGETS="gfx1151"` parameter for your specific GPU. See the [GPU Target Reference](#gpu-target-reference) section for details.
164149
165-
### Part 5: Copy required ROCm libraries
150+
### Part 4: Copy required ROCm libraries
166151

167152
After successful compilation, copy the required ROCm libraries to the build directory:
168153

@@ -182,6 +167,10 @@ cp -v /opt/rocm/lib/rocm_sysdeps/lib/*.so* .
182167
# Copy the rocblas library folder
183168
mkdir -p rocblas
184169
cp -r /opt/rocm/lib/rocblas/library rocblas/
170+
171+
# Copy the hipblaslt library folder
172+
mkdir -p hipblaslt
173+
cp -r /opt/rocm/lib/hipblaslt/library hipblaslt/
185174
```
186175

187176
If you see no errors during the build process, llama.cpp has been successfully compiled and all files are available in your `build/bin` folder.
@@ -192,9 +181,9 @@ If you see no errors during the build process, llama.cpp has been successfully c
192181

193182
When building llama.cpp with ROCm, the `-DAMDGPU_TARGETS` parameter must be set based on your specific GPU architecture. Our automated workflow uses generic targets that get mapped to specific architectures:
194183

195-
- **`gfx120X`** maps to `gfx1200,gfx1201` (RDNA 3 series like RX 7900 XT/XTX)
196-
- **`gfx110X`** maps to `gfx1100` (RDNA 2 series like RX 6000 series)
197-
- **`gfx1151`** remains as `gfx1151` (specific for RX 7600/7700 XT)
184+
- **`gfx120X`** maps to `gfx1200, gfx1201` (RDNA4 series like: RX 9070 XT/GRE/9070, RX 9060 XT/9060)
185+
- **`gfx110X`** maps to `gfx1100, gfx1101, gfx1102` (RDNA3 series like: PRO W7900/W7800/W7700/W7600, RX 7900 XTX/XT/GRE, RX 7800 XT, RX 7700 XT/7700, RX 7600 XT/7600)
186+
- **`gfx1151`** remains as `gfx1151` (Strix Halo)
198187

199188
For a complete list of GPU targets and their mappings, see the [automated workflow](../.github/workflows/build-llamacpp-rocm.yml).
200189

@@ -203,12 +192,12 @@ For a complete list of GPU targets and their mappings, see the [automated workfl
203192
Replace the `-DAMDGPU_TARGETS="gfx1151"` parameter in your cmake command with the appropriate target for your GPU:
204193

205194
```bash
206-
# For RDNA 3 series (RX 7900 XT/XTX)
207-
-DAMDGPU_TARGETS="gfx1200,gfx1201"
195+
# For RDNA4 series (RX 9070 XT/GRE/9070, RX 9060 XT/9060)
196+
-DAMDGPU_TARGETS="gfx1200, gfx1201"
208197

209-
# For RDNA 2 series (RX 6000 series)
198+
# For RDNA3 series (PRO W7900/W7800/W7700/W7600, RX 7900 XTX/XT/GRE, RX 7800 XT, RX 7700 XT/7700, RX 7600 XT/7600)
210199
-DAMDGPU_TARGETS="gfx1100"
211200

212-
# For RX 7600/7700 XT
201+
# For Strix Halo
213202
-DAMDGPU_TARGETS="gfx1151"
214203
```

0 commit comments

Comments
 (0)