Ci benchmarks (#2019)
* 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
* ?
* ci: ubuntu-latest-4-cores + SVG benchmark charts with red/green color coding
- Switch both jobs to ubuntu-latest-4-cores for more consistent results
- Replace plaintext markdown tables with SVG charts generated by
.github/scripts/render_bench_svg.py
- Dark theme, monospace font, red/green bars + delta percentages
- SVGs uploaded as artifacts and embedded in PR comments
- Supports both Rust (bencher format) and Python (pytest-benchmark JSON)
* Apply suggestion from @ArthurZucker
* Apply suggestions from code review
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
* fix: render bench charts as PNG for GitHub comment compatibility
SVG doesn't render in GitHub PR comments. Now:
- render_bench_svg.py supports --output .png via cairosvg
- PNGs uploaded to hf-internal-testing/tokenizers-bench/charts/
- PR comments embed as  which GitHub renders correctly
* ci: bump bench rounds to 15 (Rust sample_size + Python min-rounds)
* fix: use uv pip install --system for cairosvg A
Arthur committed
efbcc68e321c364c8f9541f1c93a158df54d7da4
Parent: d863e6e
Committed by GitHub <noreply@github.com>
on 4/10/2026, 2:52:58 PM