TokenVector.Inference is a deep learning runtime written in TokenVector
(.tkv) — inference (graph optimization, quantization, micro-serving) and
GPT2-medium / GPT-2 124M training engines benchmarked head-to-head against
PyTorch (latest numbers verified 2026-11-28, see below).
Current status, verified 2026-11-28 (Kaggle T4, HEAD
1da48ef):
- GPT2-medium real weights, 12 updates per side: PyTorch eager
465.2 ms/step, loss0.1457; TokenVector.tkv222.4 ms/step(2.09x), loss0.1693, 0 increasing steps. TKV loss is still 0.0236 nats higher — theTKV <= PyTorchtarget is NOT met.- TKV self-saves weights via
fwriteP/Invoke and reloads them for CE / generation: train0.1275, held-out8.1774(baseline4.0695) → memorization of the repeated batch, not real language learning.- Historical GPU full-step (2026-11-20): 40.0 ms/step @seq1024 vs torch 289.1 ms (~7.2x), @seq2048
212.6vs599.5ms (~2.8x). Native CPU EXACT path unchanged. Details:docs/BENCHMARK_GUIDE.md.- Sources are
.tkv; no C++/torch in the TKV execution path.
docs/internal/HANDOFF.mdis the running engineering journal (append-only). Every known gap, and every wrong turn taken to find them, is documented there.
| Area | State |
|---|---|
| Inference runtime (graph, PTQ INT8/FP8, ONNX reader, batcher) | Working, tested; see docs/TEST_REPORT.md |
| GPT-2 124M training (fwd/bwd/AdamW/clip/checkpoint) | Working; see benchmark/BENCHMARKS.md |
| Native SIMD kernels (GEMM, fused bwd, AdamW) | Shipped via compiler repo (tkv_simd_native.dll) |
| GPU full-step (T4) | 7.2x faster than eager torch @seq1024 (40.0 vs 289.1 ms); native CPU path unchanged |
| GPT2-medium real-weight trainer (16-head, CUDA/cuBLAS + PTX, no C++/torch) | 2.09x vs eager torch @12 updates; self-saves weights; see benchmark/README.md |
-
TokenVector compiler, current self-hosted build (referred to here as
$tkvc). The reference build isD:\TokenVector\Release\dist\tkvc-tv.exe. -
.NET 10 runtime to run the compiled executables.
tkvc-tvdoes not emit a.runtimeconfig.jsonnext to the output — without it you gethostpolicy.dll not found. Create one:{"runtimeOptions":{"tfm":"net10.0","framework":{"name":"Microsoft.NETCore.App","version":"10.0.0"}}}(or run via
dotnet <app>.exewith the file present, cf.benchmark/README.md).
src/ TokenVector sources (engine)
runtime/ graph runtime, session, arena, SIMD matmul (.tkv)
training/ autograd, AdamW/clip, GPT-2 124M reference (.tkv)
tests/ gate suites (fixtures not committed; see below)
tools/ CLI, trainer demo
tools/ host-side verification: gate_f32.sh (135/135), run_cases.ps1,
verify_*.ps1 (parity), fixture generators (gen_*.py)
benchmark/ final benchmark: scripts + notebooks + README.md guide
docs/ user-facing docs; docs/internal/ = dev logs
packaging/ NuGet packaging (TokenVector.Inference.nuspec, pack.ps1) — build via packaging/pack.ps1
demo/ 2 Kaggle notebooks: benchmark + independent TKV train/test (see benchmark/README.md)
benchmark/README.md huong dan benchmark (EN/VI)
docs/internal/HANDOFF.md engineering journal (append-only)
GPT-2 124M parity fixtures (~2.3 GB) are not in git; regenerate with
python tools/gen_gpt2_fixture.py (see docs/internal/handoff-gpt2-124m-fixture-design.md).
$tkvc = "D:\TokenVector\Release\dist\tkvc-tv.exe"
# Inference quickstart (graph -> session -> one forward pass)
& $tkvc src/examples/quickstart.tkv benchmark/quickstart.exe main
Set-Content benchmark/quickstart.runtimeconfig.json '{"runtimeOptions":{"tfm":"net10.0","framework":{"name":"Microsoft.NETCore.App","version":"10.0.0"}}}'
dotnet benchmark/quickstart.exe # prints: Y[0] = 2.25 / quickstart: OKThe API is graph-based; there is no src.inference.load_onnx() and no
NDArray. See USER_GUIDE.md for the API walkthrough and
docs/TOKENVECTOR_SYNTAX_SPEC.md for the language rules that bite (module-level
constants are not importable; record __init__ is skipped; TkvInt …).
$tkvc = "D:\TokenVector\Release\dist\tkvc-tv.exe"
# Inference case suites (each case in its own process)
powershell -File tools\run_cases.ps1 -Compiler $tkvc
# f32 kernel gate, 10 suites, 135 assertions
bash tools/gate_f32.sh
# Trainer gate (MLP, AdamW vs PyTorch reference): 15/15 expected
& $tkvc src/tests/trainer_tests.tkv benchmark\trainer_tests.exe main
dotnet benchmark\trainer_tests.exeXem benchmark/README.md de chay lai (Kaggle T4, GPT2-medium, 12 update):
python benchmark/train_real.py <repo> # PyTorch vs TokenVector
python benchmark/train_tkv_only.py <repo> 2e-4 # chi TKV + tu luu weight
python benchmark/test_trained.py # test model PyTorch
python benchmark/test_tkv_trained.py # test weight do TKV luudocs/BENCHMARK_GUIDE.md- how to reproduce GPU/CPU benchmarks (Colab T4)docs/DEVELOPMENT_HISTORY.md- repo development history (2026-09 → 2026-11)demo/KAGGLE_TKV_INDEPENDENT_2026-11-28.ipynb- train AI with TKV only + self-saved weightsdocs/internal/HANDOFF.md— engineering journal, every investigation and wrong turnUSER_GUIDE.md/USER_GUIDE_VI.md— API user guideTOKENVECTOR_SYNTAX_SPEC(_VI).md— language syntax rulesdocs/internal/COMPILER-NOTES-2026-10-16.md— compiler team notes (2026-10-16)docs/numerics-contract.md— fp32 numerics contract (what is/ isn't bit-exact vs PyTorch)docs/internal/COMPILER_TEAM_REQUEST*.md— requests to the compiler team (#1–#14)RELEASE_NOTES(_VI).md— release historydocs/internal/ROADMAP_TRAIN.md— training roadmap (campaign complete)
TokenVector is a next-generation AI/HPC ecosystem built on the .tkv
language and tkvc compiler:
TokenVector— language & compilerTokenVector.Numerics— NDArray / linear algebraTokenVector.Vision— 2D & 3D volumetric visionTokenVector.Text— tokenization, embeddings, LLM preprocessingTokenVector.Data— double-buffered data pipeline- TokenVector.Inference — this repo: inference runtime + GPT-2 124M training
