Skip to content

Commit 18e039f

Browse files
authored
fix(ci): fix AMDGPU_TARGETS empty-string bypass in hipblas builds (mudler#9626)
* fix(ci): fix AMDGPU_TARGETS empty-string bypass in hipblas builds 399c1de wired amdgpu-targets through the backend_build workflow_call interface, intending the input's default value to cover matrix entries that don't specify targets. However, GitHub Actions only applies a workflow_call input default when the caller omits the input entirely. When backend.yml passes `amdgpu-targets: ${{ matrix.amdgpu-targets }}` and the matrix entry has no amdgpu-targets key, the expression evaluates to an empty string, which is treated as an explicit value — bypassing the default. The result is Docker receiving AMDGPU_TARGETS="" which in turn causes Make's ?= default to be skipped (since the variable is already set in the environment, even to empty), and cmake gets -DAMDGPU_TARGETS= with no targets, so the HIP backend compiles for an indeterminate target rather than the intended GPU list. Fix this at two levels: 1. backend.yml: use a || fallback in the expression so that an undefined matrix.amdgpu-targets never reaches the reusable workflow as an empty string. The target list is the canonical default and lives here. 2. backend_build.yml: remove the now-misleading default value from the input declaration. The default never fired due to the above bug, so keeping it implied a guarantee that didn't exist. 3. backend/cpp/llama-cpp/Makefile: add an explicit $(error ...) guard after the ?= assignment so that if AMDGPU_TARGETS is empty (whether from environment or any future CI wiring mistake) the build fails immediately with a clear message rather than silently producing a binary compiled for an unknown GPU target. Assisted-by: Claude Code:claude-sonnet-4-6 Signed-off-by: Russell Sim <rsl@simopolis.xyz> * fix(build): plumb AMDGPU_TARGETS through to Docker builds The docker-build-backend Makefile macro and Dockerfile.golang did not pass AMDGPU_TARGETS to the inner make invocation, so hipblas builds always used the backend Makefile's hardcoded default GPU targets regardless of what was specified via environment or CI inputs. Signed-off-by: Russell Sim <rsl@simopolis.xyz> --------- Signed-off-by: Russell Sim <rsl@simopolis.xyz>
1 parent b1a9943 commit 18e039f

6 files changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
skip-drivers: ${{ matrix.skip-drivers }}
3131
context: ${{ matrix.context }}
3232
ubuntu-version: ${{ matrix.ubuntu-version }}
33-
amdgpu-targets: ${{ matrix.amdgpu-targets }}
33+
amdgpu-targets: ${{ matrix.amdgpu-targets || 'gfx908,gfx90a,gfx942,gfx950,gfx1030,gfx1100,gfx1101,gfx1102,gfx1151,gfx1200,gfx1201' }}
3434
secrets:
3535
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
3636
dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}

.github/workflows/backend_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ on:
6161
amdgpu-targets:
6262
description: 'AMD GPU targets for ROCm/HIP builds'
6363
required: false
64-
default: 'gfx908,gfx90a,gfx942,gfx950,gfx1030,gfx1100,gfx1101,gfx1102,gfx1151,gfx1200,gfx1201'
64+
default: ''
6565
type: string
6666
secrets:
6767
dockerUsername:

.github/workflows/backend_pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
skip-drivers: ${{ matrix.skip-drivers }}
5454
context: ${{ matrix.context }}
5555
ubuntu-version: ${{ matrix.ubuntu-version }}
56+
amdgpu-targets: ${{ matrix.amdgpu-targets || 'gfx908,gfx90a,gfx942,gfx950,gfx1030,gfx1100,gfx1101,gfx1102,gfx1151,gfx1200,gfx1201' }}
5657
secrets:
5758
quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
5859
quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ define docker-build-backend
10511051
--build-arg UBUNTU_VERSION=$(UBUNTU_VERSION) \
10521052
--build-arg UBUNTU_CODENAME=$(UBUNTU_CODENAME) \
10531053
$(if $(FROM_SOURCE),--build-arg FROM_SOURCE=$(FROM_SOURCE)) \
1054+
$(if $(AMDGPU_TARGETS),--build-arg AMDGPU_TARGETS=$(AMDGPU_TARGETS)) \
10541055
$(if $(filter true,$(5)),--build-arg BACKEND=$(1)) \
10551056
-t local-ai-backend:$(1) -f backend/Dockerfile.$(2) $(3)
10561057
endef

backend/Dockerfile.golang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ ARG TARGETARCH
1414
ARG TARGETVARIANT
1515
ARG GO_VERSION=1.25.4
1616
ARG UBUNTU_VERSION=2404
17+
ARG AMDGPU_TARGETS
18+
ENV AMDGPU_TARGETS=${AMDGPU_TARGETS}
1719

1820
RUN apt-get update && \
1921
apt-get install -y --no-install-recommends \

backend/cpp/llama-cpp/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ else ifeq ($(BUILD_TYPE),hipblas)
3434
export CXX=$(ROCM_HOME)/llvm/bin/clang++
3535
export CC=$(ROCM_HOME)/llvm/bin/clang
3636
AMDGPU_TARGETS?=gfx908,gfx90a,gfx942,gfx950,gfx1030,gfx1100,gfx1101,gfx1102,gfx1151,gfx1200,gfx1201
37+
ifeq ($(strip $(AMDGPU_TARGETS)),)
38+
$(error AMDGPU_TARGETS is empty — set it to a comma-separated list of gfx targets e.g. gfx1100,gfx1101)
39+
endif
3740
CMAKE_ARGS+=-DGGML_HIP=ON -DAMDGPU_TARGETS=$(AMDGPU_TARGETS)
3841
else ifeq ($(BUILD_TYPE),vulkan)
3942
CMAKE_ARGS+=-DGGML_VULKAN=1

0 commit comments

Comments
 (0)