Repository navigation
74 lines (72 loc) · 2.8 KB
/
Copy pathpython.yml
File metadata and controls
74 lines (72 loc) · 2.8 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
name: Optional PyTorch operators
on:
push:
branches: [main]
pull_request:
jobs:
wheel:
name: wheel and CPU contract (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: bindings/torch/native
- name: Build tooling
run: python -m pip install build pytest numpy
- name: Install CPU PyTorch on Linux
if: runner.os == 'Linux'
run: python -m pip install torch==2.14.1 --index-url https://download.pytorch.org/whl/cpu
- name: Install PyTorch on macOS
if: runner.os == 'macOS'
run: python -m pip install torch==2.14.1
- name: Build wheel and source distribution
run: python -m build
- name: Verify macOS native wheel tag
if: runner.os == 'macOS'
run: |
python - <<'PY'
from pathlib import Path
import subprocess, tempfile, zipfile
wheel = next(Path('dist').glob('*.whl'))
with zipfile.ZipFile(wheel) as archive, tempfile.TemporaryDirectory() as tmp:
name = next(n for n in archive.namelist() if n.endswith('.dylib'))
native = Path(tmp) / 'native.dylib'
native.write_bytes(archive.read(name))
arch = subprocess.check_output(['lipo', '-archs', str(native)], text=True).strip()
assert arch in ('arm64', 'x86_64'), arch
assert wheel.name.endswith('_' + arch + '.whl'), (wheel.name, arch)
print('Verified native wheel architecture:', arch)
PY
- name: Install the built wheel
run: python -m pip install --no-deps dist/*.whl
- name: Cache full-model test checkpoint
id: gguf
uses: actions/cache@v4
with:
path: ci-models/tinyllama-1.1b-Q4_K_M.gguf
key: gguf-tinyllama-1.1b-chat-v1.0-q4km
- name: Fetch full-model test checkpoint
if: steps.gguf.outputs.cache-hit != 'true'
run: |
mkdir -p ci-models
curl -fL --retry 3 -o ci-models/tinyllama-1.1b-Q4_K_M.gguf \
https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
- name: Test installed package
env:
VITNI_REQUIRE_FULL_MODEL: '1'
VITNI_FULL_MODEL_CPU_ONLY: '1'
VITNI_FULL_MODEL_GGUF: ${{ github.workspace }}/ci-models/tinyllama-1.1b-Q4_K_M.gguf
run: python -m pytest -q python/tests
- uses: actions/upload-artifact@v4
with:
name: vitni-torch-${{ matrix.os }}
path: dist/