Trace Schema

Reference

TokenPrint traces record complete forward-pass execution state, including layer activations, head-level attention matrices, KV cache shapes, and logit lens projections.


Trace structure

Traces are serialized as versioned JSON objects (.json or .tokenprint.json). All tensor shapes are explicit and all numeric values match exact backend floating-point outputs.

json
{
  "version": "1.0.0",
  "metadata": {
    "model_id": "Qwen/Qwen2.5-0.5B-Instruct",
    "prompt": "The cat sat on the mat.",
    "seq_len": 7,
    "timestamp": "2026-09-13T12:00:00Z"
  },
  "tensors": {
    "embed_tokens": { "shape": [7, 896], "dtype": "float32" },
    "layers.0.attn.q": { "shape": [7, 14, 64], "dtype": "float32" },
    "layers.0.attn.k": { "shape": [7, 2, 64], "dtype": "float32" },
    "layers.0.attn.v": { "shape": [7, 2, 64], "dtype": "float32" },
    "layers.0.attn.weights": { "shape": [14, 7, 7], "dtype": "float32" },
    "lm_head.logits": { "shape": [7, 151936], "dtype": "float32" }
  }
}

Field definitions

FieldTypeDescription
versionstringSchema specification version (currently 1.0.0).
metadata.model_idstringHuggingFace or local GGUF model identifier.
metadata.seq_lenintegerTotal sequence length of analyzed input.
tensorsobjectDictionary of recorded activation tensors by standard PyTorch key.