tokforge 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tokforge-0.1.0/.gitattributes +1 -0
- tokforge-0.1.0/.github/workflows/ci.yml +113 -0
- tokforge-0.1.0/.github/workflows/release.yml +127 -0
- tokforge-0.1.0/.gitignore +17 -0
- tokforge-0.1.0/AGENTS.md +20 -0
- tokforge-0.1.0/CLAUDE.md +634 -0
- tokforge-0.1.0/Cargo.lock +1523 -0
- tokforge-0.1.0/Cargo.toml +50 -0
- tokforge-0.1.0/LICENSE-APACHE +202 -0
- tokforge-0.1.0/LICENSE-MIT +21 -0
- tokforge-0.1.0/PERFORMANCE.md +543 -0
- tokforge-0.1.0/PKG-INFO +48 -0
- tokforge-0.1.0/README.md +321 -0
- tokforge-0.1.0/benches/throughput.rs +635 -0
- tokforge-0.1.0/benchmarks/after.json +65 -0
- tokforge-0.1.0/benchmarks/before.json +65 -0
- tokforge-0.1.0/benchmarks/guided-after.json +65 -0
- tokforge-0.1.0/benchmarks/guided-before.json +65 -0
- tokforge-0.1.0/benchmarks/guided-recheck-after.json +65 -0
- tokforge-0.1.0/benchmarks/guided-recheck-before.json +65 -0
- tokforge-0.1.0/benchmarks/memory.json +112 -0
- tokforge-0.1.0/benchmarks/python-compare.json +557 -0
- tokforge-0.1.0/benchmarks/runs/after-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/after-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/after-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/before-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/before-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/before-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-after-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-after-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-after-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-before-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-before-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-before-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-after-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-after-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-after-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-before-1.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-before-2.json +49 -0
- tokforge-0.1.0/benchmarks/runs/guided-recheck-before-3.json +49 -0
- tokforge-0.1.0/benchmarks/runs/scaling-after-1.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-after-2.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-after-3.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-after-4.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-after-5.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-before-1.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-before-2.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-before-3.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-before-4.json +260 -0
- tokforge-0.1.0/benchmarks/runs/scaling-before-5.json +260 -0
- tokforge-0.1.0/benchmarks/scaling-after.json +23 -0
- tokforge-0.1.0/benchmarks/scaling-before.json +23 -0
- tokforge-0.1.0/build.rs +33 -0
- tokforge-0.1.0/docs/superpowers/plans/2026-11-10-phase1-cache-scaling.md +164 -0
- tokforge-0.1.0/docs/superpowers/plans/2026-11-10-phase2-python-package.md +84 -0
- tokforge-0.1.0/docs/superpowers/plans/2026-11-10-resume-ready-roadmap.md +72 -0
- tokforge-0.1.0/examples/core_soak.rs +2542 -0
- tokforge-0.1.0/examples/unicode_tables.rs +210 -0
- tokforge-0.1.0/models/MANIFEST.json +157 -0
- tokforge-0.1.0/models/README.md +57 -0
- tokforge-0.1.0/models/fetch.py +171 -0
- tokforge-0.1.0/pyproject.toml +25 -0
- tokforge-0.1.0/python/Cargo.toml +17 -0
- tokforge-0.1.0/python/README.md +34 -0
- tokforge-0.1.0/python/benchmarks/compare.py +142 -0
- tokforge-0.1.0/python/benchmarks/memory.py +130 -0
- tokforge-0.1.0/python/src/lib.rs +173 -0
- tokforge-0.1.0/python/tests/test_tokforge.py +118 -0
- tokforge-0.1.0/python/tokforge.pyi +37 -0
- tokforge-0.1.0/rust-toolchain.toml +4 -0
- tokforge-0.1.0/scripts/setup.ps1 +102 -0
- tokforge-0.1.0/src/api.rs +272 -0
- tokforge-0.1.0/src/batch.rs +250 -0
- tokforge-0.1.0/src/bytelevel/mod.rs +1131 -0
- tokforge-0.1.0/src/bytelevel/pretokenize.rs +493 -0
- tokforge-0.1.0/src/bytelevel/unicode_tables.rs +3428 -0
- tokforge-0.1.0/src/engine.rs +1226 -0
- tokforge-0.1.0/src/lib.rs +15 -0
- tokforge-0.1.0/src/main.rs +403 -0
- tokforge-0.1.0/src/work.rs +801 -0
- tokforge-0.1.0/tests/api.rs +272 -0
- tokforge-0.1.0/tests/batch.rs +273 -0
- tokforge-0.1.0/tests/bytelevel.rs +1286 -0
- tokforge-0.1.0/tests/cli.rs +228 -0
- tokforge-0.1.0/tests/engine.rs +614 -0
- tokforge-0.1.0/tests/fixtures/corpus/arabic_devanagari.txt +21 -0
- tokforge-0.1.0/tests/fixtures/corpus/ascii_prose.txt +17 -0
- tokforge-0.1.0/tests/fixtures/corpus/cjk.txt +18 -0
- tokforge-0.1.0/tests/fixtures/corpus/code.txt +58 -0
- tokforge-0.1.0/tests/fixtures/corpus/combining_marks.txt +20 -0
- tokforge-0.1.0/tests/fixtures/corpus/control_bytes.txt +0 -0
- tokforge-0.1.0/tests/fixtures/corpus/emoji.txt +16 -0
- tokforge-0.1.0/tests/fixtures/corpus/empty.txt +0 -0
- tokforge-0.1.0/tests/fixtures/corpus/fullwidth_ligatures.txt +17 -0
- tokforge-0.1.0/tests/fixtures/corpus/hangul.txt +16 -0
- tokforge-0.1.0/tests/fixtures/corpus/long_words.txt +11 -0
- tokforge-0.1.0/tests/fixtures/corpus/mixed_multilingual.txt +22 -0
- tokforge-0.1.0/tests/fixtures/corpus/numbers_punctuation.txt +19 -0
- tokforge-0.1.0/tests/fixtures/corpus/special_tokens.txt +22 -0
- tokforge-0.1.0/tests/fixtures/corpus/whitespace.txt +35 -0
- tokforge-0.1.0/tests/fixtures/golden/KNOWN_DIFFERENCES.json +55 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/arabic_devanagari.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/ascii_prose.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/cjk.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/code.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/combining_marks.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/control_bytes.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/emoji.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/empty.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/fullwidth_ligatures.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/hangul.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/long_words.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/mixed_multilingual.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/numbers_punctuation.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/special_tokens.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/bert-base-uncased/whitespace.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/arabic_devanagari.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/ascii_prose.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/cjk.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/code.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/combining_marks.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/control_bytes.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/emoji.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/empty.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/fullwidth_ligatures.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/hangul.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/long_words.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/mixed_multilingual.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/numbers_punctuation.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/special_tokens.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/cl100k_base/whitespace.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/generate.py +365 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/arabic_devanagari.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/ascii_prose.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/cjk.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/code.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/combining_marks.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/control_bytes.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/emoji.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/empty.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/fullwidth_ligatures.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/hangul.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/long_words.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/mixed_multilingual.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/numbers_punctuation.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/special_tokens.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/gpt2/whitespace.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/arabic_devanagari.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/ascii_prose.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/cjk.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/code.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/combining_marks.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/control_bytes.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/emoji.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/empty.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/fullwidth_ligatures.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/hangul.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/long_words.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/mixed_multilingual.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/numbers_punctuation.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/special_tokens.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/o200k_base/whitespace.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/arabic_devanagari.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/ascii_prose.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/cjk.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/code.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/combining_marks.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/control_bytes.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/emoji.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/empty.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/fullwidth_ligatures.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/hangul.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/long_words.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/mixed_multilingual.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/numbers_punctuation.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/special_tokens.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/qwen2.5-0.5b/whitespace.json +29 -0
- tokforge-0.1.0/tests/fixtures/golden/requirements.txt +9 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/arabic_devanagari.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/ascii_prose.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/cjk.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/code.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/combining_marks.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/control_bytes.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/emoji.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/empty.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/fullwidth_ligatures.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/hangul.json +47 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/long_words.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/mixed_multilingual.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/numbers_punctuation.json +43 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/special_tokens.json +45 -0
- tokforge-0.1.0/tests/fixtures/golden/xlm-roberta-base/whitespace.json +47 -0
- tokforge-0.1.0/tests/fixtures/wordpiece.json +27 -0
- tokforge-0.1.0/tests/reference.rs +868 -0
- tokforge-0.1.0/tests/support/mod.rs +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
env:
|
|
9
|
+
CARGO_TERM_COLOR: always
|
|
10
|
+
RUSTFLAGS: -D warnings
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
check:
|
|
14
|
+
name: fmt, clippy, tests (${{ matrix.os }})
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
os: [ubuntu-latest, windows-latest]
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
23
|
+
with:
|
|
24
|
+
components: rustfmt, clippy
|
|
25
|
+
- uses: Swatinem/rust-cache@v2
|
|
26
|
+
- run: cargo fmt --all -- --check
|
|
27
|
+
- run: cargo clippy --all-targets --locked -- -D warnings
|
|
28
|
+
# Reference and differential suites print SKIPPED here: model files are gitignored.
|
|
29
|
+
- run: cargo test --all-targets --locked
|
|
30
|
+
|
|
31
|
+
reference:
|
|
32
|
+
name: reference artifacts and oracle goldens
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
needs: check
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
38
|
+
- uses: Swatinem/rust-cache@v2
|
|
39
|
+
- uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: "3.12"
|
|
42
|
+
- name: Fetch pinned artifacts and oracle files
|
|
43
|
+
run: python -I models/fetch.py
|
|
44
|
+
- name: Verify committed goldens are reproducible
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install -r tests/fixtures/golden/requirements.txt
|
|
47
|
+
python -I tests/fixtures/golden/generate.py --check
|
|
48
|
+
- name: Reference and differential suites must run, not skip
|
|
49
|
+
env:
|
|
50
|
+
FAST_TOKENIZER_REQUIRE_MODELS: "1"
|
|
51
|
+
run: cargo test --release --locked --test reference --test bytelevel -- --show-output
|
|
52
|
+
- name: Python package matches tiktoken on the real GPT-2 artifact
|
|
53
|
+
run: |
|
|
54
|
+
python -m pip install pytest ./python
|
|
55
|
+
python -m pytest python/tests -q -rs
|
|
56
|
+
|
|
57
|
+
python:
|
|
58
|
+
name: python wheel (${{ matrix.os }})
|
|
59
|
+
runs-on: ${{ matrix.os }}
|
|
60
|
+
needs: check
|
|
61
|
+
strategy:
|
|
62
|
+
fail-fast: false
|
|
63
|
+
matrix:
|
|
64
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@v4
|
|
67
|
+
- uses: actions/setup-python@v5
|
|
68
|
+
with:
|
|
69
|
+
python-version: "3.12"
|
|
70
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
71
|
+
with:
|
|
72
|
+
components: clippy
|
|
73
|
+
- uses: Swatinem/rust-cache@v2
|
|
74
|
+
- run: cargo clippy -p tokforge-python --all-targets --locked -- -D warnings
|
|
75
|
+
- uses: PyO3/maturin-action@v1
|
|
76
|
+
with:
|
|
77
|
+
command: build
|
|
78
|
+
args: --release --locked --out dist --manifest-path python/Cargo.toml
|
|
79
|
+
manylinux: auto
|
|
80
|
+
- name: Install the wheel and run the Python tests
|
|
81
|
+
shell: bash
|
|
82
|
+
run: |
|
|
83
|
+
python -m pip install pytest
|
|
84
|
+
python -m pip install --no-index --find-links dist tokforge
|
|
85
|
+
python -m pytest python/tests -q -rs
|
|
86
|
+
- uses: actions/upload-artifact@v4
|
|
87
|
+
with:
|
|
88
|
+
name: wheel-${{ matrix.os }}
|
|
89
|
+
path: dist/*.whl
|
|
90
|
+
|
|
91
|
+
release-binaries:
|
|
92
|
+
name: release binary (${{ matrix.os }})
|
|
93
|
+
runs-on: ${{ matrix.os }}
|
|
94
|
+
needs: check
|
|
95
|
+
strategy:
|
|
96
|
+
matrix:
|
|
97
|
+
include:
|
|
98
|
+
- os: ubuntu-latest
|
|
99
|
+
artifact: tokforge-linux-x86_64
|
|
100
|
+
path: target/release/tokforge
|
|
101
|
+
- os: windows-latest
|
|
102
|
+
artifact: tokforge-windows-x86_64
|
|
103
|
+
path: target/release/tokforge.exe
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/checkout@v4
|
|
106
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
107
|
+
- uses: Swatinem/rust-cache@v2
|
|
108
|
+
- run: cargo build --release --locked
|
|
109
|
+
- run: ${{ matrix.path }} info
|
|
110
|
+
- uses: actions/upload-artifact@v4
|
|
111
|
+
with:
|
|
112
|
+
name: ${{ matrix.artifact }}
|
|
113
|
+
path: ${{ matrix.path }}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Builds abi3 wheels and an sdist, and publishes them to PyPI through trusted
|
|
2
|
+
# publishing (OIDC, no API token) when a v* tag is pushed. Pull requests that
|
|
3
|
+
# touch packaging, and manual runs, build and test everything without
|
|
4
|
+
# publishing.
|
|
5
|
+
name: release
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["v*"]
|
|
10
|
+
pull_request:
|
|
11
|
+
paths:
|
|
12
|
+
- .github/workflows/release.yml
|
|
13
|
+
- python/**
|
|
14
|
+
- Cargo.toml
|
|
15
|
+
- Cargo.lock
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
version:
|
|
23
|
+
name: tag matches crate version
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- shell: bash
|
|
29
|
+
run: |
|
|
30
|
+
crate=$(grep -m1 '^version' python/Cargo.toml | cut -d'"' -f2)
|
|
31
|
+
echo "tag ${GITHUB_REF_NAME#v}, python/Cargo.toml $crate"
|
|
32
|
+
test "${GITHUB_REF_NAME#v}" = "$crate"
|
|
33
|
+
|
|
34
|
+
wheels:
|
|
35
|
+
name: wheel (${{ matrix.os }} ${{ matrix.target }})
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
strategy:
|
|
38
|
+
fail-fast: false
|
|
39
|
+
matrix:
|
|
40
|
+
include:
|
|
41
|
+
- { os: ubuntu-latest, target: x86_64, test: true }
|
|
42
|
+
- { os: ubuntu-latest, target: aarch64, test: false }
|
|
43
|
+
- { os: windows-latest, target: x64, test: true }
|
|
44
|
+
- { os: macos-latest, target: aarch64, test: true }
|
|
45
|
+
- { os: macos-latest, target: x86_64, test: false }
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
- uses: actions/setup-python@v5
|
|
49
|
+
with:
|
|
50
|
+
python-version: "3.12"
|
|
51
|
+
- uses: PyO3/maturin-action@v1
|
|
52
|
+
with:
|
|
53
|
+
command: build
|
|
54
|
+
target: ${{ matrix.target }}
|
|
55
|
+
args: --release --locked --out dist --manifest-path python/Cargo.toml
|
|
56
|
+
manylinux: auto
|
|
57
|
+
# Cross-compiled wheels cannot run on the build machine; the native ones
|
|
58
|
+
# cover the same code.
|
|
59
|
+
- name: Install the wheel and run the Python tests
|
|
60
|
+
if: matrix.test
|
|
61
|
+
shell: bash
|
|
62
|
+
run: |
|
|
63
|
+
python -m pip install pytest
|
|
64
|
+
python -m pip install --no-index --find-links dist tokforge
|
|
65
|
+
python -m pytest python/tests -q -rs
|
|
66
|
+
- uses: actions/upload-artifact@v4
|
|
67
|
+
with:
|
|
68
|
+
name: dist-${{ matrix.os }}-${{ matrix.target }}
|
|
69
|
+
path: dist/*.whl
|
|
70
|
+
|
|
71
|
+
sdist:
|
|
72
|
+
name: sdist
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v4
|
|
76
|
+
- uses: PyO3/maturin-action@v1
|
|
77
|
+
with:
|
|
78
|
+
command: sdist
|
|
79
|
+
args: --out dist --manifest-path python/Cargo.toml
|
|
80
|
+
# The sdist has to carry the parent crate it depends on by path, so
|
|
81
|
+
# prove it builds on its own, away from the checkout.
|
|
82
|
+
- name: Build and import the sdist in isolation
|
|
83
|
+
shell: bash
|
|
84
|
+
run: |
|
|
85
|
+
python -m venv /tmp/sdist-check
|
|
86
|
+
cd /tmp
|
|
87
|
+
/tmp/sdist-check/bin/pip install "$GITHUB_WORKSPACE"/dist/*.tar.gz
|
|
88
|
+
/tmp/sdist-check/bin/python -c "import tokforge; print(tokforge.Tokenizer)"
|
|
89
|
+
- uses: actions/upload-artifact@v4
|
|
90
|
+
with:
|
|
91
|
+
name: dist-sdist
|
|
92
|
+
path: dist/*.tar.gz
|
|
93
|
+
|
|
94
|
+
publish:
|
|
95
|
+
name: publish to PyPI
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
needs: [version, wheels, sdist]
|
|
98
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
99
|
+
environment:
|
|
100
|
+
name: pypi
|
|
101
|
+
url: https://pypi.org/p/tokforge
|
|
102
|
+
permissions:
|
|
103
|
+
id-token: write
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/download-artifact@v4
|
|
106
|
+
with:
|
|
107
|
+
pattern: dist-*
|
|
108
|
+
path: dist
|
|
109
|
+
merge-multiple: true
|
|
110
|
+
- run: ls -l dist
|
|
111
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
112
|
+
|
|
113
|
+
github-release:
|
|
114
|
+
name: GitHub release
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
needs: publish
|
|
117
|
+
permissions:
|
|
118
|
+
contents: write
|
|
119
|
+
steps:
|
|
120
|
+
- uses: actions/download-artifact@v4
|
|
121
|
+
with:
|
|
122
|
+
pattern: dist-*
|
|
123
|
+
path: dist
|
|
124
|
+
merge-multiple: true
|
|
125
|
+
- env:
|
|
126
|
+
GH_TOKEN: ${{ github.token }}
|
|
127
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes
|
tokforge-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Project priorities
|
|
2
|
+
|
|
3
|
+
The user's primary goal is a performance-oriented Rust tokenizer and document
|
|
4
|
+
preparation engine, while learning Rust. Treat runtime efficiency and bounded
|
|
5
|
+
resource use as core requirements, alongside correctness.
|
|
6
|
+
|
|
7
|
+
- Measure performance in release builds. Read PERFORMANCE.md and use the
|
|
8
|
+
benchmark runner before and after changes to hot paths. Keep the workload,
|
|
9
|
+
artifact, toolchain, and machine comparable; report limits of synthetic data.
|
|
10
|
+
- Prefer algorithmic improvements, fewer allocations/copies, reused model state,
|
|
11
|
+
bounded CPU work, and buffered I/O. Keep CPU work off async runtime threads.
|
|
12
|
+
- Preserve verified token budgets, original source byte ranges, Unicode scalar
|
|
13
|
+
boundaries, deterministic special-token behavior, ordering, and cancellation.
|
|
14
|
+
- Keep general no-fit fallback correct for nonmonotonic token counts; do not
|
|
15
|
+
silently assume that longer text always produces more tokens.
|
|
16
|
+
- Add caches, more concurrency, native CPU flags, or unsafe code only when
|
|
17
|
+
profiling and benchmarks support the change. Explain important Rust ownership
|
|
18
|
+
and concurrency choices briefly so the user can learn from the implementation.
|
|
19
|
+
- Validate changes with cargo fmt, cargo clippy --all-targets -- -D warnings,
|
|
20
|
+
and the relevant correctness/integration tests.
|