Sentinel
Sentinel is a C++/CUDA library for full-train causal language models on a single consumer GPU — no LoRA, no PyTorch/TensorFlow runtime, no cuDNN.
You get a linkable C++ library (Sentinel::sentinel), small CLI examples, and a pip package (sentinel-lm, import name sentinel).
| Engine runtime deps | CUDA toolkit (cuBLAS / cuBLASLt), OpenMP, C++20 stdlib |
| Not required at train/infer | cuDNN, PyTorch, TensorFlow, other DL frameworks |
| Python package | Build needs scikit-build-core + nanobind + CMake + CUDA compiler; no extra PyPI runtime deps |
The “zero-dependency” blurb means the engine, not the optional Python build toolchain.
Install
Python (sentinel-lm)
Needs a CUDA 13.x toolkit on the build machine and at runtime (matching driver). On Windows, import sentinel adds $CUDA_PATH\bin\x64 (and bin) via os.add_dll_directory.
# From a release / PyPI (when published):
pip install sentinel-lm
# From this repo:
pip install .
# Editable while hacking bindings:
pip install -e . --no-build-isolation
Windows tip: if pip cannot find CMake, use a VS x64 Native Tools shell, or prepend the VS CMake bin:
$env:PATH = "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;$env:CUDA_PATH\bin;$env:PATH"
pip install -e . --no-build-isolation
Faster local wheel (your GPU only):
pip install . -C cmake.define.SENTINEL_CUDA_ARCHITECTURES=native
C++ (CMake)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
cmake --install build --prefix /path/to/prefix
find_package(Sentinel 0.1 REQUIRED)
target_link_libraries(my_app PRIVATE Sentinel::sentinel)
# #include "NeuralNet/Network/LanguageModel.hpp"
| Option | Default | Meaning |
|---|---|---|
SENTINEL_CUDA_ARCHITECTURES |
75;80;86;89;120 |
Fat binary (native = host GPU) |
SENTINEL_BUILD_SHARED |
OFF |
Shared instead of static |
SENTINEL_BUILD_DEMO |
ON |
sentinel harness (main.cpp) |
SENTINEL_BUILD_EXAMPLES |
ON |
sentinel_train_tiny, sentinel_generate |
SENTINEL_BUILD_PYTHON |
OFF (ON via pip) |
nanobind sentinel._core |
SENTINEL_INSTALL |
ON |
Install / find_package export rules |
Requirements: Windows or Linux x86_64 · C++20 · CMake ≥ 3.24 · CUDA 13.x · GeForce 20/30/40/50 (sm_75 … sm_120) · OpenMP · Python ≥ 3.10 only for the pip package.
Quickstart (Python)
import sentinel as S
tok = S.BPETokenizer()
tok.train(["the cat sat on the mat", "cuda packs batches"], vocab_size=256)
data = S.LanguageModelDataset.build(["the cat sat on the mat"], tok, maximum_token_count=48)
model = S.LanguageModel(tok.vocab_size, embedding_dim=64, maximum_position_count=64, learning_rate=3e-3)
if S.cuda_available():
model.enable_cuda()
model.set_prefer_flash_attention(True)
model.enable_cuda_train()
model.train(data, epochs=4, batch_size=4)
model.save_safetensors("toy.safetensors")
print(tok.decode(model.generate(tok.encode("the"), new_token_count=16)))
python examples/python/train_tiny.py
python examples/python/generate.py tiny_demo.snlm "the cat"
python examples/python/train_jsonl.py examples/data/sample.jsonl --out run.safetensors
python examples/python/finetune_hf.py --demo --out hf_demo_out
Quickstart (C++)
./build/bin/sentinel_train_tiny tiny_demo.snlm
./build/bin/sentinel_generate tiny_demo.snlm "the cat"
#include "NeuralNet/Network/LanguageModel.hpp"
#include "NeuralNet/Data/LanguageModelDataset.hpp"
#include "NeuralNet/Tokenizer/BPETokenizer.hpp"
#include "NeuralNet/Optimizers/Adam.hpp"
BPETokenizer tok;
tok.train(corpus, 256);
auto train = LanguageModelDataset::build(corpus, tok, 48, false);
LanguageModel model(tok.vocabSize(), 64, 64, Adam(3e-3f), 2, 4);
model.enableCuda();
model.enableCudaTrain();
model.train(train, /*test=*/{}, 4, 1, 4, 1);
model.saveSafeTensors("toy.safetensors");
Streaming corpora (JSONL / HF Arrow): LanguageModelChunkSource + train / train_chunks on C++ and Python (iter_train_chunks / take_train_chunk helpers). JSONL fields: problem_statement, text, or content. See examples/python/train_chunks.py.
Docs / Public API (v0.1)
Full reference:
| docs/ | Index |
| docs/python.md | Python (import sentinel) |
| docs/cpp.md | C++ (Sentinel::sentinel) |
| docs/huggingface.md | HF causal-LM import / export + tokenizer |
Treat those pages as the supported surface. The sentinel demo harness (main.cpp) is for smokes/benches — not the API contract.
Python (summary): high-level LanguageModel train / train_chunks / generate / I/O plus mid-level ops — Matrix, Attention/FFN/layers, Adam/Spulse, Softmax/CE, accumulate_example/train_step, LanguageModelChunkSource / JsonlLoader, SafeTensors helpers, SentinelModelConfig.
C++ (summary): LanguageModel.hpp (incl. loadHuggingFace / loadGguf / loadSentinelModel), LanguageModelDataset.hpp, LanguageModelChunkSource.hpp (streaming), BPETokenizer.hpp, HfTokenizer.hpp, SafeTensors.hpp, Gguf.hpp, SentinelModelConfig.hpp, HuggingFaceConfig.hpp / HuggingFaceWeights.hpp / HuggingFaceResolve.hpp, CudaSbao.hpp.
Training knobs (short)
Defaults aim at throughput when VRAM fits. Large models on 16 GB typically need host offload.
| Knob | Notes |
|---|---|
| Flash attention | Prefer on (set_prefer_flash_attention(True)) |
| AMP | FP16 GEMMs when CUDA train is on |
| Pack budget | Auto from free VRAM; override with set_max_packed_columns |
| Activation ckpt | Off = fastest when acts fit; Full/Selective when VRAM-tight |
| SBAO | Auto: GpuInt8Adam if resident fit, else HostFusedHalfAdam, else HostFusedHalfSgd (e.g. ~4B on 16 GB) |
| SPULSE | Opt-in optimizer (not SBAO): dual-horizon energy-scaled momentum. Hybrid = hidden 2D + Adam aux; Full = all params (set_spulse_coverage). Host Hybrid keeps u on GPU + half-delta D2H. u storage: Fp32/Fp16/Int8 via set_spulse_momentum_storage. set_prefer_spulse(True) before enable_cuda_train |
| Weight tying | On (LM head shares token embedding) |
| CUDA graphs | Only with checkpointing Off and stable shapes |
HostSGD path (4B-style): FP16 weights on GPU, FP32 masters on host, fused FP16 grad D2H + async host SGD (no Adam m/v).
model.set_prefer_host_sgd(True) # or set_sbao_mode(S.SbaoMode.HostFusedHalfSgd)
model.enable_cuda_train()
model.set_activation_checkpoint_mode(S.ActivationCheckpointMode.Full)
Checkpoints
| Format | Contents |
|---|---|
.snlm |
Native weights + optional optimizer (Adam/Muon) |
.safetensors |
Weights only, HF-compatible names + arch metadata |
.gguf |
GGUF v3 (llama.cpp names; F32 export, F32/F16/BF16 import) — see docs/gguf.md |
model.json / .yaml |
Native sentinel-model arch config (+ optional weights path) |
.sbpe |
BPE tokenizer (BPETokenizer::save / load) — keep as {stem}.sbpe next to weights |
model = S.LanguageModel.from_config("examples/configs/tiny.json")
model.save_checkpoint("run.snlm", include_optimizer=True)
model.save_safetensors("run.safetensors")
model.save_sentinel_config("run.json") # weights left empty; set cfg.weights if desired
tok.save("run.sbpe")
model.load_checkpoint("run.safetensors") # also accepts .safetensors
tok.load("run.sbpe")
Performance (indicative)
Measured on RTX 5070 Ti 16 GB (WDDM). Desktop clocks and pack budget matter — re-measure after train-path changes. Paper / cross-lib runners: benchmarks/.
| Shape | Setup | ~tok/s |
|---|---|---|
| ~60M (8×768) | Selective ckpt, int8 Adam, flash | ~18–20k |
| ~97M (12×768) | ckpt Off, int8 Adam, flash | ~25–26k |
| ~4B (34×3072) | HostFusedHalfSgd, Full ckpt, pack 8 @ seq 512 | ~950–1000 |
Probe: benchmarks/_lib/probe_4b_safe.py or LanguageModel.probe_cuda_packed_train_tokens_per_second.
Layout
| Path | Role |
|---|---|
CMakeLists.txt / cmake/ |
Library, install, find_package(Sentinel) |
pyproject.toml / python/sentinel/ |
pip package sentinel-lm |
sentinel/NeuralNet/ |
Engine sources |
sentinel/main.cpp |
Smoke / scale harness (not public API) |
examples/ |
C++ + Python usage (no external data required) |
docs/ |
Python + C++ API reference |
benchmarks/ |
Paper comparisons + 4B probe |
Publishing wheels
Workflow: .github/workflows/publish.yml — sdist + cp310–cp312 wheels (Linux manylinux + Windows), CUDA 13 on the runner. Publish on GitHub Release or workflow_dispatch. Wheels do not bundle the CUDA runtime.
Verify
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j
./build/bin/sentinel_train_tiny
./build/bin/sentinel_generate tiny_demo.snlm "the cat"
python examples/python/train_tiny.py
Contributing
See CONTRIBUTING.md. Changes that touch the CUDA train path should include a before/after probe — no speculative “speed” stacks without a measured keep/revert gate.
License
MIT — LICENSE.md.
Metadata
Release files for sentinel-lm 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sentinel_lm-0.2.0.tar.gz | 530.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| sentinel_lm-0.2.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| sentinel_lm-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.34+ x86-64 | Details |
| sentinel_lm-0.2.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| sentinel_lm-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.34+ x86-64 | Details |
| sentinel_lm-0.2.0-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| sentinel_lm-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.34+ x86-64 | Details |
Total release size: 17.2 MB
Release files / sentinel_lm-0.2.0.tar.gz
| Download URL | sentinel_lm-0.2.0.tar.gz |
|---|---|
| Size | 530.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1e63a8e187547414fc590e15c8764093874a105cc24b7df2d419a0d4f6ce70b
|
|
BLAKE2b-256 checksum How to use checksums |
7b84c8cc01ee3a675af2824771335a72c291cb7a115f2f8859314f97a1a5ee5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | sentinel_lm-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
19951caca6a5ec326a4436ba940f010e8b04506e5e7db23add23c862bfa85efd
|
|
BLAKE2b-256 checksum How to use checksums |
9fafaa09ad82bc35ae2dc680caf9936bb6e0e46db4c03e1740f6c02f4e3d0f83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | sentinel_lm-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
bfc67e3caf73b55eb4c5ee5565c784830280f5c9de0a0880235cb949213fe537
|
|
BLAKE2b-256 checksum How to use checksums |
72863142660796ab4275eed23c0aebd2b8354b5716a26a5bf915b0335b3b3201
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp311-cp311-win_amd64.whl
| Download URL | sentinel_lm-0.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5ebb51aaf7ee07f306f465519d41eb6c5d66ed27001de7221b8bd1527dbef6c9
|
|
BLAKE2b-256 checksum How to use checksums |
11b857261a1af8d280d540946319513b3cf38d9f53a46f0c99f0e0cd2e5ea068
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | sentinel_lm-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
f284107b6dec49dd1db704c112d21bf2784e06cc6fdc21e58e97462fb6a2b415
|
|
BLAKE2b-256 checksum How to use checksums |
d500d9c837d3f776567fa47fc148799cf2a280e00cc788ac2172f3401e2ec905
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp310-cp310-win_amd64.whl
| Download URL | sentinel_lm-0.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
976bc41db7b38544219724f85cd290ef3589d7476b94b32a213570187548b859
|
|
BLAKE2b-256 checksum How to use checksums |
0a86c98c071d1fb1aa5e1cbf32ccb736613b252dbc3073e9cce64fe3de668a07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / sentinel_lm-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | sentinel_lm-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
b30a1fead6b793ff14f0cea854b30feae79eedc26f28480bc96c0147acc72dfa
|
|
BLAKE2b-256 checksum How to use checksums |
9a5f050bc9f00fa29db2a4c0c61c9becbe3e2a9e1a0628377265b4bb455c27bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency log