-
Notifications
You must be signed in to change notification settings - Fork 78
331 lines (304 loc) · 12.2 KB
/
Copy pathjax-vllm-offloading.yml
File metadata and controls
331 lines (304 loc) · 12.2 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: JAX-vLLM offloading
on:
schedule:
- cron: '30 9 * * *' # Pacific Time 01:30 AM in UTC
pull_request:
types:
- opened
- reopened
- ready_for_review
- synchronize
paths:
- 'jax-inference-offloading/**'
- '.github/gke-workflow/jax-vllm-offloading/**'
- '.github/workflows/jax-vllm-offloading*.yml'
workflow_dispatch:
inputs:
PUBLISH:
type: boolean
description: Publish dated images and update the 'latest' tag?
default: false
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read # to fetch code
actions: write # to cancel previous workflows
packages: write # to upload containers
jobs:
metadata:
runs-on: ubuntu-22.04
outputs:
BUILD_DATE: ${{ steps.date.outputs.BUILD_DATE }}
PUBLISH: ${{ steps.if-publish.outputs.PUBLISH }}
steps:
- name: Set build date
id: date
shell: bash -x -e {0}
run: |
BUILD_DATE=$(TZ='US/Los_Angeles' date '+%Y-%m-%d')
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
- name: Determine whether results will be 'published'
id: if-publish
shell: bash -x -e {0}
run: |
echo "PUBLISH=${{ github.event_name == 'schedule' || inputs.PUBLISH }}" >> $GITHUB_OUTPUT
amd64:
needs: metadata
runs-on: [self-hosted, amd64, small]
outputs:
DOCKER_TAG_MEALKIT: ${{ steps.build-container.outputs.DOCKER_TAG_MEALKIT }}
DOCKER_TAG_FINAL: ${{ steps.build-container.outputs.DOCKER_TAG_FINAL }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Build container
id: build-container
uses: ./.github/actions/build-container
with:
ARCHITECTURE: amd64
ARTIFACT_NAME: artifact-jio-build
BADGE_FILENAME: badge-jio-build
BASE_IMAGE: nvcr.io/nvidia/cuda-dl-base:26.05-cuda13.2-devel-ubuntu24.04
BUILD_DATE: ${{ needs.metadata.outputs.BUILD_DATE }}
CONTAINER_NAME: jio
DOCKERFILE: jax-inference-offloading/dockerfile/oss.dockerfile
RUNNER_SIZE: small
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
EXTRA_BUILD_ARGS: |
REF_JIO=${{ github.ref }}
arm64:
needs: metadata
runs-on: [self-hosted, arm64, small]
outputs:
DOCKER_TAG_MEALKIT: ${{ steps.build-container.outputs.DOCKER_TAG_MEALKIT }}
DOCKER_TAG_FINAL: ${{ steps.build-container.outputs.DOCKER_TAG_FINAL }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Build container
id: build-container
uses: ./.github/actions/build-container
with:
ARCHITECTURE: arm64
ARTIFACT_NAME: artifact-jio-build
BADGE_FILENAME: badge-jio-build
BASE_IMAGE: nvcr.io/nvidia/cuda-dl-base:26.05-cuda13.2-devel-ubuntu24.04
BUILD_DATE: ${{ needs.metadata.outputs.BUILD_DATE }}
CONTAINER_NAME: jio
DOCKERFILE: jax-inference-offloading/dockerfile/oss.dockerfile
RUNNER_SIZE: small
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
EXTRA_BUILD_ARGS: |
REF_JIO=${{ github.ref }}
collect-docker-tags:
runs-on: ubuntu-22.04
if: ${{ !cancelled() }}
needs:
- amd64
- arm64
outputs:
TAGS: ${{ steps.collect-tags.outputs.TAGS }}
steps:
- name: Save docker tags as a JSON object
id: collect-tags
run: |
TAGS=$(cat <<EOF | jq -c
[\
{"flavor": "jax-inference-offloading", "stage": "final", "priority": 900, "tag": "${{ needs.amd64.outputs.DOCKER_TAG_FINAL }}"},\
{"flavor": "jax-inference-offloading-mealkit", "stage": "mealkit", "priority": 500, "tag": "${{ needs.amd64.outputs.DOCKER_TAG_MEALKIT }}"},\
{"flavor": "jax-inference-offloading", "stage": "final", "priority": 900, "tag": "${{ needs.arm64.outputs.DOCKER_TAG_FINAL }}"},\
{"flavor": "jax-inference-offloading-mealkit", "stage": "mealkit", "priority": 500, "tag": "${{ needs.arm64.outputs.DOCKER_TAG_MEALKIT }}"},\
{}\
]
EOF
)
echo "TAGS=${TAGS}" >> $GITHUB_OUTPUT
make-publish-configs:
runs-on: ubuntu-22.04
if: ${{ !cancelled() }}
env:
IMAGE_REPO: ${{ needs.metadata.outputs.PUBLISH == 'true' && 'jax' || 'mock-jax' }}
needs:
- metadata
- collect-docker-tags
outputs:
PUBLISH_CONFIGS: ${{ steps.generate-configs.outputs.PUBLISH_CONFIGS }}
steps:
- id: generate-configs
shell: bash -eu -o pipefail {0}
run: |
declare -a FLAVORS=(
jax-inference-offloading
jax-inference-offloading-mealkit
)
## create JSON specs for a 1D matrix of container publication jobs
ALL_TAGS=$(
echo '${{ needs.collect-docker-tags.outputs.TAGS }}' | jq -s 'add'
)
PUBLISH_CONFIGS='[]'
for flavor in "${FLAVORS[@]}";do
# collect images for different platforms, e.g. amd64 and arm64
matching_tags=$(
echo "$ALL_TAGS" |\
jq -c ".[] | select(.flavor == \"${flavor}\" and .tag != \"\")"
)
# source_image is a list of all platform-specific tags
source_image=$(echo "${matching_tags}" | jq -c "[.tag]" | jq -s 'add')
# if the build job failed without producing any images, skip this flavor
n_source_images=$(echo "$source_image" | jq 'length')
if [[ $n_source_images -gt 0 ]]; then
# Determine stage from flavor name
if [[ "${flavor}" == *"-mealkit" ]]; then
stage="mealkit"
else
stage="final"
fi
echo "PUBLISH image $flavor with $n_source_images containers"
# tag priority is the highest priority of all platform-specific tags
priority=$(echo "${matching_tags}" | jq -r ".priority" | jq -s 'max')
# All images go to the same repository (jax or mock-jax)
target_image=${IMAGE_REPO}
PUBLISH_CONFIGS=$(
echo ${PUBLISH_CONFIGS} | jq -c ". + [{
\"flavor\": \"${flavor}\",
\"target_image\": \"${target_image}\",
\"priority\": \"${priority}\",
\"source_image\": ${source_image},
\"stage\": \"${stage}\"
}]"
)
else
echo "SKIPPED image $flavor with 0 containers"
fi
done
PUBLISH_CONFIGS=$(echo "$PUBLISH_CONFIGS" | jq -c '{"config": .}')
echo ${PUBLISH_CONFIGS} | jq
echo "PUBLISH_CONFIGS=${PUBLISH_CONFIGS}" >> $GITHUB_OUTPUT
publish-containers:
needs:
- metadata
- make-publish-configs
if: ${{ !cancelled() && needs.make-publish-configs.outputs.PUBLISH_CONFIGS.config != '{"config":[]}' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.make-publish-configs.outputs.PUBLISH_CONFIGS) }}
uses: ./.github/workflows/_publish_container.yaml
with:
ARTIFACT_NAME: ${{ matrix.config.stage }}-${{ matrix.config.flavor }}
ARTIFACT_TAG: ${{ matrix.config.flavor }}-${{ needs.metadata.outputs.BUILD_DATE }}
SOURCE_IMAGE: ${{ join(matrix.config.source_image, ' ') }}
TARGET_IMAGE: ${{ matrix.config.target_image }}
TARGET_TAGS: |
type=raw,value=${{ matrix.config.flavor }},priority=${{ matrix.config.priority }}
type=raw,value=${{ matrix.config.flavor }}-${{ needs.metadata.outputs.BUILD_DATE }},priority=${{ matrix.config.priority }}
finalize:
needs: [metadata, amd64, arm64, publish-containers]
if: "!cancelled()"
uses: ./.github/workflows/_finalize.yaml
with:
BUILD_DATE: ${{ needs.metadata.outputs.BUILD_DATE }}
PUBLISH_BADGE: ${{ needs.metadata.outputs.PUBLISH == 'true' }}
secrets: inherit
jio-decoupled-sync-8b-gke-smoke:
needs: amd64
runs-on: gke-a3mega
steps:
- uses: actions/checkout@v6
- name: Run JIO decoupled sync 8B smoke
uses: ./.github/actions/gke-xpk
with:
NAME: jio-dec-sync-8b
IMAGE: ${{ needs.amd64.outputs.DOCKER_TAG_FINAL }}
NUM_NODES: 1
ENVS: |
CUDA_VISIBLE_DEVICES=0,1,2,3;
JIO_RESPONSE_TOPIC=inference/results/shared;
MODEL_NAME=meta-llama/Llama-3.1-8B-Instruct;
NCCL_CUMEM_ENABLE=0;
NCCL_DEBUG=INFO;
NCCL_DEBUG_SUBSYS=INIT,ENV,NET;
COMMAND: |
set -x;
python -m pip install --upgrade huggingface-hub==1.17.0;
MODEL_PATH=\$(hf download \${MODEL_NAME} --quiet);
cd /opt/jtbx/jax-inference-offloading/examples/decoupled_synchronous;
timeout --kill-after=30s 900s bash ./decoupled_sync.sh \
--model-path=\${MODEL_PATH} \
--param-mapping-path=../mappings/llama3_8b_param_mapping.json \
--num-iterations=1 \
--transfer-mode=grouped \
--n-gpus-vllm=2 \
--n-gpus-jax=2 \
--vllm-enforce-eager \
--vllm-gpu-memory-utilization=0.7 \
--output-dir=/opt/output/jio-decoupled-sync-8b;
EXIT_CODE=\$?;
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NVCR_TOKEN: ${{ secrets.NVCR_TOKEN }}
# TODO: Port these legacy 8B/70B transfer, GRPO, and EKS checks to the
# current JIO example structure before re-enabling them.
#
# transfer-gke-xpk:
# uses: ./.github/workflows/jax-vllm-offloading-gke-transfer.yml
# needs: amd64
# with:
# JAX_VLLM_OFFLOADING_IMAGE: ${{ needs.amd64.outputs.DOCKER_TAG_FINAL }}
# secrets: inherit
#
# grpo-gke-xpk:
# uses: ./.github/workflows/jax-vllm-offloading-gke-grpo.yml
# needs: amd64
# with:
# JAX_VLLM_OFFLOADING_IMAGE: ${{ needs.amd64.outputs.DOCKER_TAG_FINAL }}
# secrets: inherit
#
# jax-vllm-offloading-transfer-eks:
# needs: amd64
# runs-on: eks
# env:
# JOB_NAME: jax-vllm-offloading-${{ github.run_id }}
# JAX_VLLM_OFFLOADING_IMAGE: ${{ needs.amd64.outputs.DOCKER_TAG_FINAL }}
# MODEL: "meta-llama/Llama-3.1-8B-Instruct"
#
# steps:
# - uses: actions/checkout@v6
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v4
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: K8s GHCR store and delete token
# id: store-token
# uses: ./.github/actions/store-delete-k8s-ghcr
#
# - name: Configure jax-vllm job
# run: |
# yq -i '
# # 1. Update the JobSet Name
# .metadata.name = strenv(JOB_NAME)
#
# # 2. Update Image (Applies to Gateway, vLLM, and JAX nodes)
# | .spec.replicatedJobs[].template.spec.template.spec.containers[].image = strenv(JAX_VLLM_OFFLOADING_IMAGE)
#
# # 3. Update Model Name (Finds the env var named "MODEL_NAME" and updates its value)
# | (.spec.replicatedJobs[].template.spec.template.spec.containers[].env[] | select(.name == "MODEL_NAME").value) = strenv(MODEL)
#
# # 4. Add imagePullSecrets to all replicatedJobs (Gateway, vLLM, and JAX nodes)
# | .spec.replicatedJobs[].template.spec.template.spec.imagePullSecrets[].name = "${{ steps.store-token.outputs.token-name }}"
# ' .github/eks-workflow-files/jio-eks/jio-template.yaml
# git diff .github/eks-workflow-files/jio-eks/jio-template.yaml
#
# - name: Apply jax-vllm offloading job to EKS cluster
# uses: ./.github/actions/submit-delete-k8s-jobset
# with:
# jobset-config-file: ".github/eks-workflow-files/jio-eks/jio-template.yaml"
# jobset-name: ${{ env.JOB_NAME }}