Skip to main content

Oglodon

Build. Train. Understand. Verify.

Python PyTorch License Tests PyPI

Oglodon is a small PyTorch library for building, training and checking decoder-only Transformers (GPT-style, with RoPE, RMSNorm, SwiGLU, grouped-query attention and a KV cache).

Its most useful part is oglodon verify: it tests any causal language model (Hugging Face, your own PyTorch module, or Oglodon) for bugs that still train but quietly make the model worse, such as a token seeing the future, padding changing the answer, or a KV cache that disagrees with a full forward pass.

Status: alpha, for learning and research at small scale. Not production-ready and not a replacement for large-scale frameworks. See what has and has not been tested.

Install

pip install oglodon-transformer

Needs Python 3.11+ and PyTorch. Optional extras: [hf] Hugging Face import, export and verification, [viz] plots, [yaml] YAML configs, [dev] tests and linters. Working from a clone: pip install -e ".[dev]".

Try it in two minutes

Put a few .txt or .md files in a folder, then:

oglodon train my_texts/ --out run1 --steps 500
oglodon generate run1 --prompt "Once upon a time" --seed 1
oglodon eval run1 --text my_texts/some_file.txt

train builds a tokenizer, trains a small model and saves a checkpoint; eval prints perplexity next to the score of a model that guesses at random, so you can see whether it learned anything. A model trained for minutes learns your text's vocabulary and local patterns, not fluent language. No Python code is needed.

How it fits together

 text files ──► BPE tokenizer ──► token file ──► train ──► CHECKPOINT
                                                              │
        ┌─────────────┬──────────────┬──────────────┬─────────┴────────┐
        ▼             ▼              ▼              ▼                  ▼
    generate         eval          verify        quantize         export to
  (stream text)  (perplexity)   (behaviour)    (int8 copy)      Hugging Face
                                     ▲
 any Hugging Face / PyTorch model ───┘     verify accepts any causal LM

Inside the model:

tokens ─► Embedding ─► [ Norm ─► Attention (RoPE, KV cache) ─► + ─► Norm ─► FFN ─► + ] × N ─► Norm ─► LM head ─► logits
                                MHA / GQA / MQA                          SwiGLU / GELU

What you can do

Command What it does
oglodon train Text files to tokenizer, trained model and report. Exact --resume, data-parallel under torchrun
oglodon generate Streams text: temperature, top-k, top-p, min-p, repetition penalty, stop strings, KV cache
oglodon eval Perplexity, multiple-choice accuracy, generation sanity checks, saved as JSON
oglodon verify Behaviour checks on any causal LM; --cross-check compares against a Hugging Face model
oglodon validate Compares an Oglodon model with an independent float64 reference implementation
oglodon compare Trains variants on identical data and seeds and writes reproducible comparison reports
oglodon quantize Int8 weight-only copy of a checkpoint with a measured accuracy drift
oglodon info Versions and whether CUDA is available

Architecture options: MHA, GQA or MQA attention, RoPE, learned or ALiBi positions, RMSNorm or LayerNorm, SwiGLU, GeGLU, GELU or ReLU² feed-forward, sliding window, qkv bias. Export to Llama, Mistral or Qwen2 format for Hugging Face with export_hf(model, "hf_dir").

Verify any model

oglodon verify --checkpoint run1                      # an Oglodon checkpoint
oglodon verify --hf HuggingFaceTB/SmolLM2-135M --cross-check --dtype float32
Check What it catches
Causality A token's prediction changes when later tokens change
Padding and batching Padded or batched inputs giving different answers than single ones
KV cache Cached decoding disagreeing with a full forward pass
Numerics float32 vs float64 drift, non-finite values
Gradients Autograd disagreeing with finite differences, dead parameters
Cross-check An Oglodon model and its Hugging Face twin producing different logits

Skipped or unsupported checks are reported as such and are never counted as passed.

What has been tested

Verified Not yet
Test suite on CPU: Python 3.11, 3.12 and 3.13 (Linux) and the suite on Windows macOS
Test suite, validate, verify, bf16 and fp16 steps on one Tesla T4 (Colab) Multi-GPU, FlashAttention kernels, other GPUs
verify --cross-check on SmolLM2-135M in float32: logits agree to about 1e-4, greedy output identical Other pretrained models
Int8 drift measured on a small trained model (perplexity change about 0.001%) Int8 on large models or on a GPU
Hugging Face export matches logits to about 1e-6 Gemma, Phi, Mixtral converters, FSDP, 4-bit quantization

Details and exact numbers: Limitations and Performance and scaling.

Documentation

Contributing and licence

Contributions are welcome; see docs/contributing.md. Released under the MIT licence.

Oglodon is an independent project. It is not affiliated with, endorsed by or derived from NVIDIA or any hardware vendor.

Metadata

Release files for oglodon-transformer 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oglodon-transformer 0.4.0
File Size Uploaded Provenance Actions
oglodon_transformer-0.4.0.tar.gz 184.6 kB With provenance Details for oglodon_transformer-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oglodon-transformer 0.4.0
File Interpreter ABI Platform Actions
oglodon_transformer-0.4.0-py3-none-any.whl Python 3 none any Details for oglodon_transformer-0.4.0-py3-none-any.whl

Total release size: 316.1 kB

Release files / oglodon_transformer-0.4.0.tar.gz

Download URL oglodon_transformer-0.4.0.tar.gz
Size 184.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e11800afe51cb029d3b7482383f6d83bfac4730ce858e7b3afdd272c48592fa8
BLAKE2b-256 checksum
How to use checksums
b03fb87167d169294689a63fe76b165d3cb11cc47bc2433bfb9a8566be3504b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Release files / oglodon_transformer-0.4.0-py3-none-any.whl

Download URL oglodon_transformer-0.4.0-py3-none-any.whl
Size 131.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
666db9e510003aa80abe892c5d2213d407097df0238ddfef6d7c03483bb26a38
BLAKE2b-256 checksum
How to use checksums
8d33587f79ead4a5b9013fddaa5cf984727c24829d578a35bf84c4888b2d5ec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Security for oglodon-transformer 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for oglodon_transformer-0.4.0.tar.gz

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 Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page