-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASV PR bench workflow, pytest-bench -> ASV, add peakmem tests
- Loading branch information
1 parent
3a7d83b
commit ecc08c5
Showing
10 changed files
with
191 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Benchmark PR | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
env: | ||
PYTHON_VERSION: "3.10" | ||
WORKING_DIR: ${{ github.workspace }}/benchmarks | ||
BENCHMARKS_OUTPUT: ${{ github.workspace }}/benchmarks_output | ||
|
||
jobs: | ||
benchmark-pr: | ||
runs-on: ubuntu-latest | ||
if: contains(github.event.pull_request.labels.*.name, 'run_benchmarks') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_run' | ||
|
||
defaults: | ||
run: | ||
working-directory: ${{ env.WORKING_DIR }} | ||
|
||
steps: | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install asv virtualenv lf-asv-formatter | ||
- name: Create ASV machine config file | ||
run: asv machine --machine gh-runner --yes | ||
|
||
- name: Run Benchmarks - `PR HEAD` vs `main` | ||
run: | | ||
# prepare main branch for comparison | ||
git remote add upstream https://github.com/${{ github.repository }}.git | ||
git fetch upstream main | ||
# Run benchmarks, allow errors, they will be caught in the next step | ||
asv continuous upstream/main HEAD \ | ||
--no-stats --interleave-rounds -a repeat=3 || true | ||
- name: BENCHMARK RESULTS | ||
run: asv compare --factor=1.1 --no-stats --split upstream/main HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ docs/build | |
.idea/ | ||
*.gguf | ||
.venv | ||
benchmarks/results |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 1, | ||
"project": "Outlines", | ||
"project_url": "https://outlines-dev.github.io/outlines/", | ||
"repo": "..", | ||
"branches": [ | ||
"HEAD" | ||
], | ||
"build_command": [ | ||
"python -mpip install .[test]", | ||
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}", | ||
], | ||
"environment_type": "virtualenv", | ||
"show_commit_url": "https://github.com/lapp0/outlines/commit/", | ||
"benchmark_dir": ".", | ||
"env_dir": "env", | ||
"results_dir": "results", | ||
"html_dir": "html", | ||
"build_cache_size": 8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import importlib | ||
|
||
import interegular | ||
import numba | ||
|
||
import outlines | ||
|
||
from .common import clear_outlines_cache, setup_tokenizer | ||
|
||
outlines.disable_cache() | ||
|
||
|
||
class NumbaCompileBenchmark: | ||
def setup(self): | ||
clear_outlines_cache() | ||
from outlines.fsm import regex | ||
|
||
self.tokenizer = setup_tokenizer() | ||
self.regex = regex | ||
original_njit = numba.njit | ||
|
||
def mock_njit(*args, **kwargs): | ||
kwargs["cache"] = False | ||
return original_njit(*args, **kwargs) | ||
|
||
self.original_njit = original_njit | ||
numba.njit = mock_njit | ||
importlib.reload(self.regex) | ||
self.regex_pattern, _ = self.regex.make_deterministic_fsm( | ||
interegular.parse_pattern("a").to_fsm().reduce() | ||
) | ||
|
||
def teardown(self): | ||
numba.njit = self.original_njit | ||
|
||
def time_compile_numba(self): | ||
self.regex.create_fsm_index_tokenizer(self.regex_pattern, self.tokenizer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import pytest | ||
from transformers import AutoTokenizer | ||
|
||
import outlines.caching | ||
from outlines.fsm.guide import RegexGuide | ||
from outlines.models.transformers import TransformerTokenizer | ||
|
||
|
||
@pytest.fixture | ||
def tokenizer(): | ||
def clear_outlines_cache(): | ||
outlines.caching.clear_cache() | ||
|
||
|
||
def setup_tokenizer(): | ||
tokenizer = AutoTokenizer.from_pretrained("gpt2") | ||
return TransformerTokenizer(tokenizer) | ||
|
||
|
||
@pytest.fixture | ||
def ensure_numba_compiled(tokenizer): | ||
RegexGuide("a", tokenizer) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.