Files
OBLITERATUS/docs/activation-observation.md

2.9 KiB

Activation observation

Pipeline subclasses can override _read_activation_hidden(layer, output) to select a model-specific readout. The collector retains its tokenization, batching, pooling, and hook cleanup. Readouts must preserve layer outputs and weights.

observe_activations records detached CPU activations without replacing decoder outputs. Supply the current call's binary token mask and a semantic phase label. The default token is the last unmasked position in each row. A decode step needs its own scope and a mask excluding cached history.

from obliteratus.analysis import (
    deepseek_v41_post_block_readout,
    inspect_deepseek_v41_engram,
    observe_activations,
)

# A loaded native DeepseekV41ForCausalLM; paths are relative to its text backbone.
layout = inspect_deepseek_v41_engram(model.model)
layers = {str(i): layer for i, layer in enumerate(model.model.layers)}
with observe_activations(
    layers,
    attention_mask=inputs["attention_mask"],
    phase="prompt.thinking_off",
    readout=deepseek_v41_post_block_readout,
    readout_name="deepseek_v41.post_block.v1",
) as observations:
    output = model(**inputs, use_cache=False)

Phase labels are caller-supplied. The observer does not parse chat templates, detect thinking boundaries, gate interventions, or modify weights. Each selected layer must execute exactly once; failures discard partial observations and remove hooks. Custom readouts must preserve their inputs.

V4.1 returns (hidden_streams[B,S,hc,H], pre_mix[B,S,hc]). Its readout uses the layer's native weighted collapse. It is not an average across streams or an inverse mapping for edits. Generic steering hooks reject unsupported tensor ranks.

Engram tables reside at engram_tables.<layer>, separately from injections at layers.<layer>.engram. The inspector validates configuration order, keys, shapes, and injection locations. It inventories tables, optional scales, gate/fusion parameters, and shared hash buffers, including nonpersistent tokenizer-derived state. It neither moves tables nor hashes their contents.

The released V4.1 configuration injects at zero-based layers 1 and 14, before attention. Outputs of layers 0 and 13 therefore precede those injections; they must not be labeled as the next layer's post-Engram input. Positions are derived from the loaded configuration rather than fixed to this release.

Inventory devices describe loaded tensors, including meta. Logical byte counts do not estimate resident allocations, local tensor-parallel shards, offload buffers, or peak memory. Two BF16 tables of shapes (384006168, 256) and (384016682, 256) require 393,227,699,200 logical bytes, excluding scales.

This API does not enable V4.1 weight editing or certify an artifact's integrity. Native semantics were reviewed against Transformers revision 62d7ebd7de4938e072b7aaeb881593b79dc56835; the locked dependency does not yet provide those model classes. No dependency version is changed by this API.