Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test pretty-duration benchmark formatting #7

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions .github/workflows/benchmark-rust.yaml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Benchmarks

on:
push:
branches: [main]
pull_request:
types: [synchronize, labeled]
workflow_dispatch:
merge_group:
env:
PYTHON_VERSION: "3.10"
BENCHMARKS_DIR: ${{ github.workspace }}/benchmarks/python
BENCHMARKS_OUTPUT: ${{ github.workspace }}/benchmarks_output
CARGO_NET_GIT_FETCH_WITH_CLI: true


permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
# allow posting comments to pull request
pull-requests: write

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
Criterion:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'run-benchmarks') || github.event_name == 'push' || github.event_name == 'merge_group' }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup rust
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: stable

- name: Cache Rust
uses: actions/cache@v4
with:
key: ${{ runner.os }}-${{ runner.group }}-rust-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ runner.group }}-rust-
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/

- name: Install cargo-criterion if not cached
run: |
if ! command -v cargo-criterion &> /dev/null; then
echo "cargo-criterion is not found, installing..."
cargo install cargo-criterion
else
echo "cargo-criterion is cached"
fi

- name: Run benchmarks
run: cargo criterion --bench criterion --output-format bencher|& tee benchmarks.txt

- name: Compare benchmarks
uses: 414owen/github-action-benchmark@745dc3ce0a9a35124ab058c1259f1970fd945fd3
with:
tool: 'cargo'
output-file-path: benchmarks.txt
alert-threshold: "110%"
fail-on-alert: ${{ github.event_name == 'pull_request' }}
comment-on-alert: true
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
auto-push: ${{ github.event_name == 'push' }}
save-data-file: ${{ github.event_name == 'push' }}
33 changes: 3 additions & 30 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,23 @@ repository = "https://github.com/dottxt-ai/outlines-core"
rust-version = "1.71.1"

[dependencies]
once_cell = "1.20"
thiserror = "2.0"
pyo3 = { version = "0.22.0", features = ["extension-module"], optional = true }
regex = "1.10.6"
serde-pyobject = "0.4.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
serde = {version = "1.0", features = ["derive"]}
bincode = "2.0.0-rc.3"
# Fragile dependencies, minor updates often break the code
hf-hub = "=0.3.2"
tokenizers = { version = "=0.20.3", features = ["http"] }
rustc-hash = "2.1.0"
regex-automata = "0.4.9"

[features]
python-bindings = ["pyo3"]

[lib]
name = "outlines_core"
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
opt-level = 2
lto = false
codegen-units = 10
strip = true
panic = 'abort'

[package.metadata.scripts]
build-python-extension = "python setup.py build_rust --inplace --debug"
build-python-extension-release = "python setup.py build_rust --inplace --release"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

[[bench]]
path = "benchmarks/criterion.rs"
name = "criterion"
harness = false

[[bin]]
name = "convert-json-schema"
test = false
bench = false

[dev-dependencies]
criterion = "0.5.1"
8 changes: 4 additions & 4 deletions benchmarks/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use criterion::{criterion_group, criterion_main, Criterion};
use std::hint::black_box;

fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n - 1) + fibonacci(n - 2),
if n < 3 {
n
} else {
fibonacci(n - 1) + fibonacci(n - 2) + fibonacci(n - 3)
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/bin/convert-json-schema.rs

This file was deleted.

87 changes: 0 additions & 87 deletions src/error.rs

This file was deleted.

Loading
Loading