Skip to content

Commit c163caa

Browse files
committed
revamp the workflow in preparation for nightly runs
1 parent 35dd8ef commit c163caa

20 files changed

+79
-191
lines changed

.github/workflows/build.yaml

Lines changed: 79 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
tags:
55
- "*"
66
pull_request:
7+
workflow_dispatch:
8+
inputs:
9+
xla_commit:
10+
required: true
11+
type: string
12+
default: "main"
713

814
concurrency:
915
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -12,98 +18,49 @@ concurrency:
1218
permissions:
1319
contents: write
1420

15-
jobs:
16-
pjrt-osx-artifacts:
17-
strategy:
18-
matrix:
19-
pjrt:
20-
- target: cpu
21-
config: "--config=release_macos_base"
22-
artifact: bazel-bin/xla/pjrt/c/libpjrt_c_api_cpu_plugin.dylib
23-
runs_on: ["macos-14"]
24-
platform: darwin-amd64
25-
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
26-
- target: cpu
27-
config: "--config=release_macos_arm64"
28-
artifact: bazel-bin/xla/pjrt/c/libpjrt_c_api_cpu_plugin.dylib
29-
runs_on: ["self-hosted", "macOS"]
30-
platform: darwin-arm64
31-
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
21+
env:
22+
XLA_COMMIT: ${{ inputs.xla_commit || 'cc075beb6148c2777da2b6749c63830856ee6c2a' }}
3223

33-
runs-on: ${{ matrix.pjrt.runs_on }}
24+
jobs:
25+
setup_openxla:
26+
runs-on: ubuntu-latest
3427
steps:
3528
- name: "Checking out repository"
3629
uses: actions/checkout@v4
3730
with:
3831
path: "pjrt-artifacts"
39-
40-
- name: Extract OpenXLA commit id
41-
id: extract
42-
run: |
43-
commitid=`grep "OPENXLA_COMMIT = " ./pjrt-artifacts/third_party/openxla/xla.bzl | awk -F ' = ' '{print $2}' | sed 's/"//g'`
44-
echo "commitid=$commitid" >> $GITHUB_OUTPUT
45-
4632
- name: "Checking out openxla repository"
4733
uses: actions/checkout@v4
4834
with:
35+
ref: ${{ env.XLA_COMMIT }}
4936
repository: openxla/xla
5037
path: "xla"
51-
ref: ${{ steps.extract.outputs.commitid }}
52-
53-
- name: Apply patches
38+
- name: Apply patches to openxla
5439
working-directory: ./xla
5540
run: |
56-
for patch in $(ls ../pjrt-artifacts/third_party/openxla/patches/*.patch | sort); do
41+
echo "::notice Applying patches to openxla ${{ github.sha }}"
42+
43+
for patch in $(ls ../pjrt-artifacts/openxla/patches/*.patch | sort); do
5744
echo "Applying patch $patch"
5845
git apply "$patch"
5946
done
60-
61-
- name: Setup Bazel
62-
if: ${{ contains(matrix.pjrt.runs_on, 'self-hosted') }} # Run only for self-hosted macOS
63-
run: |
64-
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O /usr/local/bin/bazel
65-
chmod +x /usr/local/bin/bazel
66-
67-
- name: "Build ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }}"
68-
working-directory: ./xla
69-
run: |
70-
bazelisk \
71-
build \
72-
--disk_cache=/tmp/cache \
73-
${{ matrix.pjrt.config }} \
74-
${{ matrix.pjrt.bazel_target }}
75-
76-
- name: Strip binary and rpath
77-
working-directory: ./xla
78-
run: |
79-
strip -x -o libpjrt_cpu.dylib ${{ matrix.pjrt.artifact }}
80-
install_name_tool -id '@rpath/libpjrt_cpu.dylib' libpjrt_cpu.dylib
81-
82-
- name: Create compressed ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} release file
83-
uses: a7ul/tar-action@v1.2.0
84-
with:
85-
command: c
86-
cwd: ./xla
87-
files: |
88-
./libpjrt_cpu.dylib
89-
outPath: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
90-
91-
- name: Upload ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts
47+
- name: Upload openxla repository artifact
9248
uses: actions/upload-artifact@v4
9349
with:
94-
name: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
95-
path: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
50+
include-hidden-files: true
51+
name: xla-${{ env.XLA_COMMIT }}
52+
path: ./xla
9653

9754
pjrt-artifacts:
55+
runs-on: ${{ matrix.pjrt.runs_on }}
9856
strategy:
9957
matrix:
10058
pjrt:
10159
- target: cuda
10260
config: "--config=cuda"
10361
artifact: libpjrt_c_api_gpu_plugin.so
10462
renamed_artifact: libpjrt_cuda.so
105-
runs_on:
106-
["runs-on", "runner=32cpu-linux-x64", "image=ubuntu24-amd64"]
63+
runs_on: ["self-hosted", "Linux", "X64"]
10764
platform: linux-amd64
10865
bazel_target: //xla/pjrt/c:pjrt_c_api_gpu_plugin
10966
- target: rocm
@@ -114,6 +71,13 @@ jobs:
11471
["runs-on", "runner=32cpu-linux-x64", "image=ubuntu24-amd64"]
11572
platform: linux-amd64
11673
bazel_target: //xla/pjrt/c:pjrt_c_api_gpu_plugin
74+
- target: cpu
75+
config: "--config=release_macos_arm64"
76+
artifact: bazel-bin/xla/pjrt/c/libpjrt_c_api_cpu_plugin.dylib
77+
runs_on: ["self-hosted", "macOS"]
78+
renamed_artifact: libpjrt_cpu.dylib
79+
platform: darwin-arm64
80+
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
11781
- target: cpu
11882
config: ""
11983
artifact: libpjrt_c_api_cpu_plugin.so
@@ -122,66 +86,105 @@ jobs:
12286
["runs-on", "runner=32cpu-linux-x64", "image=ubuntu24-amd64"]
12387
platform: linux-amd64
12488
bazel_target: //xla/pjrt/c:pjrt_c_api_cpu_plugin
125-
runs-on: ${{ matrix.pjrt.runs_on }}
89+
needs: ["setup_openxla"]
12690
steps:
12791
- name: "Checking out repository"
12892
uses: actions/checkout@v4
93+
with:
94+
path: "pjrt-artifacts"
95+
96+
- name: Download xla artifact
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: xla-${{ env.XLA_COMMIT }}
100+
path: xla
101+
129102
- name: Setup Bazel
130103
run: |
131-
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O ~/bin/bazel
104+
mkdir -p ~/bin/
105+
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-${{ matrix.pjrt.platform }} -O ~/bin/bazel
132106
chmod +x ~/bin/bazel
133-
- name: Force remove container
107+
108+
- name: "Setup bazelrc for openxla"
134109
run: |
135-
docker rm -f pjrt-${{ matrix.pjrt.target }}
110+
cp pjrt-artifacts/openxla/bazelrc/common.bazelrc xla/
111+
cp pjrt-artifacts/openxla/bazelrc/${{ matrix.pjrt.target }}.bazelrc xla/xla_configure.bazelrc
112+
136113
- name: "Build ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} image"
114+
if: matrix.pjrt.target != 'cpu'
115+
working-directory: ./pjrt-artifacts
137116
run: |
117+
docker rm -f pjrt-${{ matrix.pjrt.target }}
138118
~/bin/bazel run //${{ matrix.pjrt.target }}:${{ matrix.pjrt.target }}_stripped_tarball
119+
139120
- name: "Run ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} image"
121+
if: matrix.pjrt.target != 'cpu'
140122
run: |
141123
docker run \
142124
--name=pjrt-${{ matrix.pjrt.target }} \
143125
-w=/xla \
144126
--net=host \
127+
-v=$(pwd)/xla:/xla \
145128
-v=/tmp/cache:/tmp/cache \
146129
distroless/${{ matrix.pjrt.target }}_builder:latest \
147130
bazelisk \
148131
build \
149-
--remote_cache=grpc://127.0.0.1:15501 \
150132
--disk_cache=/tmp/cache \
151133
${{ matrix.pjrt.config }} \
152134
${{ matrix.pjrt.bazel_target }}
135+
153136
- name: "Retrieve ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts"
137+
if: matrix.pjrt.target != 'cpu'
154138
run: |
155139
docker cp pjrt-${{ matrix.pjrt.target }}:/xla/bazel-bin/xla/pjrt/c/${{ matrix.pjrt.artifact }} ${{ matrix.pjrt.renamed_artifact }}
156140
docker rm -f pjrt-${{ matrix.pjrt.target }}
141+
142+
- name: "Build ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }}"
143+
if: matrix.pjrt.target == 'cpu'
144+
working-directory: ./xla
145+
run: |
146+
~/bin/bazel \
147+
build \
148+
--disk_cache=/tmp/cache \
149+
${{ matrix.pjrt.config }} \
150+
${{ matrix.pjrt.bazel_target }}
151+
152+
- name: Strip binary and rpath
153+
if: matrix.pjrt.target == 'cpu'
154+
working-directory: ./xla
155+
run: |
156+
strip -x -o libpjrt_cpu.dylib ${{ matrix.pjrt.artifact }}
157+
install_name_tool -id '@rpath/libpjrt_cpu.dylib' libpjrt_cpu.dylib
158+
157159
- name: Create compressed ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} release file
158160
uses: a7ul/tar-action@v1.2.0
159161
with:
160162
command: c
161-
cwd: .
163+
cwd: ./
162164
files: |
163165
./${{ matrix.pjrt.renamed_artifact }}
164166
outPath: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
167+
165168
- name: Upload ${{ matrix.pjrt.target }} ${{ matrix.pjrt.platform }} artifacts
166169
uses: actions/upload-artifact@v4
167170
with:
168171
name: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
169172
path: pjrt-${{ matrix.pjrt.target }}_${{ matrix.pjrt.platform }}.tar.gz
170173

171174
release:
172-
needs: ["pjrt-artifacts", "pjrt-osx-artifacts"]
173-
runs-on: ["runs-on", "runner=2cpu-linux-x64"]
174-
if: startsWith(github.ref, 'refs/tags/')
175+
needs: ["pjrt-artifacts"]
176+
runs-on: ubuntu-latest
175177
steps:
176178
- run: rm -rf pjrt*.tar.gz
177179
- name: Download all artifacts
178180
uses: actions/download-artifact@v4
181+
if: startsWith(github.ref, 'refs/tags/')
179182
- name: Release
180183
uses: softprops/action-gh-release@v2
184+
if: startsWith(github.ref, 'refs/tags/')
181185
with:
182186
files: |
183-
pjrt-cpu_darwin-arm64.tar.gz/pjrt-cpu_darwin-arm64.tar.gz
184-
pjrt-cpu_darwin-amd64.tar.gz/pjrt-cpu_darwin-amd64.tar.gz
185187
pjrt-rocm_linux-amd64.tar.gz/pjrt-rocm_linux-amd64.tar.gz
186188
pjrt-cuda_linux-amd64.tar.gz/pjrt-cuda_linux-amd64.tar.gz
187189
pjrt-cpu_linux-amd64.tar.gz/pjrt-cpu_linux-amd64.tar.gz
190+
pjrt-cpu_darwin-arm64.tar.gz/pjrt-cpu_darwin-arm64.tar.gz

cpu/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ oci_image(
6565
"//base/jammy:packages",
6666
":strip_packages",
6767
":symlinks",
68-
"//third_party/openxla:openxla_tar",
69-
"//third_party/openxla:cpu_configuration_tar",
7068
],
7169
env = {
7270
"MAX_NUM_WORKERS": -1,

cuda/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ oci_image(
6767
"//base/noble:bazelisk",
6868
":strip_packages",
6969
":symlinks",
70-
"//third_party/openxla:openxla_tar",
71-
"//third_party/openxla:cuda_configuration_tar",
7270
],
7371
env = {
7472
"MAX_NUM_WORKERS": -1,

openxla/bazelrc/cpu.bazelrc

Whitespace-only changes.

third_party/openxla/patches/20240131-001-Expose-PJRT-mlir_to_hlo-to-public.patch renamed to openxla/patches/20240131-001-Expose-PJRT-mlir_to_hlo-to-public.patch

File renamed without changes.

third_party/openxla/patches/20240318-001-PJRT-C-API-Ensure-C-compliance-for-Profiler-Extension.patch renamed to openxla/patches/20240318-001-PJRT-C-API-Ensure-C-compliance-for-Profiler-Extension.patch

File renamed without changes.

third_party/openxla/patches/20240901-001-Do-not-force-DEVELOPER_DIR-on-macOS.patch renamed to openxla/patches/20240901-001-Do-not-force-DEVELOPER_DIR-on-macOS.patch

File renamed without changes.

0 commit comments

Comments
 (0)