Commit 5e35576
authored
feat: CI benchmark regression detection on PRs (#2013)
* feat: CI benchmark regression detection
Add a consolidated benchmark suite (`ci_benchmark`) and a GitHub Actions
workflow that automatically compares performance against the main branch
baseline on every PR.
Benchmark coverage (13 measurements, ~4 min on CI):
- BPE GPT-2: encode, batch, no-cache, batch-no-cache
- Llama-3: encode, batch, encode-fast, char-offsets, concurrent-4t
- Serialization: GPT-2 load, Llama-3 load, Llama-3 save
- Training: BPE small corpus
CI workflow:
- On push to main: run benchmarks, store baseline in gh-pages branch
- On PR: run benchmarks, compare vs baseline, post/update a single
PR comment with the delta table
- Alert threshold: 15% regression (warn, don't fail)
Uses benchmark-action/github-action-benchmark with criterion's bencher
output format for machine-readable results.
* fix: rustfmt + add github-token for PR comments
* ci: require approval for benchmark runs on PRs
* bench: add from_file + deserialize benchmarks to ci_benchmark
* fix: split workflow into two jobs to avoid empty environment value
* fix: download benchmark data in CI + skip if output empty
* fix: use huggingface-cli for data download (handles gated models like Llama-3)
* fix: use uvx for huggingface-cli, add setup-uv step
* fix: hf not huggingface-cli
* fix: single download from hf-internal-testing/tokenizers-bench-data
* fix: use hf-internal-testing dataset for BOTH jobs, remove all curl/gated refs
* Initialize gh-pages for benchmark data
* upupdate
* Initialize gh-pages for benchmark data
* ci: sccache, workflow_dispatch with PR comment, push-to-main only (no PR trigger)
* ci: temporarily trigger on ci-benchmarks branch for testing
* ci: touch tokenizers/ to trigger path filter
* ci: store baselines on HF Hub, drop github-action-benchmark + gh-pages
* ci: also trigger on workflow file changes + doc touch
* ci: skip upload if HF_TOKEN missing, remove ci-benchmarks branch trigger
* feat: add Python benchmark suite + CI matrix for Python bindings perf
- pytest-benchmark based test suite covering:
- BPE GPT-2: encode, encode_batch, multithreaded (4 workers)
- Llama-3: encode, encode_batch, encode_fast, multithreaded, decode_batch
- Async: async_encode_batch, async_encode_batch_fast
- Serialization: from_file, to_str, from_str (roberta, llama3, albert)
- Training: BPE small corpus
- CI workflow: separate benchmark-python job with sccache + maturin
- Re-enabled ci-benchmarks branch trigger for testing
* fix: skip benchmark tests when pytest-benchmark is not installed
* ci: Python bench comparison against saved baseline + PR comment
* ci: compare against baseline BEFORE uploading new one (both Rust and Python)
* ci: /benchmark comment trigger + only upload baseline on push to main
- New benchmark-trigger.yml: maintainer comments '/benchmark' on a PR
to dispatch the benchmark workflow on the PR's ref
- Upload steps gated on github.event_name == 'push' so workflow_dispatch
(PR runs) never overwrite the baseline
- Trigger requires MEMBER/OWNER/COLLABORATOR association
* ci: remove ci-benchmarks branch trigger
* ci: /benchmark creates a check run on the PR, updated with results when done
- benchmark-trigger.yml creates a 'Benchmark Results' check on the PR head SHA
- benchmarks.yml marks it in_progress at start, completed (success/failure) at end
- The check body contains the comparison markdown table
- Can be made a required check in branch protection rules
* ci: use criterion --save-baseline/--baseline + export artifacts
Rust:
- Push to main: runs with --save-baseline main, uploads criterion
data (tar.gz) + bencher output to HF Hub
- workflow_dispatch: downloads criterion baseline, runs with --baseline main
for automatic criterion comparison
- criterion HTML report uploaded as GitHub Actions artifact (30 day retention)
Python:
- bench_output.json uploaded as GitHub Actions artifact
- Baseline stored/compared via HF Hub as before
Both:
- Artifacts downloadable from the workflow run page for manual inspection
- Comparison tables posted to PR comments
* update
* ci: pin macOS Python to 3.13 (3.14 breaks abi3 linking)
* ci: add -undefined dynamic_lookup for macOS abi3 cross-compilation linking
* ?1 parent bd497e3 commit 5e35576
6 files changed
Lines changed: 908 additions & 0 deletions
File tree
- .github/workflows
- bindings/python/tests
- tokenizers
- benches
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
149 | 154 | | |
150 | 155 | | |
151 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments