Compare commits

...

16 Commits

Author SHA1 Message Date
Sermet Pekin
84db602869
Merge 7f3154f025 into 4a87a0d19f 2025-11-18 14:47:27 +08:00
Andrej
4a87a0d19f
Merge pull request #299 from samjabrahams/rotary_embedding_head_dim_comment_cleanup
Fix comment: rotary embeddings final dimension size
2025-11-17 13:29:21 -08:00
Sam Abrahams
11e68bf442 Fix comment: rotary embeddings final dimension size 2025-11-17 11:32:56 -05:00
Sermet Pekin
7f3154f025
Update .github/workflows/test.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 13:34:57 +03:00
Sermet Pekin
76ecece5f3
rename base.yml as test.yml 2025-10-31 09:18:38 +03:00
Sermet Pekin
b8d0c7f391
Update .github/workflows/base.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 09:17:08 +03:00
Sermet Pekin
c98648d0a9
Update .github/workflows/base.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 09:16:46 +03:00
Sermet Pekin
887e68409f
Update .github/workflows/base.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 09:16:23 +03:00
Sermet Pekin
5cfcbaa4cd
Update .github/workflows/base.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 09:16:01 +03:00
Sermet Pekin
876da692c6
Update .github/workflows/base.yml
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-10-31 09:15:40 +03:00
Sermet Pekin
7715d0d425 reset tests/test_rustbpe.py file to upstream master 2025-10-22 21:25:52 +03:00
Sermet Pekin
a7d130f015 workflow remove windows from matrix 2025-10-22 20:52:05 +03:00
Sermet Pekin
c4efcafaa8 wf uv sync --extra cpu 2025-10-22 20:49:18 +03:00
Sermet Pekin
63e4691357 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
2025-10-22 20:49:18 +03:00
Sermet Pekin
4b45dfee97 Rename base.yml to .github/workflows/base.yml 2025-10-22 20:49:18 +03:00
Sermet Pekin
46659d1009 Refactor CI workflow to use 'uv' commands
Updated GitHub Actions workflow to use 'uv' for setup and dependency management.
2025-10-22 20:49:18 +03:00
2 changed files with 44 additions and 1 deletions

43
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.10']
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies with uv
run: |
uv sync --extra cpu
uv pip install transformers>=4.0.0
- name: Add nanochat to PYTHONPATH (Unix)
run: |
echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV
- name: Run pytest
run: |
uv run pytest tests/

View File

@ -244,7 +244,7 @@ class GPT(nn.Module):
def forward(self, idx, targets=None, kv_cache=None, loss_reduction='mean'):
B, T = idx.size()
# Grab the rotary embeddings for the current sequence length (they are of shape (1, seq_len, 1, head_dim))
# Grab the rotary embeddings for the current sequence length (they are of shape (1, seq_len, 1, head_dim/2))
assert T <= self.cos.size(1), f"Sequence length grew beyond the rotary embeddings cache: {T} > {self.cos.size(1)}"
assert idx.device == self.cos.device, f"Rotary embeddings and idx are on different devices: {idx.device} != {self.cos.device}"
assert self.cos.dtype == torch.bfloat16, "Rotary embeddings must be in bfloat16"