-
Notifications
You must be signed in to change notification settings - Fork 307
257 lines (231 loc) · 8.59 KB
/
huggingface-nightly.yml
File metadata and controls
257 lines (231 loc) · 8.59 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
name: huggingface-nightly-build-and-publish
on:
schedule:
# Nightly at 03:17 UTC
- cron: "17 3 * * *"
workflow_dispatch:
inputs:
upload_to:
description: "Where to upload (none/testpypi/pypi)"
required: true
default: "testpypi"
type: choice
options:
- none
- testpypi
- pypi
skip_existing:
description: "Skip already-uploaded versions"
required: true
default: true
type: boolean
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- id: nemotron-page-elements-v3
url: https://huggingface.co/nvidia/nemotron-page-elements-v3
project_subdir: ""
- id: nemotron-table-structure-v1
url: https://huggingface.co/nvidia/nemotron-table-structure-v1
project_subdir: ""
- id: nemotron-graphic-elements-v1
url: https://huggingface.co/nvidia/nemotron-graphic-elements-v1
project_subdir: ""
- id: llama-nemotron-embed-1b-v2
url: https://huggingface.co/nvidia/llama-nemotron-embed-1b-v2
# Repo layout matches nemotron-ocr-v1: Python project is nested under a same-named subdir.
project_subdir: llama-nemotron-embed-1b-v2
- id: llama-nemotron-rerank-1b-v2
url: https://huggingface.co/nvidia/llama-nemotron-rerank-1b-v2
project_subdir: ""
steps:
- name: Checkout orchestrator repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install git-lfs
run: |
sudo apt-get update
sudo apt-get install -y git-lfs
git lfs install
- name: Decide upload target
id: target
shell: bash
run: |
set -euo pipefail
# Default for scheduled runs: testpypi
upload_to="testpypi"
skip_existing="true"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
upload_to="${{ inputs.upload_to }}"
skip_existing="${{ inputs.skip_existing }}"
fi
echo "upload_to=${upload_to}" >> "$GITHUB_OUTPUT"
echo "skip_existing=${skip_existing}" >> "$GITHUB_OUTPUT"
- name: Build (and maybe upload)
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
shell: bash
run: |
set -euo pipefail
upload_flag=""
repo_url="https://test.pypi.org/legacy/"
token_env="TEST_PYPI_API_TOKEN"
if [[ "${{ steps.target.outputs.upload_to }}" == "none" ]]; then
upload_flag=""
else
upload_flag="--upload"
fi
if [[ "${{ steps.target.outputs.upload_to }}" == "pypi" ]]; then
repo_url="https://upload.pypi.org/legacy/"
token_env="PYPI_API_TOKEN"
fi
skip_existing_flag=""
if [[ "${{ steps.target.outputs.skip_existing }}" == "true" ]]; then
skip_existing_flag="--skip-existing"
fi
python ci/scripts/nightly_build_publish.py \
--repo-id "${{ matrix.repo.id }}" \
--repo-url "${{ matrix.repo.url }}" \
--work-dir ".work" \
--dist-dir "dist-out" \
--project-subdir "${{ matrix.repo.project_subdir }}" \
${upload_flag} \
--repository-url "${repo_url}" \
--token-env "${token_env}" \
${skip_existing_flag}
- name: Upload build artifacts (GH Actions)
if: always()
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.repo.id }}
path: dist-out/${{ matrix.repo.id }}/*
build_ocr_cuda:
# nemotron-ocr-v1 needs nvcc/CUDA headers to build its extension.
# Build with Python 3.12 to match upstream package constraints and
# avoid producing an extension for the wrong Python ABI.
runs-on: ubuntu-latest
container:
# Build extension with CUDA 13 toolchain (nvcc/headers from devel image).
image: nvidia/cuda:13.0.0-devel-ubuntu24.04
steps:
- name: Install system deps (git, lfs, build tools)
shell: bash
run: |
set -euo pipefail
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates \
git \
git-lfs \
build-essential \
ninja-build \
python3 \
python3-venv \
python3-pip
git lfs install
- name: Checkout orchestrator repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Decide upload target
id: target
shell: bash
run: |
set -euo pipefail
# Default for scheduled runs: testpypi
upload_to="testpypi"
skip_existing="true"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
upload_to="${{ inputs.upload_to }}"
skip_existing="${{ inputs.skip_existing }}"
fi
echo "upload_to=${upload_to}" >> "$GITHUB_OUTPUT"
echo "skip_existing=${skip_existing}" >> "$GITHUB_OUTPUT"
- name: Build nemotron-ocr-v1 (and maybe upload)
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
CUDA_HOME: /usr/local/cuda
BUILD_CPP_EXTENSION: "1"
BUILD_CPP_FORCE: "1"
TORCH_CUDA_ARCH_LIST: "8.0;8.6;8.9;9.0;10.0;12.0+PTX"
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cu130"
shell: bash
run: |
set -euo pipefail
upload_flag=""
repo_url="https://test.pypi.org/legacy/"
token_env="TEST_PYPI_API_TOKEN"
if [[ "${{ steps.target.outputs.upload_to }}" == "none" ]]; then
upload_flag=""
else
upload_flag="--upload"
fi
if [[ "${{ steps.target.outputs.upload_to }}" == "pypi" ]]; then
repo_url="https://upload.pypi.org/legacy/"
token_env="PYPI_API_TOKEN"
fi
skip_existing_flag=""
if [[ "${{ steps.target.outputs.skip_existing }}" == "true" ]]; then
skip_existing_flag="--skip-existing"
fi
python --version
python ci/scripts/nightly_build_publish.py \
--repo-id "nemotron-ocr-v1" \
--repo-url "https://huggingface.co/nvidia/nemotron-ocr-v1" \
--work-dir ".work" \
--dist-dir "dist-out" \
--project-subdir "nemotron-ocr" \
--build-no-isolation \
--venv-pip-install "hatchling" \
--venv-pip-install "setuptools>=68" \
--venv-pip-install "torch==2.9.1" \
--venv-pip-install "torchvision==0.24.1" \
--build-env "BUILD_CPP_EXTENSION=1" \
--build-env "BUILD_CPP_FORCE=1" \
${upload_flag} \
--repository-url "${repo_url}" \
--token-env "${token_env}" \
${skip_existing_flag}
python - <<'PY'
import sys
import zipfile
from pathlib import Path
wheels = sorted(Path("dist-out/nemotron-ocr-v1").glob("*.whl"))
if not wheels:
raise SystemExit("No wheel found in dist-out/nemotron-ocr-v1")
py_tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
matches = []
for wheel in wheels:
with zipfile.ZipFile(wheel) as zf:
names = zf.namelist()
for name in names:
if "nemotron_ocr_cpp/_nemotron_ocr_cpp." in name:
matches.append((wheel.name, name))
if not matches:
raise SystemExit("Built wheel is missing nemotron_ocr_cpp extension artifact")
if not any(py_tag in ext for _, ext in matches):
formatted = "\n".join(f"{w}: {ext}" for w, ext in matches)
raise SystemExit(
f"Built extension ABI does not match runner Python ({py_tag}). Found:\n{formatted}"
)
print("Verified nemotron_ocr_cpp extension ABI:", py_tag)
PY
- name: Upload build artifacts (GH Actions)
if: always()
uses: actions/upload-artifact@v4
with:
name: dist-nemotron-ocr-v1
path: dist-out/nemotron-ocr-v1/*