The same answer on every chip: an ML framework whose compiled programs are checked against float64.
Install · 30 seconds · What's in it · Speed · Docs · Changelog
Build, train, serve and deploy models that give the right answer, the same answer, on every chip. Truestar is a complete machine learning framework: its own front end and typed IR, autodiff, a kernel compiler, a training stack, multi GPU parallelism, a serving engine and export to phones and laptops. What sets it apart is one rule applied everywhere: a result is only as good as its distance from the exact answer, so every compiled program, training steps included, is checked against float64 on its first call, and the parts that promise identical bits across devices prove it.
This page describes version 0.2.1, the version pip install truestar gives. Rows marked 0.2
are new in this release (CHANGELOG). Every number here links to the doc it comes
from, and losses are listed next to the wins.
pip install truestar
Python 3.10 or newer (3.10 and 3.12 run in CI on Linux and Windows) and PyTorch >=2.11,<2.16
(2.11, 2.14.1 and 2.15.0 tested). Install PyTorch the way pytorch.org says for your machine first.
The checkers are pure Python: no CUDA toolkit, no compiler.
pip install "truestar[cpu-kernels]" # numba, for the compiler's CPU kernels
pip install "truestar[mcp]" # official MCP SDK for `truestar mcp` (a builtin server is used without it)
pip install "truestar[onnx]" # `truestar export --to onnx` and ONNX Runtime backends
pip install "truestar[litert]" # `truestar export --to litert`
pip install "truestar[executorch]" # `truestar export --to executorch` (must match your torch)
pip install "truestar[serving]" # safetensors, for `truestar conform serving`
GPU kernels are written in Triton. PyTorch's CUDA wheels for Linux bring Triton with them; on
Windows install the community triton-windows package in the version its README pairs with your
PyTorch. Without Triton the checkers still work; the compiled executor on cuda does not.
The examples come with a checkout:
git clone https://github.com/SharvenRane/truestar
cd truestar
pip install ".[cpu-kernels]"
python examples/quickstart.py # a verified compiled training step, then a call to the server
truestar check examples/cpu_check.py
GETTING_STARTED.md walks through both, from an empty venv, in ten minutes on a CPU. No environment variable is needed; SWITCHES.md lists every one.
examples/check_model.py is a small net with a hand written layer norm that computes the variance
as mean(x * x) - mean(x) ** 2. Its inputs sit near 3000, where that subtraction loses every digit
in float32:
$ truestar check examples/check_model.py --backends cpu,cuda
truestar check: check_model (float32), reference CPU float64
[DIVERGENT] cpu: CPU TS010 TS013
note: op drilldown on norm#0: no single ATen op was confirmed wrong for its own inputs; the formula
loses its digits at aten.sub.Tensor (op 5 of 10, amplification 9.1e+06), so the module's own math
is what to change, not that op.
final output: relative error 1.0e+02
TS013 decisions: 2/8 predictions changed (0 near ties, 2 real)
TS010 first divergent module: norm#0 (OnePassNorm), own error 9.7e+01 vs threshold 1.0e-04
source: examples/check_model.py:17 (check_model.OnePassNorm)
repro: python truestar_repro/cpu_norm_0/repro.py
modules over threshold: 1 of 3 checked
DIVERGENT norm#0 own 9.7e+01 accumulated 9.7e+01 threshold 1.0e-04
[DIVERGENT] cuda: NVIDIA GeForce RTX 5070 Ti, CUDA 12.8 TS010 TS013
note: op drilldown on norm#0: no single ATen op was confirmed wrong for its own inputs.
final output: relative error 1.2e+02
TS010 first divergent module: norm#0 (OnePassNorm), own error 1.5e+02 vs threshold 5.0e-03
source: examples/check_model.py:17 (check_model.OnePassNorm)
repro: python truestar_repro/cuda_norm_0/repro.py
...
overall: DIVERGENT
Real output from 2026-11-24 (Windows, torch 2.11, RTX 5070 Ti; paths shortened, lines cut and
wrapped; the CPU part is from 2026-11-28). The
run took 2.9 s and exits 1. Each generated repro.py needs only PyTorch and exits 1 while the
divergence is there.
The method: the model runs once in float64 on CPU as the reference. Every module is then replayed alone on each backend with the reference inputs, so the error a module shows is its own and never inherited. Thresholds are fixed floors per precision, raised on backends other than the CPU to 10x the error a correct CPU run shows on the same module, and each output is judged by its whole tensor error and by its worst element and slice (TOLERANCE). Inside the blamed module, ATen ops are traced on both sides and the first op whose own error crosses its threshold is named.
A model file defines get_model() (an nn.Module), get_inputs() (a tensor or a tuple) and
optionally get_kwargs(). Exit codes: 0 clean, 1 a finding, 2 a usage error. From Python:
import truestar
report = truestar.check(model, inputs) # every backend on this machine
print(report.to_text())Maturity words: shipped is a command or API in the released package with docs and tests; library is tested Python API that may still change; experimental is opt in or partial; not run on hardware means the code exists and its tests pass, but the device itself has not run it. Each doc ends with a Limits section.
| area | what is there | maturity | docs |
|---|---|---|---|
| Write models | @truestar.function: a native front end with typed shapes, loops and branches compiled from Python source into a shape typed IR; reverse mode autodiff through cond, loop and while; vmap, jvp, jacfwd, jacrev as program transformations; truestar.torch_op registers native functions as PyTorch ops |
library | FRONTEND, IR, AUTODIFF, TRANSFORMS, CUSTOM_OPS |
| Compile | a loop level kernel IR with fusion, Triton (GPU) and numba (CPU) code generation, launch config autotuning, dynamic shape ranges and a persistent verified compile cache | library | KERNEL_IR, COMPILER, DYNAMIC_SHAPES |
| Lumen | Truestar's own kernel language: typed reductions and MMA semantics, a CPU spec emulator, tile kernels compiled to PTX 0.2 | experimental: opt in with TRUESTAR_LUMEN=1; contractions and attention still go to Triton |
LUMEN |
| Train | losses; SGD, Adam, AdamW, Muon, Lion, RMSprop, Adagrad and Adafactor 0.2; schedules; compiled mixed precision (autocast policy and loss scaling); a compiled training step with CUDA graph replay; LoRA and QLoRA; deterministic resumable data loaders | library | TRAINING, OPTIM, LORA, DATA |
| Multi GPU | data parallel, tensor parallel, sequence parallel, gradient accumulation and sharded state | library: run on 2 x T4, 4 x A10G in one machine and 2 machines with one GPU each; no NVLink, no multi node NCCL | PARALLEL, TRAINING |
| Runtime | CUDA graph capture with bitwise replay checks, graphed compiled programs, the layer behind a CUDA OOM and the rank behind a hang | library | RUNTIME, DIAGNOSTICS |
| Native runtime | import truestar never imports torch; its own Tensor, a ctypes CUDA driver, an arena and pool, DLPack and Triton launches without torch 0.2 |
EXPERIMENTAL: the compiler and executor do not use it yet, its API may change, and torch is still a dependency | RUNTIME_NATIVE |
| Models | mixture of experts, DeepSeek V3 latent attention, linear attention and state space kernels, speculative decoding bitwise equal to greedy | library | MOE, MLA, LINEAR_ATTENTION, SPEC_DECODE |
| Serve | truestar serve: an OpenAI compatible HTTP server (completions, chat, models) on a paged KV cache with continuous batching and chunked prefill, whose answers do not change with batching or the prefix cache, checked bit for bit |
experimental: small random weight models and a byte tokenizer, no checkpoint loading | SERVE, LLM |
| Deploy | .tsx artifacts written only when they match PyTorch at two batch sizes; --to onnx, litert and executorch files are run and verified when written; --to coreml writes the file |
shipped; the Core ML runtime check needs a Mac | EXPORT |
| Phone NPUs | hosted Snapdragon phones through Qualcomm AI Hub, judged against float64 | experimental: needs an AI Hub account | QAIHUB, NPU |
| Import | PyTorch through torch.export; ONNX (one way, 64 op types) 0.2; local Hugging Face decoder checkpoints from their config.json and safetensors |
library | IR, ONNX_IMPORT, MODELS |
| Check | truestar check and --backward, record and diff, invariance, port, kernel, conform, range, fix; agent JSON with stable TS codes |
shipped | GETTING_STARTED, KERNEL_CHECK |
| Apple GPUs | a Metal backend for the compiled executor | library: run on a real Mac mini M2 (Metal tests 109 passed, 1 skipped) | METAL |
| AMD GPUs | ROCm code paths compiled for gfx942, gfx1100 and gfx1103 | not run on hardware | ROCM |
| TPUs | truestar conform tpu judges a fixed op battery from files written on the device |
the judge is tested; no TPU run yet | TPU |
A native program, with a loop over a symbolic length and a branch on tensor data, differentiated through both:
import torch
import truestar
from truestar import Tensor, ops
@truestar.function
def rnn_loss(params: {"wx": Tensor[4, 5], "wh": Tensor[5, 5]}, x: Tensor["B", "T", 4],
y: Tensor["B", 5]) -> Tensor[()]:
h = ops.zeros((x.shape[0], 5))
for t in range(x.shape[1]): # a loop over a symbolic length
h = ops.tanh(x[:, t] @ params["wx"] + h @ params["wh"])
if h.mean() > 0: # a branch on tensor data
h = h * 2.0
return ((h - y) * (h - y)).mean()
params = {"wx": torch.randn(4, 5), "wh": torch.randn(5, 5) * 0.5}
x, y = torch.randn(3, 7, 4), torch.randn(3, 5)
loss, g = truestar.grad(rnn_loss, wrt="params")(params, x, y) # g["wx"], g["wh"]Any batch size and sequence length run the same compiled program.
- Every compiled program, training steps included, is checked against float64 on its first call (COMPILER).
- Portable tensor cores give the same float16, bfloat16 and TF32 bits on every NVIDIA generation from sm_80 on, with the exact window proved in Lean 4 (PORTABLE_TC, PROOFS).
- Data and tensor parallel results are bitwise equal to one device adding the same pieces in rank order, measured on 4 x A10G for data parallel (PARALLEL, TRAINING Scaling against torch DDP).
- Lumen, a kernel language whose generated code is checked against its declared numerics (LUMEN).
- One checker for llama.cpp, vLLM, SGLang, Core ML and phone NPUs against float64, with per layer blame on the NPU and the faulty tensor named for llama.cpp (CONFORM, CONFORM_LLAMACPP, CONFORM_SERVING, COREML, NPU).
- It tells an ill conditioned formula from a broken chip: TS015 reports SUSPECT when the exact math itself amplifies one rounding that much (FAQ, TOLERANCE).
From one fair benchmark: an idle RTX 5070 Ti (2026-11-24, Truestar commit 95d84e1, Windows,
PyTorch 2.11, Triton 3.7.1), the same weights and inputs for every framework, TF32 off in float32
rows, every baseline in its recommended mode (eager with CUDA graphs, torch.compile default and
max-autotune, SDPA with each backend forced, JAX jit, TensorFlow XLA), and Truestar as shipped
with its first call float64 check on. Median of 250 pipelined samples; ratio is the best other
framework's time over Truestar's, so above 1 means Truestar is faster. The full report with every
table is in the author's research notes and not in this repository yet. A fresh benchmark on the
0.2 release commit will be published in docs/bench/.
| Wins and ties | Losses |
|---|---|
resnet18 inference, float32: 5.62 ms against torch.compile max-autotune 7.07 ms, 1.26x (cold L2 single call: 5.64 against 7.13 ms) |
Decode attention, bfloat16: 0.29x to 0.76x of cuDNN SDPA |
| Causal attention, bfloat16 (B4 H16 S2048 D64): 0.379 ms against cuDNN SDPA 0.443 ms, 1.17x pipelined and 1.08x as a single cold call, same output error; not confirmed with a profiler yet | Llama style decode step with CUDA graphs: 0.48x to 0.83x of the best framework |
| Matmul 4096^3: a tie with cuBLAS in float32 (0.99x), TF32 (1.02x, with 2.7x cuBLAS's error) and bfloat16 (1.00x) | MLP inference, float32: 0.80x; encoder layer float32 0.92x; resnet18 bfloat16 0.81x of JAX |
Cold compile to the first result beats torch.compile max-autotune: MLP 8.2 s against 18 s, resnet18 37 s against 51 s, decode step 3.8 to 4.8 s against 28 to 31 s |
Warm start from the cache (1.4 to 4.7 s) is never the fastest: JAX and TensorFlow reload in under 1 s |
Training is not in this result: at that commit the first call check refused 11 of the 12 training rows. That fixed bar has since been replaced by a bound derived from the program (COMPILER); a fair rerun of training is pending.
- Same bits across GPU generations. With
deterministic=Trueand TF32 off, compiled float32 outputs were bitwise identical on an RTX 5070 Ti and a Tesla T4 for an MLP, a TransformerEncoderLayer and a Llama style decode step at four batch sizes (12 of 12 rows), where eager PyTorch and torch.compile differed in every row; a second run matched on A10G, L4, L40S, H100 and an RTX 5060 laptop (CROSS_CHIP). - Held out kernels.
truestar kernelon 403 kernels written outside this project (KernelBench samples and METR's KernelBenchFiltered, Modal L4): false fails 3.6% on both sets against 35.1% and 38.1% fortorch.testing.assert_close; false passes 6.4% (KernelBench, assert_close 9.2%) and 7.1% (METR, the same as assert_close). 54 kernels did not finish (memory, build or time) (KERNEL_CHECK, results/heldout_runs/). - Real Apple hardware. On a Mac mini M2 the copy
t.to("cpu", torch.float64)from MPS returned all zeros with torch 2.14.1 and raised with 2.15.0 (METAL section 5).
- Hardware actually run: CPU and an RTX 5070 Ti on Windows, an RTX 5060 laptop GPU, Tesla T4 and Modal L4, A10G, L40S and H100 GPUs on Linux, Linux and Windows CPU in CI, and a Mac mini M2 (the full suite there still had 13 failures and 3 errors, METAL section 5). AMD and Intel GPUs and TPUs have not run Truestar.
- Speed: the losses above are real; decode is the weakest area.
- The compiled training step is not wired into
Traineryet; models are imported in their eval form, so training mode batch norm and dropout are not expressible (TRAINING). - Compiled kernels are verified on the first call per shape signature in each process: data
dependent faults on later calls with the same shapes are not seen unless
TRUESTAR_VERIFY=all. - The checker's float64 reference is float64 only where the model lets it be: explicit casts round it at those points, and PyTorch CPU float64 kernel bugs are inherited. Gradients are judged by their whole tensor error only (GRAD_CHECK).
recordanddiffwere proven with injected changes and TF32 in one environment; two real torch versions have not been compared yet.- macOS install is not in CI. Python 3.11 and 3.13 are not tested.
check, record, diff, invariance and port take --format agent and print one versioned
JSON document with stable TS codes, the blamed file and line, and a next_actions list with
shell commands. truestar mcp exposes the same checks as MCP tools. Start with
AGENTS.md; the schema is in docs/AGENT_INTERFACE.md.
They make one platform fast or repeatable; Truestar asks whether the answer is right on every platform, and treats Inductor, ONNX Runtime and TensorRT as backends to check. Details and sources: docs/FAQ.md.
Truestar builds on, borrows ideas from, or is checked against:
- Batch invariant kernels: Thinking Machines Lab, "Defeating Nondeterminism in LLM Inference" and batch_invariant_ops; SGLang's deterministic inference; vLLM's batch invariance and its bitwise consistent trainer and sampler work.
- Keyed, counter based random numbers: JAX's PRNG keys (Threefry) and the Philox and Threefry generators of Salmon et al., "Parallel random numbers: as easy as 1, 2, 3" (SC 2011). SplitMix64 (Steele, Lea and Flood, 2014). Normal draws use Acklam's and Wichura's (AS241) published approximations.
- Triton, which generates Truestar's GPU kernels outside Lumen; the Triton fused attention tutorial and FlashAttention (Dao et al.) for the attention schedule.
- ONNX Runtime, TensorRT and Polygraphy, torch.compile and Inductor, FlexAttention, LiteRT, ExecuTorch and llama.cpp, all run or checked as backends and engines.
- Integer rounding conventions from gemmlowp, CMSIS-NN and TFLite, reproduced bit for bit by
truestar intref. - DLPack and safetensors for interop; numba for CPU kernels.
- Held out test data: KernelBench (MIT) and its kernelbench-samples dataset (Apache 2.0), stored with attribution in tests/data/heldout/kernelbench/; METR's KernelBenchFiltered is downloaded on demand and not redistributed.
- The evidence for the pain ledger: PyTorch's reproducibility notes, NVIDIA's cuDNN determinism notes, "Mind the Gap" (arXiv 2511.11601), KernelBench (Stanford) and HUD's YAKK, and the issue threads cited row by row in docs/QUALITY_BAR.md.
Apache 2.0, see LICENSE. Author: Sharven Rane. No telemetry: nothing leaves the machine unless you share a report. Security issues: see SECURITY.md.
