-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into token-cache
- Loading branch information
Showing
49 changed files
with
1,080 additions
and
291 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,22 @@ | ||
#!/bin/bash | ||
|
||
# Build sdist and wheel | ||
python -m pip install -U pip | ||
python -m pip install build | ||
python -m build | ||
|
||
# Check sdist install and imports | ||
mkdir -p test-sdist | ||
cd test-sdist | ||
python -m venv venv-sdist | ||
venv-sdist/bin/python -m pip install ../dist/outlines-*.tar.gz | ||
venv-sdist/bin/python -c "import outlines" | ||
cd .. | ||
|
||
# Check wheel install and imports | ||
mkdir -p test-wheel | ||
cd test-wheel | ||
python -m venv venv-wheel | ||
venv-wheel/bin/python -m pip install ../dist/outlines-*.whl | ||
venv-wheel/bin/python -c "import outlines" | ||
cd .. |
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,57 @@ | ||
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 | tee ${{ env.BENCHMARKS_OUTPUT }} | ||
if grep -q "Benchmarks that have got worse" "${{ env.BENCHMARKS_OUTPUT }}"; then | ||
echo "Performance degradation detected!" | ||
exit 1 | ||
fi |
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 |
---|---|---|
|
@@ -15,28 +15,11 @@ jobs: | |
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.10" | ||
- name: Build sdist and wheel | ||
run: | | ||
python -m pip install -U pip | ||
python -m pip install build | ||
python -m build | ||
- name: Build SDist and Wheel | ||
run: ./.github/scripts/build_sdist_and_wheel.sh | ||
- name: Check that the package version matches the Release name | ||
run: | | ||
grep -Rq "^Version: ${GITHUB_REF:10}$" outlines.egg-info/PKG-INFO | ||
- name: Check sdist install and imports | ||
run: | | ||
mkdir -p test-sdist | ||
cd test-sdist | ||
python -m venv venv-sdist | ||
venv-sdist/bin/python -m pip install ../dist/outlines-*.tar.gz | ||
venv-sdist/bin/python -c "import outlines" | ||
- name: Check wheel install and imports | ||
run: | | ||
mkdir -p test-wheel | ||
cd test-wheel | ||
python -m venv venv-wheel | ||
venv-wheel/bin/python -m pip install ../dist/outlines-*.whl | ||
venv-wheel/bin/python -c "import outlines" | ||
- name: Publish to PyPi | ||
uses: pypa/[email protected] | ||
with: | ||
|
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ docs/build | |
.idea/ | ||
*.gguf | ||
.venv | ||
benchmarks/results |
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ repos: | |
- id: mypy | ||
args: [--allow-redefinition] | ||
exclude: ^examples/ | ||
additional_dependencies: [types-tqdm] |
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
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/outlines-dev/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,34 @@ | ||
import importlib | ||
|
||
import interegular | ||
import numba | ||
|
||
from outlines.caching import cache_disabled | ||
from outlines.fsm import regex | ||
|
||
from .common import setup_tokenizer | ||
|
||
|
||
class NumbaCompileBenchmark: | ||
def setup(self): | ||
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 | ||
|
||
@cache_disabled() | ||
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,14 @@ | ||
import pytest | ||
from transformers import AutoTokenizer | ||
|
||
from outlines.fsm.guide import RegexGuide | ||
from outlines.models.transformers import TransformerTokenizer | ||
|
||
|
||
@pytest.fixture | ||
def tokenizer(): | ||
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
Oops, something went wrong.