-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (243 loc) · 10.3 KB
/
Copy pathci.yml
File metadata and controls
249 lines (243 loc) · 10.3 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: write # lets the arm64 job post its results as a commit comment
defaults:
run:
working-directory: kernel
jobs:
test:
name: test (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
# The target platform: NEON path exercised here
- { os: ubuntu-24.04-arm, name: linux-arm64 }
# Apple Silicon: NEON path on the second Arm microarchitecture
- { os: macos-14, name: macos-arm64 }
# Scalar-fallback safety net
- { os: ubuntu-latest, name: linux-x86_64 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
with:
workspaces: kernel
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Tests (release, with per-case golden table)
run: |
set -o pipefail
cargo test --release -- --nocapture 2>&1 | tee test-output.txt
- name: Build FFI cdylib
run: cargo build --release -p arm-scan-ffi
- name: Python golden check through the C ABI
working-directory: .
run: |
python3 -m pip install --quiet numpy \
|| python3 -m pip install --quiet --break-system-packages numpy
python3 tests/check_ffi.py
# Definition check for the bidirectional scan: flip-forward-flip must
# equal a backward-in-time recurrence. numpy-only (no torch, no kernel),
# so it runs on every platform. Also the executable spec for the future
# Rust `reverse` flag — see TOPOLOGY_IMPLEMENTATION_PLAN.md §2.
- name: Bidirectional definition check (numpy)
working-directory: .
run: python3 tests/check_bidirectional_math.py
- name: Makefile parity (make test = the README's validate core)
working-directory: .
run: make test PY=python3
- name: Bench ladder (scalar vs NEON)
if: matrix.name == 'linux-arm64'
run: |
set -o pipefail
cargo bench | tee bench-output.txt
- name: Publish arm64 results (commit comment + job summary)
if: always() && matrix.name == 'linux-arm64' && github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
{
echo "## arm64 CI results (${{ github.sha }})"
echo
echo '### Failures (empty when green)'
echo '```'
grep -E "FAILED|panicked|assertion" test-output.txt | head -40 || true
sed -n '/^failures:$/,/test result/p' test-output.txt | head -80 || true
echo '```'
echo '### Golden cases (backend errors vs f64 reference, NEON/scalar parity)'
echo '```'
grep -E "backend Auto resolves|scalar=.*auto=" test-output.txt || true
echo '```'
echo '### NEON math accuracy'
echo '```'
grep -E "worst relative error|worst error" test-output.txt || true
echo '```'
echo '### Bench ladder'
echo '```'
grep -E "selective_scan/|time:|thrpt:" bench-output.txt 2>/dev/null || echo "(bench skipped)"
echo '```'
} > results.md
cat results.md >> "$GITHUB_STEP_SUMMARY"
gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/comments" \
-f body="$(cat results.md)" --silent || echo "commit comment failed (non-fatal)"
bench-op:
name: bench-op (linux-arm64)
needs: test
runs-on: ubuntu-24.04-arm
# 45, not 30: the bidirectional sweep now compiles the torch.compile baseline
# up to L=2048 (~12 min of inductor), on top of the torch install and build.
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: kernel
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build FFI cdylib
run: cargo build --release -p arm-scan-ffi
- name: Install torch (CPU aarch64)
working-directory: .
run: python3 -m pip install --quiet numpy torch
# Fast consolidated sanity: both topologies run, are correct, and beat
# native torch — one clear pass/fail before the fuller benchmarks.
- name: Smoke check (unidirectional + bidirectional vs torch)
working-directory: .
run: python3 bench/smoke_topologies.py
# Correctness gates speed (CLAUDE.md): the bidirectional wrapper is
# checked against the vendored f64 reference through the real kernel
# before anything here is benchmarked.
- name: Bidirectional correctness through the kernel
working-directory: .
run: python3 tests/check_bidirectional.py
# Bidirectional scan vs stock PyTorch (eager + torch.compile), plus the
# internal fused-vs-flip diagnostic. Provisional (shared runner); headline
# numbers need a dedicated Arm host per bench/README.md.
# Full sweep-len (L = 128 .. 8192) rather than --quick's 128/512, because
# the interesting behaviour is at long L: torch.compile scales linearly in
# L while the kernel scales sub-linearly, so the gap WIDENS (3.63x at
# L=128 -> 4.67x at L=512). Two short shapes could not show that.
#
# Compilation is the entire cost (~L^0.6: 59s@128, 134s@512), so it is
# capped at 2048 — roughly 12 min. L=4096/8192 still get measured against
# eager and against the kernel, just without a torch.compile row. Raising
# the cap risks inductor OOMing on the unrolled graph; that experiment
# belongs in the dispatchable bench-baseline workflow, not on every push.
- name: Bidirectional benchmark (vs eager / torch.compile)
working-directory: .
timeout-minutes: 25
run: |
set -o pipefail
python3 bench/bench_bidirectional.py --suite sweep-len \
--compile-max-len 2048 --reps 5 --warmup 1 \
--json bench-bidi.json 2>&1 | tee bench-bidi.log
- name: Publish bidirectional result
if: always()
working-directory: .
run: |
{
echo "## Bidirectional scan (linux-arm64 CI runner)"
echo "vs-baseline rows are the result. The internal fusion win is small and is NOT a headline — see BIDIRECTIONAL_LOG.md."
echo '```'
grep -E "^===|fused ==|^ (ref_|scan_fwd|bidirectional)|^ =>|exp-sharing|^bidirectional \(fused\)|torch.compile COST|^ +[0-9]+ +[0-9.]+s|^ +L|^ L=" bench-bidi.log 2>/dev/null || echo "(bench did not run)"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# The bench flushes JSON after every shape, so this survives even if a
# long-L shape is killed mid-sweep.
- uses: actions/upload-artifact@v4
if: always()
with:
name: bidirectional-bench-arm64
path: bench-bidi.json
if-no-files-found: warn
- name: Op-level benchmark (kernel vs eager vs torch.compile)
working-directory: .
run: |
set -o pipefail
python3 bench/bench_op.py --quick 2>&1 | tee bench-op.log
- name: Publish bench results
if: always() && github.event_name == 'push'
working-directory: .
env:
GH_TOKEN: ${{ github.token }}
run: |
{
echo "## op-level bench, linux-arm64 CI runner (${{ github.sha }})"
echo '(provisional: shared runner; headline numbers per bench/README.md)'
echo '```'
grep -vE "^\s*(Downloading|Installing|Collecting)" bench-op.log | tail -45 || true
echo '```'
} > bench-comment.md
cat bench-comment.md >> "$GITHUB_STEP_SUMMARY"
gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/comments" \
-f body="$(cat bench-comment.md)" --silent || true
wheels:
name: wheel (${{ matrix.name }})
needs: test
strategy:
fail-fast: false
matrix:
include:
# 22.04 for a broader glibc floor (manylinux_2_35) than 24.04
- { os: ubuntu-22.04-arm, name: linux-arm64 }
- { os: macos-14, name: macos-arm64 }
# x86 dev-convenience wheel (scalar backend)
- { os: ubuntu-22.04, name: linux-x86_64 }
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: kernel
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build FFI cdylib
run: cargo build --release -p arm-scan-ffi
- name: Build wheel
working-directory: .
run: |
set -o pipefail
python3 -m pip install --quiet --upgrade pip setuptools wheel
python3 scripts/build_wheel.py 2>&1 | tee wheel-build.log
- name: Install wheel into clean venv and golden-check it
working-directory: .
run: |
python3 -m venv wheel-test-env
wheel-test-env/bin/pip install --quiet python/dist/arm_scan-*.whl
ARM_SCAN_INSTALLED=1 wheel-test-env/bin/python tests/check_ffi.py
wheel-test-env/bin/python -c "import arm_scan; p=str(arm_scan.lib_path()); print('installed kernel:', p); assert 'site-packages' in p, 'wheel test resolved the repo library, not the installed one'"
- uses: actions/upload-artifact@v4
with:
name: arm-scan-wheel-${{ matrix.name }}
path: python/dist/*.whl
if-no-files-found: error
- name: Publish wheel failure log
if: failure() && github.event_name == 'push'
working-directory: .
env:
GH_TOKEN: ${{ github.token }}
run: |
{
echo "## wheel (${{ matrix.name }}) FAILED (${{ github.sha }})"
echo '```'
tail -60 wheel-build.log 2>/dev/null || echo "(no build log)"
echo '```'
} > wheel-fail.md
gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/comments" \
-f body="$(cat wheel-fail.md)" --silent || true