Commit Graph
494 Commits
Author SHA1 Message Date
Joseph Magly 7228de99db fix(vocab-surgery): tie detection across head aliases and suffix forms; admit edit memory before reads
Muse review r1 for #623: the config tie check walks every path the head is
registered under (any owner config or its text config saying tied, or a
disagreement between paths, means tied); tie metadata is read as an
undirected link graph matched over every suffix form of every module path, so
cycles and suffix-form links are never read as untied; edit memory is
admitted from shape/dtype/placement before any offloaded value is read, then
again exactly before any edit allocation. The NaN-aware bounded comparison
moves to offload_surgery and is reused by adopt_tied_alias.
2026-11-24 22:43:54 -05:00
Joseph Magly b97ef38efc Merge main d737569 into fix/599-601-vocab-surgery-tie-budget
# Conflicts:
#	tests/test_vocab_surgery.py
2026-11-24 22:01:39 -05:00
Joseph Magly 5fe49fdadc Merge pull request #618 from elder-plinius/fix/606-607-604-report-metrics
Preserve the study impact metric in reports and list only plots written
2026-11-24 21:11:56 -05:00
Joseph Magly ddc4762604 fix(viewer,report): name-sorted fallback metric, latest-load-wins reads, report-matching percent change
Codex review r4 for #618: when the study metric has no measured change, the
fallback is the first measured metric in name order (the order save_json
writes), so a live run, replay and the viewer agree; the order-preserving
reader is no longer needed and is removed. Every upload, drop or demo load
starts a new generation and stale reads are ignored. Viewer percentages use
the absolute baseline and show unavailable for a zero baseline, as the
report does.
2026-11-24 20:22:21 -05:00
Joseph Magly dc1f92747a Merge main 20a09c6 into fix/600-602-vocab-discovery-roundtrip-concurrency 2026-11-24 20:04:34 -05:00
Joseph Magly 82eeeaceb2 fix(persistence): never roll back or delete published no-replace outputs; keep default checkpoint semantics
Codex review r3 for #621: once the opt-in no-replace checkpoint commit has
published, it is never rolled back (a later sync failure is reported and the
complete checkpoint left in place), and discovery never moves or deletes a
published file (a later failure names what was published); only private temp
files are removed. The staging path is never cleaned after a no-replace
publish. The default replace_existing=True path keeps main's semantics
unchanged (its rollback race is tracked in #645).
2026-11-24 20:04:32 -05:00
Joseph Magly a4af133c90 fix(viewer,report): linear-time trim, real-pair deltas, and an error state for failed loads
Codex review r3 for #618: the viewer trims ASCII whitespace by scanning
instead of a backtracking regex; report availability, plotted deltas, the
heatmap and the summary compute changes from each metric's own value and
baseline so generated column names cannot collide with raw metric names;
failed uploads clear the results and show an error; strict JSON (no NaN or
Infinity tokens) is documented as the shared input contract.
2026-11-24 19:48:43 -05:00
Joseph Magly f2abf5557a fix(viewer,report): share one numeric-string grammar and read metrics in file order
Codex review r2 for #618: the results viewer reads uploaded files with an
order-preserving JSON reader so metric selection walks baseline keys in file
order like Python (integer-like keys included), and the viewer and
report._metric_value share one strict numeric-string grammar (ASCII digits,
sign, decimal point, exponent; ASCII whitespace only; finite).
2026-11-24 19:13:22 -05:00
Joseph Magly 4b0113c00a Merge main 6a2b84d into fix/600-602-vocab-discovery-roundtrip-concurrency
# Conflicts:
#	CHANGELOG.md
2026-11-24 18:46:57 -05:00
Joseph Magly bf36682ad8 fix(persistence): never roll back a checkpoint destination another writer replaced
Codex review r2 for #621: the promoted directory's identity is recorded at
promotion and rollback leaves a destination whose identity changed untouched
(keeping any backup); no-replace rename tests run portably on hosts without
the primitive; ENOTEMPTY maps to FileExistsError and the unsupported-rename
message names a remedy.
2026-11-24 18:45:59 -05:00
Joseph Magly 675e5683d8 fix(snapshot): admit exact overlap-check scratch within staging and pin it to CPU
Codex review r2 for #616: the exact overlap check's host scratch (a
conservative 48 bytes per checked element) is counted in snapshot admission
and restore validation, so staging_bytes stays a hard cap and an unadmitted
check fails closed; the offset tensors are created on the CPU explicitly.
2026-11-24 18:45:54 -05:00
Joseph Magly 50133eb272 Merge main 11c7137 into fix/606-607-604-report-metrics
# Conflicts:
#	tests/test_cli.py
2026-11-24 18:32:15 -05:00
Joseph Magly 86407c7760 fix(viewer,report): render results as text, mirror plot metric selection, write plots atomically
Codex review r1 for #618: the results viewer builds its stats, chart and
table with DOM nodes and text only (no innerHTML), so a crafted results.json
cannot inject markup; its impact-metric selection mirrors save_plots exactly
(string primary only, measured baseline plus at least one measured ablation);
every render clears all result regions. Plots are written to a temp file and
moved into place only on success, figures are always closed, and a fallback
metric is labelled on the chart. A node-based test exercises the viewer.
2026-11-24 18:31:18 -05:00
Joseph Magly f8de9e3888 Merge main 11c7137 into fix/612-613-checkpoint-snapshot 2026-11-24 18:04:11 -05:00
Joseph Magly 56b658558b fix(snapshot): admit provably non-overlapping strided layouts via an exact offset check
Codex review r1 for #616: the sorted-stride overlap test is sufficient but
not necessary, so valid interleaved layouts (e.g. as_strided (3,2)/(2,3)) and
some empty tensors were refused. Empty tensors are admitted; when the fast
test fails, an exact uniqueness check over the narrowed view's storage
offsets runs up to 4,194,304 elements, and layouts above that cap are refused
as "could not be proven non-overlapping". Docs distinguish the two refusals.
The detector guard test also pins duplicate config.json as fail-closed.
2026-11-24 18:04:09 -05:00
Joseph Magly 343f68dafa Merge main a837fec into fix/600-602-vocab-discovery-roundtrip-concurrency
# Conflicts:
#	CHANGELOG.md
2026-11-24 17:54:54 -05:00
Joseph Magly 5f50feaeb5 fix(vocab-surgery): verify residual pins and publish outputs with atomic no-replace renames
Codex review r1 for #621: discovery refuses to stamp a pin onto inherited
ID-only operations it cannot verify (unpinned base, or an unfingerprintable
loaded tokenizer). The opt-in no-clobber checkpoint commit and the discovery
publisher use an atomic no-replace rename (renameat2 RENAME_NOREPLACE on
Linux, renamex_np RENAME_EXCL on macOS) and fail closed where none exists;
rollback deletes only files whose identity still matches what was published.
The recipe-digest compatibility test now uses a preserved pre-change
normalizer and a frozen recipe fixture, so normalization drift is caught.
2026-11-24 17:54:25 -05:00
Joseph Magly 638a728531 Merge main 08997c2 into fix/611-603-cli-json-mcp-hint
# Conflicts:
#	CHANGELOG.md
2026-11-24 17:13:27 -05:00
Joseph Magly b6ac2aeffc fix(cli): keep runs stdout empty on errors; send guard diagnostics to stderr
Codex review r1 for #617: the pre-parse secret-token and
distributed+preflight guards now print to stderr, and `runs` catches archive
errors (unknown or malformed run id, unfinished run) with a one-line stderr
diagnostic, exit 1 and empty stdout. Docs and changelog state the success
and error output contract; MCP_LOCAL_SETUP.md notes that policy validation
runs before the missing-extra check.
2026-11-24 17:12:24 -05:00
Joseph Magly 222c33ab3c fix(vocab-surgery): guard study-runner ID-only edits; derive recipe digest baselines
From the BT6 re-audit: the legacy `obliteratus run` study path (enumerate →
apply_batch) now runs the shared ID-only guard and fails closed with no
opt-out. The bundled-recipe compatibility test derives its baseline from a
pre-pin technique registry instead of hard-coded digests, so legitimate recipe
changes on main don't break it. A pin that cannot be verified (tokenizer
without get_vocab) is recorded as pin_unverifiable.
2026-11-24 16:10:20 -05:00
Joseph Magly 4fd3a33b11 fix(vocab-surgery): match tie metadata across module aliases; compare NaN rows as equal
From the round-3 BT6 audit: tie-map matching now considers every module path
(alias) of the embedding and head, plus prefix-normalized forms, and a map
naming only one side of the pair is undetermined rather than untied. The
last-resort value comparison treats matching NaN positions as equal, so a
tied model with NaN rows is no longer read as untied.
2026-11-24 16:09:44 -05:00
Joseph Magly 3fb1e26e3b fix(vocab-surgery): resolve ambiguous offloaded ties toward tied
From the BT6 re-audit: the config of the module that owns the head now
decides first (the top-level config when the top-level model holds the head,
as transformers 5 ties), weighed with its own text config so either saying
tied means tied. Tie metadata is matched with shared module prefixes removed,
and a link-bearing map that never names the pair is undetermined rather than
untied. Ambiguity now resolves toward tied or cannot-establish, never untied.
2026-11-24 16:03:06 -05:00
Joseph Magly 43393d841b Merge main 16f181a into fix/600-602-vocab-discovery-roundtrip-concurrency 2026-11-24 15:59:08 -05:00
Joseph Magly c3d134cf24 fix(vocab-surgery): pin ID-only operations to the tokenizer vocabulary in apply and recipes
From the BT6 audit of this PR: discovery now emits ID-only operations
routinely, so applying a config with a different tokenizer could edit the
wrong rows. Discovery embeds the tokenizer vocabulary SHA-256 in the config
(a field serialized only when set, so existing configs and bundled recipe
digests are unchanged). One shared guard, called by `vocab-surgery apply` and
the recipe technique, refuses ID-only operations unless the pin matches the
loaded tokenizer. The CLI keeps an explicit, receipt-recorded
--allow-unpinned-id-operations; the recipe path has no opt-out. An
unavailable vocabulary digest is recorded with a reason, and discover writes
the config before the report.
2026-11-24 15:59:05 -05:00
Joseph Magly f1daae32a4 Merge main 16f181a into fix/599-601-vocab-surgery-tie-budget 2026-11-24 15:54:08 -05:00
Joseph Magly f58eed2857 fix(vocab-surgery): prefer specific tie sources and compare offloaded values device-safely
From the BT6 audit of this PR: decide offloaded ties from the most specific
source first (pair tie metadata, then the head-owning sub-model's flag, then
the text config, then the top-level flag), so a composite config's top-level
tie_word_embeddings no longer overrides more specific metadata. Compare
matrix values only when no source decides, in bounded CPU chunks, so mixed
resident/offloaded placement can't raise a device mismatch. An empty tie map
is undetermined rather than untied. Add tests for the resident row-transaction
failure paths.
2026-11-24 15:54:06 -05:00
Joseph Magly fa719ec885 docs(checkpoints): avoid a backticked project name the docs checker runs as a CLI example
scripts/check_checkpoint_docs.py treats inline code that starts with the
project name as a CLI example and parses it, so the runbook wording added for
#626 failed test_checkpoint_documentation_contract_passes_offline.
2026-11-24 15:52:06 -05:00
Joseph Magly 1760d85238 Merge main 16f181a into fix/626-install-hints 2026-11-24 15:45:49 -05:00
Joseph Magly 39ff5861da Merge main 16f181a into fix/606-607-604-report-metrics 2026-11-24 15:45:41 -05:00
Joseph Magly 931b630f92 Merge main 16f181a into fix/611-603-cli-json-mcp-hint 2026-11-24 15:45:39 -05:00
Joseph Magly d8f2094a4b Merge main 16f181a into fix/612-613-checkpoint-snapshot 2026-11-24 15:45:37 -05:00
Joseph Magly 16f181a578 Merge pull request #605 from elder-plinius/feat/590-analysis-on-device
Run abliteration analysis math on the model's device
2026-11-24 15:36:12 -05:00
Joseph Magly 3cdc3ce065 fix(checkpoints): stop naming the quarantined PyPI project in install hints
The checkpoint adapter reason rendered `install_extra=obliteratus[<extras>]==<version>`,
and the refusal-recovery pilot printed `install obliteratus[recovery]`. pip
resolves both against an index, where the `obliteratus` project is
quarantined with no installable files. The reason keeps its `install_extra=`
key with bare extra names and adds `install_hint` (source checkout
`uv sync --locked --extra ...`) and `project_version`, within the schema's
2048-character limit. The pilot gives the same source-checkout guidance.

Fixes #626
2026-11-24 15:33:00 -05:00
Joseph Magly d92f8b9804 fix(checkpoint): fail closed on duplicate DCP and DeepSpeed shard basenames
The DCP (.metadata, *.distcp) and DeepSpeed zero-rank detectors scanned
every inventoried file instead of the duplicate-checked name map, so after
the #612 change two sibling DCP sets (or duplicated zero_pp_rank_* files)
merged into one component instead of failing closed as before. Detectors now
select from the name map through shared basename predicates, and a guard test
fails if any detector consumes a basename the duplicate check does not cover.
2026-11-24 15:30:44 -05:00
Joseph Magly 09d7df5e03 fix(viewer): chart only metrics with a measured baseline
The results viewer preferred primary_metric whenever the key existed, but
unavailable metrics are saved as null, so the #607 case threw in toFixed
and rendered nothing. Use the study metric only when its baseline is a
finite number (own property only), otherwise the first measured metric, as
`obliteratus report` does; skip ablations without a measured value and show
a message when nothing is measurable.
2026-11-24 15:27:15 -05:00
Joseph Magly 4643c0f295 fix(vocab-surgery): enforce tie policy for offloaded weights and bound edit memory
Decide offloaded embedding/head ties from shared backing, tie metadata and
tie_word_embeddings instead of materialized tensor identity. Tied offloaded
edits commit through every backing alias, and tie status that cannot be
established fails closed.

Resident edits are now row-level with row-only rollback. Edits are admitted
against an edit-memory budget (default half of available host memory, or
edit_memory_bytes=) before any allocation or write.

Fixes #599
Fixes #601
2026-11-24 15:12:40 -05:00
Joseph Magly 9d766b48b7 fix(vocab-surgery): resolve discovered tokens by id and refuse concurrent output clobbering
Discovery checks that each token's text resolves back to its id. Tokens that
don't round-trip become flagged ID-only operations instead of failing at
apply time or being silently dropped. Reports record the tokenizer
vocabulary SHA-256, and apply/discover accept --expected-tokenizer-sha256.

apply rechecks its destination under the commit lock (new opt-in
replace_existing=False on atomic_checkpoint_directory); discover publishes
its files atomically with exclusive creation. Other checkpoint writers are
unchanged.

Fixes #600
Fixes #602
2026-11-24 14:54:36 -05:00
Joseph Magly c0c174a05b fix(report): preserve the study impact metric and report only plots written
Record the study's chosen impact metric as an optional `primary_metric` key
in results.json so `report` replays the same chart; files without the key
keep the first-metric behaviour. Write the impact and heatmap plots
independently, fall back to a metric with a measured change, and print only
the files written in this run, flagging stale plots from earlier runs.

Fixes #606
Fixes #607
Fixes #604
2026-11-24 14:44:28 -05:00
Joseph Magly 73b8b7233f fix(cli): emit clean JSON from runs commands and drop the PyPI MCP install hint
Add `runs` to the CLI machine-JSON command set so every durable-run
subcommand writes only its JSON document to stdout.

Replace the missing-`mcp`-extra hint with the source-checkout installs from
docs/MCP_LOCAL_SETUP.md. The PyPI project named `obliteratus` is quarantined
and has no installable files, so the hint no longer points there.

Fixes #611
Fixes #603
2026-11-24 14:43:55 -05:00
Joseph Magly 5d534fbb71 fix(checkpoint,snapshot): scope basename ambiguity to components; restore expanded buffers
Checkpoint inspection now fails on a repeated basename only for names the
format probes resolve (weights, shards, indexes, adapter/model config,
producer metadata); other files are inventoried by relative path.

Snapshot restore writes expanded (stride-0) resident buffers through a
non-overlapping view, keeping layout and identity. Values that vary along an
expanded axis are rejected before any write, and other internally
overlapping layouts are refused at snapshot creation.

Fixes #612
Fixes #613
2026-11-24 14:43:22 -05:00
Joseph Magly 001057182a fix(process): deliver SIGINT as KeyboardInterrupt and bound selector waits
Codex review r5 for #592 (2 x P2):
- A deferred SIGINT is raised as an exact KeyboardInterrupt instance
  carrying `signum` and the original exception as context, so
  `except KeyboardInterrupt` callers handle it and an uncaught one still
  exits by SIGINT on Python 3.12 (which only does so for the exact type).
  SIGTERM keeps ProcessInterrupted(SystemExit).
- Each post-cleanup selector wait is capped at the poll interval while
  the overall drain deadline is kept, so huge finite drain values cannot
  overflow the platform timestamp.
Docs note that a drain of zero skips the post-cleanup read. Regressions
fail on the previous head; verified on the pinned Python 3.12 lane.
2026-11-23 19:59:03 -05:00
Joseph Magly 71576c39f8 fix(process): bound post-cleanup drain and share signal state across owners
Codex review r4 for #592 (4 x P2):
- After the group is terminated, draining uses an independent short
  bound (0.25 s default, OBLITERATUS_PROCESS_DRAIN_SECONDS override) and
  then closes both pipes, so a descendant that escaped the group while
  holding stdout/stderr cannot hang the evaluator.
- Nested owners share pending cancellation up the ownership chain, so
  the earliest signal wins and is delivered exactly once in either
  order.
- A SIGINT during exception cleanup reaches the outermost owner as a
  KeyboardInterrupt with the original exception kept as context.
- Deterministic coverage of the ownership-loss guard: an independently
  reaped leader raises the ownership error with zero killpg calls.
Docs and docstrings now state that an inherited SIGCHLD=SIG_IGN is
rejected before spawning (fail closed) rather than restored.
2026-11-23 18:24:48 -05:00
Joseph Magly ffe66b8096 fix(process): drain safely, own reaping, and never drop cancellations
Codex review r3 (5 x P2):
- Evaluator output is drained while polling the leader's exit; once the
  leader exits the group is terminated and draining completes, so a
  descendant holding a pipe no longer turns a pass into a timeout/hang.
- Owned groups require exclusive reaping: SIGCHLD=SIG_IGN is restored
  to SIG_DFL for the owned scope, and detected loss of ownership fails
  closed without signalling an unreserved PGID (contract documented).
- A signal deferred during exception cleanup is forwarded to the
  enclosing owner while the in-flight exception is kept; ProcessSignals
  documents and tests 'first signal wins, delivered exactly once'.
- Test helpers track every group from creation and terminate+reap in
  finally, including before readiness and in nested verify-edit.
Regressions fail on the previous heads and pass now; also synchronizes
the vLLM repeated-stop test and covers the procfs fallback.
2026-11-23 16:39:51 -05:00
Joseph Magly 52c4d0eee5 fix(analysis): size SAE and exact LEACE work before choosing the device
Codex review r1 for #605:
- High: SAE expansion was estimated from _harmful_means, empty before
  collection, so it was sized as zero. SAE training counts now come from
  the configured positive and control prompts.
- High: exact affine LEACE was sized as float32 but fits in float64 on
  CPU/CUDA. Device selection and distill admission now budget its
  covariance, decomposition and live operands at the fitter's actual
  dtype, shared from leace_exact.
- Medium: terminal cleanup after a failed run now drops all transient
  analysis references (means, shield atoms, directions, subspaces,
  workspace, resolved device) so accelerator memory is released.
Regression tests cover SAE and exact-LEACE fallback at a mocked memory
boundary, LEACE in distill admission, and cleanup after PROBE and
DISTILL failures.
2026-11-23 16:12:16 -05:00
Joseph Magly 2d79987f9b Merge remote-tracking branch 'upstream/main' into fix/589-search-process-groups 2026-11-23 12:21:30 -05:00
Joseph Magly f2db169384 Merge upstream/main into feat/590-analysis-on-device
Resolve against #593 (quick-check settings) and #591 (tied-head
migration) by keeping both sides: the pipeline gains analysis_device
alongside refusal_check_mode/confidence; migration and the shipped
recipes emit allow_tied_head_edit and the analysis_device cpu pin;
_structured relaxes both the refusal-check settings and
analysis_device for historical resolution records; both sides' tests
are kept.
2026-11-23 12:20:52 -05:00
Joseph Magly d62f4aafe9 feat(abliterate): run analysis math on the model's device
When the model is on CUDA or MPS, activation stacks and the analysis
math (difference means, winsorizing, whitening, per-layer SVD in
float32, refinement and KL logits) now stay on that device instead of
being copied to the host, where they used about 10 host cores per edit.
A new analysis_device setting (auto | model | cpu) is a v2 projection
parameter: auto, the default for v2 recipes, uses the model's device and
falls back to the CPU with a logged reason for offloaded, split or meta
models or when the pre-collection memory estimate exceeds free device
memory. The device actually used is recorded in resolution records and
checkpoint metadata. v1-migrated recipes and the shipped recipes pin
cpu so confirmations made with CPU-extracted directions re-apply
exactly; direct pipeline calls keep their CPU default. CPU results are
unchanged.

Fixes #590
2026-11-23 12:19:09 -05:00
Joseph Magly 1de580f7a1 Merge pull request #595 from younger-plinius/research/vocabulary-row-edits
Add experimental vocabulary-row editing with prompt and export audits
2026-11-23 12:18:46 -05:00
Joseph Magly cb49b92777 Merge remote-tracking branch 'upstream/main' into fix/589-search-process-groups 2026-11-23 12:18:43 -05:00
Pliny the Younger 5e55cdae09 Add experimental vocabulary-row editing with prompt and export audits 2026-11-22 22:18:34 -05:00