From 46659d1009c33d3f9822ff61a92d2bf8da7e0f90 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Wed, 22 Oct 2025 13:50:35 +0300 Subject: [PATCH 01/13] Refactor CI workflow to use 'uv' commands Updated GitHub Actions workflow to use 'uv' for setup and dependency management. --- base.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 base.yml diff --git a/base.yml b/base.yml new file mode 100644 index 0000000..8150f7c --- /dev/null +++ b/base.yml @@ -0,0 +1,50 @@ +name: Test + +on: + push: + branches: + - master + - gh-wf-v3 + pull_request: + branches: + - master + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.10', '3.11', '3.12', '3.13'] + fail-fast: false + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up uv + uses: astral-sh/setup-uv@v7 + + - name: Install dependencies with uv + run: | + uv sync + uv pip install transformers>=4.0.0 + + - name: Add nanochat to PYTHONPATH (Unix) + if: runner.os != 'Windows' + run: | + echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV + + - name: Add nanochat to PYTHONPATH (Windows) + if: runner.os == 'Windows' + run: | + echo "PYTHONPATH=$PWD;$env:PYTHONPATH" >> $env:GITHUB_ENV + + - name: Run pytest + run: | + uv run pytest tests/ --maxfail=5 From 4b45dfee9771582926ce9cb1be1cbe0f6a7acf25 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Wed, 22 Oct 2025 13:51:16 +0300 Subject: [PATCH 02/13] Rename base.yml to .github/workflows/base.yml --- base.yml => .github/workflows/base.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename base.yml => .github/workflows/base.yml (100%) diff --git a/base.yml b/.github/workflows/base.yml similarity index 100% rename from base.yml rename to .github/workflows/base.yml From 63e4691357f3bc36c5653f5707c2369fce2a7ec2 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Wed, 22 Oct 2025 13:57:45 +0300 Subject: [PATCH 03/13] Specify UTF-8 encoding for on `test_rustbpe.py` while enwik8 file reads Specify UTF-8 encoding for on `test_rustbpe.py` while enwik8 file reads --- tests/test_rustbpe.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_rustbpe.py b/tests/test_rustbpe.py index 5f95721..524cab2 100644 --- a/tests/test_rustbpe.py +++ b/tests/test_rustbpe.py @@ -451,19 +451,18 @@ def enwik8_path(): print(f"Using existing enwik8 at {enwik8_local_path}") return enwik8_local_path - @pytest.fixture(scope="module") def enwik8_small(enwik8_path): """Fixture providing 100KB of enwik8 for quick tests.""" - with open(enwik8_path, "r") as f: + with open(enwik8_path, "r", encoding="utf-8") as f: return f.read(100_000) @pytest.fixture(scope="module") def enwik8_large(enwik8_path): """Fixture providing 10MB of enwik8 for performance tests.""" - with open(enwik8_path, "r") as f: + with open(enwik8_path, "r", encoding="utf-8") as f: return f.read(10**7) - + def time_function(func, *args, **kwargs): """Time a function call and return the result and elapsed time""" start_time = time.time() From c4efcafaa8018ca47a7fdc0536693ac9d738f0ec Mon Sep 17 00:00:00 2001 From: Sermet Pekin Date: Wed, 22 Oct 2025 20:46:39 +0300 Subject: [PATCH 04/13] wf uv sync --extra cpu --- .github/workflows/base.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 8150f7c..9c2f770 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -3,8 +3,7 @@ name: Test on: push: branches: - - master - - gh-wf-v3 + - '**' pull_request: branches: - master @@ -15,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10'] fail-fast: false steps: @@ -32,7 +31,7 @@ jobs: - name: Install dependencies with uv run: | - uv sync + uv sync --extra cpu uv pip install transformers>=4.0.0 - name: Add nanochat to PYTHONPATH (Unix) From a7d130f01532a0c1744edd9a7f54a5365266e00f Mon Sep 17 00:00:00 2001 From: Sermet Pekin Date: Wed, 22 Oct 2025 20:52:05 +0300 Subject: [PATCH 05/13] workflow remove windows from matrix --- .github/workflows/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 9c2f770..01e83e0 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] python-version: ['3.10'] fail-fast: false From 7715d0d425df8e4c923602a6ace37bff9f62087f Mon Sep 17 00:00:00 2001 From: Sermet Pekin Date: Wed, 22 Oct 2025 21:25:52 +0300 Subject: [PATCH 06/13] reset tests/test_rustbpe.py file to upstream master --- tests/test_rustbpe.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_rustbpe.py b/tests/test_rustbpe.py index 524cab2..5f95721 100644 --- a/tests/test_rustbpe.py +++ b/tests/test_rustbpe.py @@ -451,18 +451,19 @@ def enwik8_path(): print(f"Using existing enwik8 at {enwik8_local_path}") return enwik8_local_path + @pytest.fixture(scope="module") def enwik8_small(enwik8_path): """Fixture providing 100KB of enwik8 for quick tests.""" - with open(enwik8_path, "r", encoding="utf-8") as f: + with open(enwik8_path, "r") as f: return f.read(100_000) @pytest.fixture(scope="module") def enwik8_large(enwik8_path): """Fixture providing 10MB of enwik8 for performance tests.""" - with open(enwik8_path, "r", encoding="utf-8") as f: + with open(enwik8_path, "r") as f: return f.read(10**7) - + def time_function(func, *args, **kwargs): """Time a function call and return the result and elapsed time""" start_time = time.time() From 876da692c6507ddf728039683c5145e1032eb199 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:15:40 +0300 Subject: [PATCH 07/13] Update .github/workflows/base.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 01e83e0..2221345 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v4 From 5cfcbaa4cd72191598f95e00919d34b74b64258e Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:16:01 +0300 Subject: [PATCH 08/13] Update .github/workflows/base.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/base.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 2221345..44f2061 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -35,7 +35,6 @@ jobs: uv pip install transformers>=4.0.0 - name: Add nanochat to PYTHONPATH (Unix) - if: runner.os != 'Windows' run: | echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV From 887e68409fd6ed018b36b2c4027ed5b4bcda57f6 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:16:23 +0300 Subject: [PATCH 09/13] Update .github/workflows/base.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/base.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 44f2061..df9c9a3 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -38,11 +38,6 @@ jobs: run: | echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV - - name: Add nanochat to PYTHONPATH (Windows) - if: runner.os == 'Windows' - run: | - echo "PYTHONPATH=$PWD;$env:PYTHONPATH" >> $env:GITHUB_ENV - - name: Run pytest run: | uv run pytest tests/ --maxfail=5 From c98648d0a92b3054bef70e16ff269b7fb1df3c4f Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:16:46 +0300 Subject: [PATCH 10/13] Update .github/workflows/base.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index df9c9a3..f13c7ff 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -3,7 +3,7 @@ name: Test on: push: branches: - - '**' + - master pull_request: branches: - master From b8d0c7f391d5409518112d5a2bd86e8ddf0f5a78 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:17:08 +0300 Subject: [PATCH 11/13] Update .github/workflows/base.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index f13c7ff..95ba317 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} From 76ecece5f3c19692dfa9c865099e90a6a9b32af3 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:18:38 +0300 Subject: [PATCH 12/13] rename base.yml as test.yml --- .github/workflows/{base.yml => test.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{base.yml => test.yml} (100%) diff --git a/.github/workflows/base.yml b/.github/workflows/test.yml similarity index 100% rename from .github/workflows/base.yml rename to .github/workflows/test.yml From 7f3154f02548ab6bcbfa0d7a231be0148960e437 Mon Sep 17 00:00:00 2001 From: Sermet Pekin <96650846+SermetPekin@users.noreply.github.com> Date: Fri, 31 Oct 2025 13:34:57 +0300 Subject: [PATCH 13/13] Update .github/workflows/test.yml Co-authored-by: Sofie Van Landeghem --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95ba317..4b79305 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,4 +40,4 @@ jobs: - name: Run pytest run: | - uv run pytest tests/ --maxfail=5 + uv run pytest tests/