Skip to content

Commit 6096c9d

Browse files
committed
feat(sycl): Add sycl support (#1647)
1 parent abd678e commit 6096c9d

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

.github/workflows/image-pr.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ jobs:
7575
ffmpeg: 'true'
7676
image-type: 'core'
7777
runs-on: 'ubuntu-latest'
78+
- build-type: 'sycl_f16'
79+
platforms: 'linux/amd64'
80+
tag-latest: 'false'
81+
tag-suffix: 'sycl-f16-ffmpeg-core'
82+
ffmpeg: 'true'
83+
image-type: 'core'
84+
runs-on: 'ubuntu-latest'
7885
- build-type: 'cublas'
7986
cuda-major-version: "12"
8087
cuda-minor-version: "1"

.github/workflows/image.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,34 @@ jobs:
122122
ffmpeg: 'true'
123123
image-type: 'core'
124124
runs-on: 'ubuntu-latest'
125+
- build-type: 'sycl_f16'
126+
platforms: 'linux/amd64'
127+
tag-latest: 'false'
128+
tag-suffix: 'sycl-f16-core'
129+
ffmpeg: 'false'
130+
image-type: 'core'
131+
runs-on: 'ubuntu-latest'
132+
- build-type: 'sycl_f32'
133+
platforms: 'linux/amd64'
134+
tag-latest: 'false'
135+
tag-suffix: 'sycl-f32-core'
136+
ffmpeg: 'false'
137+
image-type: 'core'
138+
runs-on: 'ubuntu-latest'
139+
- build-type: 'sycl_f16'
140+
platforms: 'linux/amd64'
141+
tag-latest: 'false'
142+
tag-suffix: 'sycl-f16-ffmpeg-core'
143+
ffmpeg: 'true'
144+
image-type: 'core'
145+
runs-on: 'ubuntu-latest'
146+
- build-type: 'sycl_f32'
147+
platforms: 'linux/amd64'
148+
tag-latest: 'false'
149+
tag-suffix: 'sycl-f32-ffmpeg-core'
150+
ffmpeg: 'true'
151+
image-type: 'core'
152+
runs-on: 'ubuntu-latest'
125153
- build-type: 'cublas'
126154
cuda-major-version: "11"
127155
cuda-minor-version: "7"

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ ARG GO_VERSION=1.21-bullseye
22
ARG IMAGE_TYPE=extras
33
# extras or core
44

5-
65
FROM golang:$GO_VERSION as requirements-core
76

87
ARG BUILD_TYPE
@@ -38,6 +37,11 @@ RUN if [ "${BUILD_TYPE}" = "cublas" ]; then \
3837
apt-get update && \
3938
apt-get install -y cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcusolver-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} && apt-get clean \
4039
; fi
40+
# oneapi requirements
41+
RUN if [ "${BUILD_TYPE}" = "sycl_f16" ] || [ "${BUILD_TYPE}" = "sycl_f32" ]; then \
42+
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/163da6e4-56eb-4948-aba3-debcec61c064/l_BaseKit_p_2024.0.1.46_offline.sh && \
43+
sh ./l_BaseKit_p_2024.0.1.46_offline.sh \
44+
; fi
4145
ENV PATH /usr/local/cuda/bin:${PATH}
4246

4347
# OpenBLAS requirements and stable diffusion

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ ifeq ($(BUILD_TYPE),hipblas)
111111
CGO_LDFLAGS += -O3 --rtlib=compiler-rt -unwindlib=libgcc -lhipblas -lrocblas --hip-link
112112
endif
113113

114+
ifeq ($(BUILD_TYPE),sycl_f16)
115+
CMAKE_ARGS+=-DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_SYCL_F16=ON
116+
endif
117+
118+
ifeq ($(BUILD_TYPE),sycl_f32)
119+
CMAKE_ARGS+=-DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
120+
endif
121+
114122
ifeq ($(BUILD_TYPE),metal)
115123
CGO_LDFLAGS+=-framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders
116124
export LLAMA_METAL=1

backend/cpp/llama/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ LLAMA_VERSION?=
33

44
CMAKE_ARGS?=
55
BUILD_TYPE?=
6+
ONEAPI_VARS?=/opt/intel/oneapi/setvars.sh
67

78
# If build type is cublas, then we set -DLLAMA_CUBLAS=ON to CMAKE_ARGS automatically
89
ifeq ($(BUILD_TYPE),cublas)
@@ -49,5 +50,10 @@ clean:
4950
rm -rf grpc-server
5051

5152
grpc-server: llama.cpp llama.cpp/examples/grpc-server
53+
ifneq (,$(findstring sycl,$(BUILD_TYPE)))
54+
source $(ONEAPI_VARS) && \
55+
cd llama.cpp && mkdir -p build && cd build && cmake .. $(CMAKE_ARGS) && cmake --build . --config Release
56+
else
5257
cd llama.cpp && mkdir -p build && cd build && cmake .. $(CMAKE_ARGS) && cmake --build . --config Release
58+
endif
5359
cp llama.cpp/build/bin/grpc-server .

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ if [ -n "$EXTRA_BACKENDS" ]; then
1313
done
1414
fi
1515

16+
if [ -e "/opt/intel/oneapi/setvars.sh"]; then
17+
source /opt/intel/oneapi/setvars.sh
18+
fi
19+
1620
if [ "$REBUILD" != "false" ]; then
1721
rm -rf ./local-ai
1822
make build -j${BUILD_PARALLELISM:-1}

0 commit comments

Comments
 (0)