Files
OBLITERATUS/docs/OBSERVATION_RUNS.md
Joseph MaglyandClaude Opus 5.5 477eb753c8 feat(analysis): dataset-level candidate discovery with confound and null baselines
Extend candidate scanning from two prompts to distributions over a
labeled activation set (F07).

- Candidates with explicit coordinate identities: individual channels
  at a site and residual directions (a difference-of-means refit and
  the pack's stored basis rows). Binary (positive vs controls) or
  per-set contrasts.
- Measures reported separately, never combined: held-out AUC and
  balanced accuracy over group-disjoint folds, standardized mean
  difference, group-bootstrap intervals and fold stability. Everything
  fitted is refitted per training fold; recipe_top1 reports the honest
  held-out score of each fold's own top channel. Independent validation
  uses select rows; in-sample and basis-overlap scores are labelled.
- Nulls: a group-level shuffled-label null rerunning the full recipe
  (max over channels for channels) and random-direction/channel nulls,
  each with the observed quantile.
- Confounds: token-count and hashed-token lexical baselines plus length
  correlation, flagged beside each candidate; features are built in
  memory and no text is stored.
- Locked test is refused for discovery and excluded from acknowledged
  sets. Caps bound channels, bootstraps and permutations.
- `obliteratus experiments discover` and a Python API write versioned
  candidate tables; the Explorer lists them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:05:30 -05:00

16 KiB

Baseline observation runs

An observation run generates completions from an unmodified model, scores them with registered task scorers, optionally captures activations and optionally records local cost counters. The CLI and the Python API call the same function, obliteratus.experiments.run_observation, so a UI can call it too.

obliteratus experiments run spec.json --store ./observations
obliteratus experiments history spec.json --store ./observations
obliteratus experiments prune spec.json --store ./observations --keep 2 [--apply]
obliteratus experiments compare ./observations/<digest> ./other-store/<digest>

obliteratus experiments subspace --run <run dir> ... writes a model-level subspace report next to a run; see LABELED_SUBSPACE.md. obliteratus experiments discover --run <run dir> --layer <n> writes candidate tables next to a run; see CANDIDATE_DISCOVERY.md.

from obliteratus.experiments import compare_results, run_observation

result = run_observation("spec.json", "./observations")
report = compare_results(result, "./other-store/<digest>")

Specification

The spec is JSON validated against the shipped obliteratus/concepts/schema/observation-spec.v1.schema.json, which is the only schema authority (maintained by the experiment platform maintainers). It references inputs; it never copies their contents.

{
  "schema_version": "1",
  "kind": "baseline_observation",
  "dataset": {"pack": "./my-pack", "revision": "sha256:...", "role": "select"},
  "model": {"id": "org/model", "dtype": "float32"},
  "decoding": {"max_new_tokens": 32},
  "tasks": [{"name": "answers", "scorer": {"id": "exact_answer", "version": 1},
             "target_field": "answer"}],
  "capture": {"sites": [0, 4, 8], "budget_bytes": 50000000},
  "profile": true,
  "seed": 0
}
  • dataset.pack is a concept id or pack path and dataset.revision is the dataset revision shown by obliteratus concepts dataset-preview. The run is refused if the resolved revision differs. pack_sha256 optionally pins the pack archive hash as well.
  • role is select or calibrate. The locked test role requires "allow_locked_test": true; without it the spec is refused before a store directory is created.
  • model gives an id, optional revision (verified against the loaded checkpoint when set), dtype, and device: cpu (default), cuda or cuda:N. See Devices below.
  • decoding sets max_new_tokens, the strategy (greedy, the default, or sample) and an optional batch_size (default 1). See Decoding and batching below.
  • prompt is optional. Without it, or with "chat_template": false, the prompt text is used as supplied. See Chat templates below.
  • Each task names a registered scorer and version, the row annotation holding its target, and the dataset file (positive.jsonl by default).
  • capture selects decoder layer indices, the decoder_output readout of the prompt forward pass, and a byte budget that is checked before capture.

Omitted optional fields are filled with their defaults before hashing. The sha256: digest of the canonical JSON of the filled spec is the run identity: an explicit default hashes like an omitted one, and any changed value gives a new identity. Options added after the first release (decoding.batch_size, the sampling settings and prompt) are left out of the filled spec while they hold their defaults, so specs written before them keep their run identities.

Chat templates

"prompt": {"chat_template": true, "system": "Answer in one word."}

With chat_template: true each prompt is rendered with the tokenizer's apply_chat_template as a single user message (preceded by the optional system message) with add_generation_prompt=True, and the rendered text is tokenized without adding special tokens again, because the template already renders them. system is only accepted together with chat_template: true. A tokenizer without a chat template is refused. The template text is part of the tokenizer identity, and each generation step identity also binds the digest of the rendered prompts; each generated row records rendered_prompt_sha256. Capture uses the same rendered prompts.

Decoding and batching

"decoding": {"strategy": "sample", "max_new_tokens": 32,
             "temperature": 0.7, "top_p": 0.9, "top_k": 50}

Greedy decoding is the default. strategy: "sample" samples with temperature (default 1.0), top_p (default 1.0) and top_k (default 0, meaning no top-k filter); the defaults are written into the filled spec, so they are part of the run identity. These settings are refused with greedy decoding. Before each example is sampled the generator is seeded with that example's seed: the first 8 bytes, read as a big-endian unsigned integer, of SHA-256 over the UTF-8 text "<seed>:<example id>", where <seed> is the spec seed. An example therefore samples the same way regardless of its position or task. Sampling requires batch_size 1, since a batch shares one random stream.

batch_size greater than 1 generates greedy batches of consecutive examples. Prompts are left-padded and padding is masked out of attention. The pad token is the tokenizer's pad token or, when it has none, its eos token; the choice (pad_token_id and source) is recorded in the generation step identity and artifact. A tokenizer with neither is refused. Each row is cut after its first eos token, as unbatched generation stops there, so per-example outcomes are directly comparable with unbatched runs. Capture still runs one unpadded prompt per shard.

Devices

device: "cuda" or "cuda:N" runs generation and capture on one CUDA device. The default loader loads the model densely on the CPU and then moves it to that device. The realized device (for example cuda:0) is recorded in the model identity and the result's execution block; capture shards are always written from CPU copies, the capture manifest records execution.device and execution.dtype, and the capture identity records device for non-CPU captures, so a CUDA capture never matches a CPU identity. Refused before anything is generated, each with its reason:

  • quantized models (4-bit, 8-bit or a quantization config);
  • offloaded or dispatched models (accelerate hooks or a device map);
  • meta tensors (weights not materialized);
  • tensors on more than one device, or on another device than requested;
  • mps, which is not qualified, whether named in the spec or found on the model's tensors.

The unmodified-model checks run before the device check on every device.

Unmodified model requirement

Before anything is generated, the runner refuses a model that has a registered forward, pre-forward or backward hook on any submodule, a global module hook, an interrupted surgery marker, or adapter state other than none. A recognised PEFT configuration is accepted only when every adapter is disabled or inactive. The model must be in eval mode, have the declared dtype and live on the declared device. Weights edited in place without a marker are not refused, but the observed model identity includes a weight fingerprint (see below), so such a model records a different identity and never reuses steps of the original weights.

Weight fingerprint

The model identity (and the activation capture identity) contains weights, a fingerprint of every parameter and buffer: the sorted names (tied parameters once), shapes and dtypes, plus a SHA-256 over the bytes of a fixed, evenly strided sample of 256 elements of each tensor, always including its first and last element (all elements of smaller tensors). Only the sampled elements are copied to the CPU, so the cost is bounded by the number of tensors, not the model size (a non-contiguous tensor is first flattened into a temporary copy on its own device), and the result is identical across reloads of the same weights.

Sampled mode can miss an edit that changes no sampled element, for example a single changed value in the middle of a large matrix. mode="full" (in obliteratus.analysis.capture_identity.weight_fingerprint, inputs.model_identity and capture_identity) hashes every element in bounded chunks and detects any byte change, at the cost of reading all weights. Runs use sampled mode unless the spec sets "model": {"fingerprint": "full"}, which applies to the run's model identity and therefore to every step's reuse check; the activation capture manifest always records a sampled fingerprint. On a 5.2M-parameter float32 test model one measurement took about 1 ms sampled and 11 ms full on CPU; full mode grows linearly with model size. A fingerprint is not an integrity certificate: it says the observed bytes match, not where they came from.

Store layout and states

<store>/<digest>/spec.json          canonical spec, written once
<store>/<digest>/attempts.jsonl     append-only state events
<store>/<digest>/attempts/0001/     attempt.json, steps/, result.json, profile.json
<store>/<digest>/.lock              held while an attempt runs or a prune plans or applies

Each attempt moves pending -> running -> complete | failed | cancelled. Refusals of inputs or models end a pending attempt as failed. Exceptions raised by the check_cancelled callback (or a keyboard interrupt) end it as cancelled. Terminal attempts are never rewritten, and failed or cancelled attempts stay in history. One attempt per spec runs at a time; if a process dies while holding the lock, the next attempt records the stale one as failed with error_type: "Abandoned". Running a spec that already has a complete attempt returns that result unless --rerun is given.

Steps and resume

An attempt has one generation step per task and an optional capture step. Each step identity binds the spec digest, dataset revision and role, the observed checkpoint, tokenizer, adapter and weight fingerprint identity, and the step parameters (examples, decoding and seed, plus the rendered prompt digest and padding when those options are used, or the activation capture identity and budget). A new attempt reuses an earlier step only when that step is complete, has exactly the same identity, and its artifact digests still verify. Reused steps record the attempt they came from. A recomputed step records in reuse_refused the newest earlier complete step of the same name and why it was not reused, for example identity differs at model.weights.sha256. Steps recorded before the weight fingerprint existed are never reused; their reason is step predates weight fingerprint; recomputed. Interrupted steps are marked incomplete and never reused, and runs of different specs live in different directories.

Pruning

obliteratus experiments prune (and obliteratus.experiments.prune.prune_attempts, which the CLI calls) lists attempts that can be removed and removes them only with --apply (apply=True). A dry run writes nothing. An attempt is kept when it is the latest complete attempt, is among the newest --keep attempts (default 1), is not terminal, or holds step artifacts that any kept attempt reuses, directly or through another kept attempt. The output lists every kept attempt with its reasons and every removable attempt with its file count and bytes.

Applying appends a pruned event to attempts.jsonl for each removed attempt, recording its previous state, path, files and bytes, and then deletes its directory. Earlier events stay in history, attempt numbers are never reused, and a removal interrupted after its event is finished by the next applied prune. Pruning holds the run lock, so it fails while an attempt is running. A later run --rerun still reuses steps from the attempts that remain.

Results

result.json records input identities, step identities and provenance, and a single-arm baseline scorecard. Each task reports per-example records (including completion digests), excluded examples with reasons, and rates with Wilson 95% intervals for task success and abstention (scorable examples) and invalid output (all examples). There is no PASS or FAIL: a verdict needs a paired intervened arm. Completions are stored in the generation step and activation shards in the capture step. With profile enabled, local cost counters are included and the full profile is written next to the result.

Comparison

compare_results (and experiments compare, which exits 1 on any difference) compares identities, the execution block (device, dtype, strategy, seed, batch size, chat template), counts, denominators, per-example outcomes and completion digests exactly. What "exact" means depends on execution:

  • Greedy outcomes are compared exactly across batch sizes, devices and dtypes. On the CPU, batched and unbatched greedy runs of the tiny test model agree per example; elsewhere numerical differences can change a token, and the report then lists the differing outcomes instead of hiding them.
  • Sampled outcomes are compared exactly only when both runs sampled on the same device, dtype and seed. Otherwise the report sets outcomes.compared_exactly to false, gives the reason (which of strategy, device, dtype or seed differs) and lists per-example outcomes, outcome counts and rates as not compared; only the spec-fixed task fields are compared.
  • Runs on different devices or batch sizes always differ in run and step identity, so they never compare equal; read the per-example fields of the report to see whether the outcomes agree.

Rates and Wilson bounds are compared with atol=1e-9, and activation values per site with atol=1e-5, rtol=1e-4; callers may override either tolerance. Attempt numbers, timestamps, reuse provenance, tool provenance, measured capture cost and profiles are listed as not compared. The report lists every field compared exactly, every field compared within tolerance with its largest difference, and the fields that differed.

Limits

Observation runs observe baselines only: no interventions. Quantized, offloaded and MPS execution are refused, sampling cannot be batched, and capture is not batched. Offline tests use a tiny randomly initialised model to check software contracts; they say nothing about pretrained-model behaviour. CUDA agreement with the CPU is checked by a conditional GPU test, not by the default CPU suite.

Observation Runs tab

The web UI has an Observations tab under Concept Lab. It calls the same functions as obliteratus experiments run|history|compare; it adds no validation, scoring or comparison of its own.

  • The spec JSON is what runs. The form (pack, revision, role, model id, revision and dtype, tasks, capture sites and budget, profile, seed, plus the execution options: device, decoding strategy and sampling settings, batch size, chat template and system message, weight fingerprint mode) only overwrites its own fields, so other fields pass through unchanged and the shipped schema decides whether they are valid.
  • Validate reads the JSON exactly as the CLI reads a spec file and shows the errors or the run identity. Run validates again and never starts an invalid spec.
  • The locked test role is offered only after ticking the locked test data acknowledgement, which writes allow_locked_test: true into the spec.
  • Run shows the attempt state and recorded steps while it works. Cancel stops it at the next cancellation checkpoint and records a cancelled attempt; a later run resumes from the verified completed steps.
  • There is no capture byte preview before a run: the estimate needs the loaded model, so the runner computes it and refuses an over-budget capture. The estimate and measured bytes appear in the capture summary afterwards.
  • History lists every attempt, including failed and cancelled ones. Scorecard shows per-task rates with Wilson intervals, excluded examples and the capture summary. Compare takes two result, attempt or run paths and lists the fields compared exactly and within tolerance.
  • Views show identities, counts, rates and digests only; prompt and completion text stay in the run store. The tab loads without a model or network access.

The Explorer tab beside it inspects a completed run: scorecard drill-down, example records and stored activations, saved views and export to batch. See docs/EVIDENCE_EXPLORER.md.