-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (181 loc) · 5.97 KB
/
Copy pathci.yml
File metadata and controls
191 lines (181 loc) · 5.97 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
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install lint tools
run: |
python -m pip install --upgrade pip
python -m pip install ruff==0.4.10 black==24.4.2
- name: Ruff
run: ruff check src tests
- name: Black
run: black --check src tests
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Mypy
run: mypy src/quant_explorer
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Unit tests + coverage gate (>= 56%)
run: pytest tests/unit -v --cov=src/quant_explorer --cov-report=term
integration-tiny:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Cache CIFAR-10 dataset
uses: actions/cache@v4
with:
path: data
key: cifar10-${{ hashFiles('src/quant_explorer/data.py') }}
restore-keys: cifar10-
- name: Tiny pipeline
env:
RUN_INTEGRATION: "1"
run: pytest tests/integration -v
bench-smoke:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Bench fp32_baseline (loads committed weights)
run: |
quant-explorer bench --config fp32_baseline --warmup 2 --iters 20
- name: Validate result JSON shape
run: |
python - <<'PY'
import json, pathlib
p = pathlib.Path("artifacts/results/fp32_baseline.json")
assert p.exists(), p
data = json.loads(p.read_text())
assert "size" in data
assert "latency" in data and len(data["latency"]) > 0
assert "memory" in data
for lat in data["latency"]:
assert {"batch_size", "p50_ms", "p95_ms", "p99_ms"}.issubset(lat)
print("ok")
PY
qat-smoke:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Cache CIFAR-10 dataset
uses: actions/cache@v4
with:
path: data
key: cifar10-${{ hashFiles('src/quant_explorer/data.py') }}
restore-keys: cifar10-
- name: QAT fine-tune (tiny — 256 train images, 1 epoch)
run: |
quant-explorer qat-finetune --epochs 1 --train-subset 256 --batch-size 64
- name: Bench QAT graph
run: quant-explorer bench --config qat_int8 --warmup 2 --iters 20
- name: Validate QAT result JSON
run: |
python - <<'PY'
import json, pathlib
p = pathlib.Path("artifacts/results/qat_int8.json")
assert p.exists(), p
data = json.loads(p.read_text())
assert data["size"]["kb"] > 0
assert all(lat["p50_ms"] > 0 for lat in data["latency"])
print("ok")
PY
multi-bench-regress:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 torchvision==0.17.2
pip install -e ".[dev]"
- name: Run multi-model bench (random init, no accuracy)
run: quant-explorer multi-bench --warmup 1 --iters 5
- name: Bench-regress structural gate
run: python scripts/bench_regress_check.py
build:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t quant-explorer:ci .
- name: Smoke run inside container
run: |
# ENTRYPOINT is `quant-explorer`; --help is the safe smoke arg.
docker run --rm quant-explorer:ci --help | grep -q "Quant-explorer CLI"
# Override entrypoint to confirm the package imports cleanly.
docker run --rm --entrypoint python quant-explorer:ci -c "from quant_explorer.cli import main; print('ok')"