Extend observation from prompt readouts to token-time-layer traces (F09), with matched-prefix comparison kept separate from free-running generation. - Each forward call is recorded with its phase (full, prefill, decode), new positions, cache history and a prefix digest as decode-step identity; every position is observed exactly once, and masks select calls, prompt/continuation segments or caller labels. - Teacher-forced replay of fixed tokens and free-running greedy decoding are distinct modes; comparing them is refused. Matched-prefix comparison reports per-layer and per-position differences; free running reports the divergence point. - Cached execution is supported on dense CPU Transformers with past_key_values and refused (never silently recomputed) when the model, cache type or cache length doesn't fit. Qualification checks cached against uncached traces within tolerance. - Caller labels such as "thinking" are stored as unverified metadata only. Traces are stored as chunked safetensors bound to the capture identity; hooks are removed on errors and cancellation. - `obliteratus experiments trace` with --mode, --cache and --qualify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.6 KiB
Temporal traces
A temporal trace records one detached CPU activation per token position and selected decoder layer of a single unpadded sequence, across the prompt, prefill and decode calls that produced it. Observation hooks are read-only and are removed when a trace finishes, fails or is cancelled.
obliteratus experiments trace --model <id> --layer 4 --layer 8 \
--prompt "Question" --continuation " answer" --cache cached --out ./trace
obliteratus experiments trace --model <id> --layer 4 --prompt "Question" \
--mode free-running --max-new-tokens 16
obliteratus experiments trace --model <id> --layer 4 --prompt-ids 1,2,3 \
--continuation-ids 4,5 --qualify --atol 1e-5
from obliteratus.analysis.temporal_trace import trace_free_running, trace_teacher_forced
from obliteratus.analysis.trace_compare import compare_traces, qualify_cached_execution
from obliteratus.analysis.trace_store import load_trace, trace_identity, write_trace
base = trace_teacher_forced(model, layers, token_ids, prompt_tokens, condition="base")
edited = trace_teacher_forced(other, layers2, token_ids, prompt_tokens, condition="edited")
compare_traces(base, edited) # mode "matched-prefix"
qualify_cached_execution(model, layers, token_ids, prompt_tokens, atol=1e-5)
Modes
teacher-forcedreplays a fixed token sequence. Two teacher-forced traces of the same tokens and prompt boundary compare asmatched-prefix: every position is aligned and differences are reported per layer and per position. Different tokens or prompt boundaries are refused.free-runningappends the model's greedy choice after each call and stops aftermax_new_tokensor the first end-of-sequence token. A final call observes the last generated token; its prediction is unused. Free-running traces compare asfree-running: the first divergent position is reported and activations are compared only over the shared prefix.
Comparing a teacher-forced with a free-running trace is refused. Sampling, beam search and padded batches are not traced.
Calls, phases and token masks
Each call records its phase, cache condition, the positions it newly observed
(start, end), the tokens it read from the cache (cache_history), the
tokens it recomputed without a cache (recomputed_history), its decode step and
prefix_sha256, the digest of the token ids up to end. Equal prefixes have
equal step identities across traces.
| Phase | Cache condition | Observed positions |
|---|---|---|
full |
uncached | the prompt (teacher-forced: the whole sequence) |
prefill |
cached | the prompt; the returned cache must hold exactly those tokens |
decode |
either | one new token |
call_index[position] names the call that observed each position, so
trace.call_mask(i) is that call's token mask and trace.segment_mask("prompt")
or ("continuation") splits the sequence at the prompt boundary. Every position
is observed exactly once. Cached or recomputed history is never recorded as a
new token.
Cache qualification
One backend is qualified: dense CPU Transformers decoder models with
past_key_values (transformers-cpu-past_key_values). --qualify traces the
same sequence uncached and cached and passes when they agree within --atol
and each position was observed once; a failure exits with status 1.
Cached execution is refused, never replaced by recomputation, when the model
has no past_key_values/use_cache arguments, returns no cache, returns a
cache whose length differs from the tokens fed so far, uses an unrecognised
cache type, or a layer returns more tokens than were fed. Encoder-decoder,
quantized, offloaded and non-CPU models are refused.
Labels
labels={"thinking": [(start, end)]} or --label thinking:START:END stores
caller-provided spans with "source": "caller", "verified": false. Labels never
change phases, masks or values, and no reasoning state is detected.
Storage
write_trace writes manifest.json (schema obliteratus.temporal-trace/1)
and chunks/NNNNN.safetensors, each holding a contiguous range of positions
with per-layer values, token ids, positions and call indices. The manifest binds
the trace to the activation capture identity, including the input token digest,
sites, readout and weight fingerprint, and records the mode, cache condition,
calls, labels and each chunk's SHA-256. It is complete only after every chunk
is written. load_trace verifies the schema, state, identity digest, chunk
digests and contiguity; with an expected identity it refuses traces from other
weights, tokenizers, inputs or sites. Logits are not stored.