-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (163 loc) · 6.58 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: PJRT GPU library
on:
push:
tags:
- '*'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
pjrt-osx-artifacts:
strategy:
matrix:
pjrt:
- target: cpu
config: "--config=release_macos_arm64"
artifact: bazel-bin/xla/pjrt/c/libpjrt_c_api_cpu_plugin.dylib
runs_on: ['self-hosted', 'macOS']
platform: darwin-arm64
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
runs-on: ${{ matrix.pjrt.runs_on }}
steps:
- name: "Checking out repository"
uses: actions/checkout@v4
with:
path: 'pjrt-artifacts'
- name: Extract OpenXLA commit id
id: extract
run: |
commitid=`grep "OPENXLA_COMMIT = " ./pjrt-artifacts/third_party/openxla/xla.bzl | awk -F ' = ' '{print $2}' | sed 's/"//g'`
echo "commitid=$commitid" >> $GITHUB_OUTPUT
- name: "Checking out openxla repository"
uses: actions/checkout@v4
with:
repository: openxla/xla
path: 'xla'
ref: ${{ steps.extract.outputs.commitid }}
- name: Apply patches
working-directory: ./xla
run: |
for patch in $(ls ../pjrt-artifacts/third_party/openxla/patches/*.patch | sort); do
echo "Applying patch $patch"
git apply "$patch"
done
- name: Setup Bazel
run: |
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O /usr/local/bin/bazel
chmod +x /usr/local/bin/bazel
- name: "Build ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }}"
working-directory: ./xla
run: |
bazelisk \
build \
--disk_cache=/tmp/cache \
${{ matrix.pjrt.config }} \
${{ matrix.pjrt.bazel_target }}
- name: Strip binary and rpath
working-directory: ./xla
run: |
strip -x -o libpjrt_cpu.dylib ${{ matrix.pjrt.artifact }}
install_name_tool -id '@rpath/libpjrt_cpu.dylib' libpjrt_cpu.dylib
- name: Create compressed ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} release file
uses: a7ul/[email protected]
with:
command: c
cwd: ./xla
files: |
./libpjrt_cpu.dylib
outPath: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
- name: Upload ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts
uses: actions/upload-artifact@v4
with:
name: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
path: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
pjrt-artifacts:
strategy:
matrix:
pjrt:
- target: cuda
config: "--config=cuda"
artifact: libpjrt_c_api_gpu_plugin.so
renamed_artifact: libpjrt_cuda.so
runs_on: ['runs-on','runner=32cpu-linux-x64', 'image=ubuntu24-amd64']
platform: linux-amd64
bazel_target: //xla/pjrt/c:pjrt_c_api_gpu_plugin
- target: rocm
config: "--config=rocm"
artifact: libpjrt_c_api_gpu_plugin.so
renamed_artifact: libpjrt_rocm.so
runs_on: ['runs-on','runner=32cpu-linux-x64', 'image=ubuntu24-amd64']
platform: linux-amd64
bazel_target: //xla/pjrt/c:pjrt_c_api_gpu_plugin
- target: cpu
config: ""
artifact: libpjrt_c_api_cpu_plugin.so
renamed_artifact: libpjrt_cpu.so
runs_on: ['runs-on','runner=32cpu-linux-x64', 'image=ubuntu24-amd64']
platform: linux-amd64
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
runs-on: ${{ matrix.pjrt.runs_on }}
steps:
- name: "Checking out repository"
uses: actions/checkout@v4
- name: Setup Bazel
run: |
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O ~/bin/bazel
chmod +x ~/bin/bazel
- name: Force remove container
run: |
docker rm -f pjrt-${{ matrix.pjrt.target }}
- name: "Build ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} image"
run: |
~/bin/bazel run //${{ matrix.pjrt.target }}:${{ matrix.pjrt.target }}_stripped_tarball
- name: "Run ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} image"
run: |
docker run \
--name=pjrt-${{ matrix.pjrt.target }} \
-w=/xla \
--net=host \
-v=/tmp/cache:/tmp/cache \
distroless/${{ matrix.pjrt.target }}_builder:latest \
bazelisk \
build \
--remote_cache=grpc://127.0.0.1:15501 \
--disk_cache=/tmp/cache \
${{ matrix.pjrt.config }} \
${{ matrix.pjrt.bazel_target }}
- name: "Retrieve ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts"
run: |
docker cp pjrt-${{ matrix.pjrt.target }}:/xla/bazel-bin/xla/pjrt/c/${{ matrix.pjrt.artifact }} ${{ matrix.pjrt.renamed_artifact }}
docker rm -f pjrt-${{ matrix.pjrt.target }}
- name: Create compressed ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} release file
uses: a7ul/[email protected]
with:
command: c
cwd: .
files: |
./${{ matrix.pjrt.renamed_artifact }}
outPath: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
- name: Upload ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts
uses: actions/upload-artifact@v4
with:
name: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
path: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
release:
needs: ["pjrt-artifacts","pjrt-osx-artifacts"]
runs-on: ['runs-on','runner=2cpu-linux-x64']
steps:
- run: rm -rf pjrt*.tar.gz
- name: Download all artifacts
uses: actions/download-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
pjrt-rocm_linux-amd64.tar.gz/pjrt-rocm_linux-amd64.tar.gz
pjrt-cuda_linux-amd64.tar.gz/pjrt-cuda_linux-amd64.tar.gz
pjrt-cpu_linux-amd64.tar.gz/pjrt-cpu_linux-amd64.tar.gz
pjrt-cpu_darwin-arm64.tar.gz/pjrt-cpu_darwin-arm64.tar.gz