-
Notifications
You must be signed in to change notification settings - Fork 59
215 lines (193 loc) · 9.27 KB
/
build_dev.yaml
File metadata and controls
215 lines (193 loc) · 9.27 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
name: Build dev images
on:
push:
branches:
# NOTE: We're intentionally not including releases/* here because we want
# more manual control over that.
- main
workflow_dispatch:
inputs:
force_rebuild:
type: boolean
required: true
description: 'Force rebuild even if image tags already exist'
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-cudaqx-dev:
name: Build CUDA-QX Dev Image
if: ${{ github.repository == 'NVIDIA/cudaqx' }}
strategy:
matrix:
platform: [amd64, arm64]
cuda_version: ['12.6', '13.0']
fail-fast: false
runs-on: linux-${{ matrix.platform }}-cpu8
steps:
- name: Login to GitHub CR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Get code
uses: actions/checkout@v4
with:
set-safe-directory: true
- name: Get required CUDA-Q version
id: get-cudaq-version
uses: ./.github/actions/get-cudaq-version
- name: Get additional metadata
id: get-cudaq-version-short
run: |
shortref=$(echo "${{ steps.get-cudaq-version.outputs.ref }}" | head -c8)
commit_date=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/${{ steps.get-cudaq-version.outputs.ref }}" | jq -r '.commit.committer.date' | cut -dT -f1)
echo "shortref=$shortref" >> $GITHUB_OUTPUT
echo "commit_date=$commit_date" >> $GITHUB_OUTPUT
- name: Check if image already exists
id: check-image
run: |
IMAGE_TAG="${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
CONTAINER_VERSION_METADATA=$(curl -s -L -H "Accept: applicat/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/orgs/NVIDIA/packages/container/cudaqx-dev/versions?per_page=100")
CONTAINER_TAGS=$(echo $CONTAINER_VERSION_METADATA | jq -r '.[] | .metadata.container.tags[]')
if echo "$CONTAINER_TAGS" | grep -qx "$IMAGE_TAG"; then
echo "Image tag $IMAGE_TAG already exists. Skipping build."
echo "IMAGE_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "Image tag $IMAGE_TAG does not exist. Proceeding with build."
echo "IMAGE_EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Build and push
if: ${{ inputs.force_rebuild || steps.check-image.outputs.IMAGE_EXISTS == 'false' }}
run: |
other_tag=""
is_main_branch=${{ github.ref_name == 'main' }}
is_versioned=${{ startsWith(github.ref_name, 'releases/') }}
if ${is_main_branch}; then
other_tag="latest"
elif ${is_versioned}; then
ver=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
echo "Versioned release: $ver"
other_tag=$ver
fi
TAGS="-t ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
TAGS+=" -t ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
if [ -n "$other_tag" ]; then
TAGS+=" -t ghcr.io/nvidia/cudaqx-dev:${other_tag}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
fi
docker build $TAGS -f docker/build_env/cudaqx.dev.Dockerfile . \
--build-arg base_image=ghcr.io/nvidia/cuda-quantum-devcontainer:${{ matrix.platform }}-cu${{ matrix.cuda_version }}-gcc11-main \
--build-arg cuda_version=${{ matrix.cuda_version }}
docker push -a ghcr.io/nvidia/cudaqx-dev
shell: bash --noprofile --norc -euo pipefail {0}
build-cudaqx-pydev:
name: Build CUDA-QX Python Dev Image
if: ${{ github.repository == 'NVIDIA/cudaqx' }}
strategy:
matrix:
python: ['3.11', '3.12', '3.13']
platform: ['amd64', 'arm64']
cuda_version: ['12.6', '13.0']
fail-fast: false
runs-on: linux-${{ matrix.platform }}-cpu8
steps:
- name: Login to GitHub CR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Get code
uses: actions/checkout@v4
with:
set-safe-directory: true
- name: Get required CUDA-Q version
id: get-cudaq-version
uses: ./.github/actions/get-cudaq-version
- name: Get additional metadata
id: get-cudaq-version-short
run: |
shortref=$(echo "${{ steps.get-cudaq-version.outputs.ref }}" | head -c8)
commit_date=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/${{ steps.get-cudaq-version.outputs.ref }}" | jq -r '.commit.committer.date' | cut -dT -f1)
echo "shortref=$shortref" >> $GITHUB_OUTPUT
echo "commit_date=$commit_date" >> $GITHUB_OUTPUT
- name: Check if image already exists
id: check-image
run: |
IMAGE_TAG="${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-py${{ matrix.python }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
CONTAINER_VERSION_METADATA=$(curl -s -L -H "Accept: applicat/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/orgs/NVIDIA/packages/container/cudaqx-dev/versions?per_page=100")
CONTAINER_TAGS=$(echo $CONTAINER_VERSION_METADATA | jq -r '.[] | .metadata.container.tags[]')
if echo "$CONTAINER_TAGS" | grep -qx "$IMAGE_TAG"; then
echo "Image tag $IMAGE_TAG already exists. Skipping build."
echo "IMAGE_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "Image tag $IMAGE_TAG does not exist. Proceeding with build."
echo "IMAGE_EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Fetch CUDA-Q
if: ${{ inputs.force_rebuild || steps.check-image.outputs.IMAGE_EXISTS == 'false' }}
uses: actions/checkout@v4
with:
repository: ${{ steps.get-cudaq-version.outputs.repo }}
ref: ${{ steps.get-cudaq-version.outputs.ref }}
path: cudaq
set-safe-directory: true
- name: Build CUDA-Q wheels
if: ${{ inputs.force_rebuild || steps.check-image.outputs.IMAGE_EXISTS == 'false' }}
id: wheel_build
uses: docker/build-push-action@v5
with:
context: cudaq
file: cudaq/docker/release/cudaq.wheel.Dockerfile
build-args: |
base_image=ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-${{ matrix.platform }}-cu${{ matrix.cuda_version }}-gcc11-main
release_version=0.14.99
python_version=${{ matrix.python }}
cuda_version=${{ matrix.cuda_version }}
outputs: type=local,dest=/tmp/wheels
- name: Build and push dev image with prebuilt CUDA-Q wheels
if: ${{ inputs.force_rebuild || steps.check-image.outputs.IMAGE_EXISTS == 'false' }}
run: |
# Bring wheels into upcoming Docker context
mkdir cudaq-wheels
cp /tmp/wheels/*.whl cudaq-wheels/
# Perform build
TAGS="-t ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-py${{ matrix.python }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
TAGS+=" -t ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.shortref }}-py${{ matrix.python }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
other_tag=""
is_main_branch=${{ github.ref_name == 'main' }}
is_versioned=${{ startsWith(github.ref_name, 'releases/') }}
if ${is_main_branch}; then
other_tag="latest"
elif ${is_versioned}; then
ver=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
echo "Versioned release: $ver"
other_tag=$ver
fi
if [ -n "$other_tag" ]; then
TAGS+=" -t ghcr.io/nvidia/cudaqx-dev:${other_tag}-py${{ matrix.python }}-${{ matrix.platform }}-cu${{ matrix.cuda_version }}"
fi
BUILDARGS="--build-arg base_image=ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-${{ matrix.platform }}-cu${{ matrix.cuda_version }}-gcc11-main"
BUILDARGS+=" --build-arg python_version=${{ matrix.python }}"
BUILDARGS+=" --build-arg cuda_version=${{ matrix.cuda_version }}"
BUILDARGS+=" --ulimit nofile=1048576:1048576"
# For some reason, this fails on amd64 unless DOCKER_BUILDKIT=0 is set.
# The exact error is: too many open files.
DOCKER_BUILDKIT=0 docker build $TAGS $BUILDARGS -f docker/build_env/cudaqx.wheel.Dockerfile .
docker push -a ghcr.io/nvidia/cudaqx-dev
shell: bash --noprofile --norc -euo pipefail {0}
# cleanup:
# name: Cleanup
# needs: [build-cudaqx-dev, build-cudaqx-pydev]
# runs-on: ubuntu-latest
# if: ${{ github.repository == 'NVIDIA/cudaqx' }}
# steps:
# - name: Delete untagged images
# uses: actions/delete-package-versions@v5
# with:
# package-name: cudaqx-dev
# package-type: 'container'
# min-versions-to-keep: 0
# delete-only-untagged-versions: 'true'