atomictrust-tpf

Free uncertainty quantification for diffusion language models

pip install atomictrust-tpf

The Discovery

TPF (Tokens-Per-Forward) reveals generation confidence in diffusion LLMs at zero cost.

7 × 8 = ?
13.58
High confidence — memorized
23 × 17 = ?
2.68
Low confidence — computed
r = -0.88
Correlation between TPF and entropy (p < 0.001) across 28 benchmarks

The Inverse Signal: Hallucination Detection

Low TPF + uncertain query Expected (honest uncertainty)
High TPF + uncertain query Potential fabrication

This bidirectional signal is structurally unavailable in autoregressive models.

Quick Start

from atomictrust_tpf import TPFRLMHybrid

router = TPFRLMHybrid()
result = router.generate("What is 23 × 17?")

print(f"Answer: {result.text}")
print(f"TPF: {result.tpf_metrics.tpf:.2f}")
print(f"Route: {result.route.name}")

FlashAPCE: Attention Verification

Verification inside FlashAttention's tiled computation — without materializing the O(n²) matrix.

Velado's Contradiction Theorem
D(ε) × I(ε) ≥ κ
Attacks cannot simultaneously achieve high impact AND low detectability.
This is a mathematical bound, not a heuristic.
from atomictrust_tpf import FlashAPCEAttention, VerificationMode

attn = FlashAPCEAttention(mode=VerificationMode.BALANCED)
output, signals = attn.forward(q, k, v)

result = attn.verify(signals)
print(f"Valid: {result.is_valid}")
print(f"D × I = {result.di_product:.3f}")

Patents

Open source under Apache 2.0 for research and evaluation. Commercial licensing available.

US 63/951,960
TPF-Based Confidence Routing
Filed December 31, 2025
US 63/948,782
FlashAPCE Attention Verification
Filed December 26, 2025

Citation

@article{velado2025tpf,
    title   = {Parallel Decoding as Intrinsic Uncertainty:
               Tokens-Per-Forward Reveals Generation Confidence
               in Diffusion Language Models},
    author  = {Velado, Rafael},
    year    = {2025},
    doi     = {10.5281/zenodo.18111467}
}

@article{velado2025contradiction,
    title   = {Velado's Contradiction Theorem: Mathematical
               Guarantees for Attention Verification},
    author  = {Velado, Rafael},
    year    = {2025},
    doi     = {10.5281/zenodo.18079657}
}