mirror of
https://github.com/karpathy/nanochat.git
synced 2025-12-06 04:12:13 +00:00
Compare commits
16 Commits
4f09ceb918
...
84db602869
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84db602869 | ||
|
|
4a87a0d19f | ||
|
|
11e68bf442 | ||
|
|
7f3154f025 | ||
|
|
76ecece5f3 | ||
|
|
b8d0c7f391 | ||
|
|
c98648d0a9 | ||
|
|
887e68409f | ||
|
|
5cfcbaa4cd | ||
|
|
876da692c6 | ||
|
|
7715d0d425 | ||
|
|
a7d130f015 | ||
|
|
c4efcafaa8 | ||
|
|
63e4691357 | ||
|
|
4b45dfee97 | ||
|
|
46659d1009 |
43
.github/workflows/test.yml
vendored
Normal file
43
.github/workflows/test.yml
vendored
Normal 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/
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user