Your First Trace

Getting Started

A trace is a full record of a single forward pass — every operation in every layer, in order. TokenPrint records traces in real time as the model runs and replays them as 3D animations.


What a trace contains

Each trace frame records:

  • The current operation name (e.g., attn.q_proj)
  • The layer index (0–23 for the reference model)
  • The KV cache phase (prefill or decode)
  • Timing metadata (host-side, not GPU-synchronized)
  • A reference to the tensor being produced

The op catalog for the reference model contains 243 operations in a single forward pass.


Reading the animation

In Generation mode, the 3D model animates as the trace plays. The component currently executing is highlighted. The right panel shows the operation name, layer, input/output shapes, and parameter count.

The operation order within each layer follows the actual computation graph:

  1. Input RMSNorm (input_layernorm)
  2. Q projection (attn.q_proj)
  3. K projection (attn.k_proj)
  4. V projection (attn.v_proj)
  5. Attention (attention)
  6. Output projection (attn.o_proj)
  7. Post-attention RMSNorm (post_attention_layernorm)
  8. MLP gate projection (mlp.gate_proj)
  9. MLP up projection (mlp.up_proj)
  10. MLP down projection (mlp.down_proj)
Note

This order is not configurable — it reflects the actual PyTorch execution order captured by register_forward_hook on each module.


KV cache phases

The trace distinguishes two phases, shown as a badge in the transport bar:

PhaseWhat happensPositions computed
prefillThe full prompt is processed in one pass. The KV cache is built.All prompt tokens (e.g., 39 for a 39-token prompt)
decodeOne new token is generated per step. Only the new token position is computed; all prior KV pairs are read from cache.1 (the new token)

Replay and branching

Completed traces are saved and can be replayed from the Debugger mode. The trace branching panel lets you re-run a trace with a different prompt or model configuration and compare the two side by side.