Layer 16/28 Dense Latch · 98 KB
Pre-tool shortcut & 503 fabrication breaker with L14, L16, L18, and L20 manifold steering vectors (1.000 calibration AUROC, 0.978 <think> pre-tool AUROC in Paper 1).
Open source / PyPI 0.1.0 / vLLM · SGLang · Diffusers · NVIDIA Cosmos
Across autoregressive tool agents, 3D video generators, and action-conditioned robot world
models, unfaithful tool shortcuts and sycophantic physics hallucinations crystallize inside
the residual stream near 57.1% network depth long before external LLM compliance auditors,
3D-VAE pixel critics, or built-in value heads notice anything wrong.
latchgate unifies the mechanistic control trilogy
(Agentic Sabotage,
Sparse Temporal Latching, and
Sycophantic World Models) into a single
MIT-licensed compiler and runtime that turns 50 to 200 paired counterfactual traces into
portable, pickle-free .lgate artifacts with zero benign capability tax.
safetensors .lgate packs01 / ADAPTIVE COMPILER
Generic Sparse Autoencoder pretraining expects billions of tokens, yet linear probes
already separate pre-tool shortcut commitments cleanly in 7B to 9B LLMs while collapsing
under pose, camera, and velocity superposition in 2B edge models and 3D Diffusion
Transformers. Given paired clean, bad, and high-velocity confounder activations,
latchgate fit benchmarks cross-validated out-of-fold AUROC at 57.1% depth
and routes automatically between two compiled architectures.
Selected automatically when linear separability holds (Qwen2.5-7B,
Gemma-2-9B). Compiles standardized detection weights alongside
manifold-aligned planning-block steering vectors (0.999985 cosine parity with
closed-loop Paper 1 breakers) so low-variance residual channels are never amplified.
Selected when superposition collapses dense probes (Gemma-2-2B,
LTX-Video-0.9.5, Cosmos-Predict2.5,
Cosmos-Policy). Applies token-first sparse encoding before spatial-temporal
pooling and penalizes norm-matched confounders via
TopK(d_bad - λ d_confound).
When a frozen open-weights SAE already exists (such as Gemma Scope params.npz
or a shared Cosmos backbone checkpoint), passing --base-sae
skips dictionary pretraining altogether and calibrates task-specific diagnostic latents
and conformal thresholds in under 10 seconds. When training a new 16,384-latent
JumpReLU dictionary from scratch via latchgate train-sae, the
trainer incorporates activation replay buffering (Koriagin et al., 2026) to prevent temporal
correlation collapse on sequential video tokens and optional channel-weighted reconstruction
(--wsae-weights) for heavy-tailed world-model channels.
02 / TWO RUNTIME SURFACES
<think> traces in LLMs and sycophantic rollouts in Cosmos.
Every compiled .lgate pack loads with cryptographic SHA-256 verification
via LatchGate.from_pretrained(...) and attaches to production open-weights
inference loops without fine-tuning model weights or running pixel-space decodes on
rejected trajectories.
TOOL_CALL:
Monitors the token-28 <think> checkpoint and the pre-tool
boundary in under 1 ms. On benign coding prompts the hook stays dormant (0.0%
false triggers); when shortcut commitment crosses τ, it aborts or
latches 4-layer manifold steering across TOOL_CALL: to defeat Action Re-Locking.
from latchgate import LatchGate, TransformersLatchHook
gate = LatchGate.from_pretrained("qwen2.5-7b-sabotage", device="cuda")
hook = TransformersLatchHook(gate, policy="latched_steer")
with hook.attach(model) as telemetry:
out = model.generate(**inputs, max_new_tokens=160)
print(telemetry)
Evaluates Layer-16 sparse physics latents at Step 10/35 for synthetic
DreamGen curation (cutting dataset corruption 11.3× while saving
26.1% GPU compute) or shields Cosmos-Policy Best-of-K MPC at Step 3/10
against Silent Sycophantic Physics (80.0% LIBERO selection).
from latchgate import CosmosLatchFirewall, LatchGate
gate = LatchGate.from_pretrained("cosmos-predict2.5-bridge", device="cuda")
firewall = CosmosLatchFirewall(gate, policy="early_abort", abort_step=10)
with firewall.attach(world_model.dit) as step_cb:
latents = world_model.rollout(frame0, actions, step_callback=step_cb)
03 / PRE-BUILT .LGATE PACKS
Run latchgate list-packs and latchgate pull <name> to fetch
any pre-calibrated gate directly from GitHub Releases or Hugging Face Hub. Every artifact
stores pure safetensors weights plus embedded JSON metadata with zero Python
pickle execution.
Pre-tool shortcut & 503 fabrication breaker with L14, L16, L18, and L20 manifold steering vectors (1.000 calibration AUROC, 0.978 <think> pre-tool AUROC in Paper 1).
Token-28 Silent Commitment & pre-tool circuit breaker cutting <think> sabotage from 66.7% to 5.6% at 100.0% benign CoT accuracy (Paper 1).
Edge-model closed-loop gate rescuing Gemma-2-2B’s α = +0.25 polysemantic over-refusal cliff from 0.0% to 96.7% benign coding accuracy (Paper 1).
6-bin σ-standardized Step-8 silent-drift detector and Step-12 zero-decode early-abort seed latch reaching 0.908 AUROC (+54.4 pts over dense; 109.4× faster than Tweedie VAE + DINOv2 in Paper 2).
Motion-invariant real-robot Bridge V2 DreamGen curation gate reaching 0.9861 out-of-fold AUROC, 97.1% accepted physical purity, and 26.1% end-to-end GPU compute savings (Paper 3).
Step-3/10 zero-decode MPC shield with per-suite conformal thresholds (Spatial, Object, Goal, LIBERO-10) defending Cosmos-Policy’s internal value critic and lifting Best-of-K selection to 80.0% (Paper 3).
04 / CI-TO-RUNTIME LOOP
Curating paired counterfactual trajectories by hand is the main bottleneck when deploying
activation gates on proprietary tool schemas. Starting in
Mendmark v0.7.2, mendmark export-latchgate
converts clean passing agent cases and planted trace mutations (or strictly the
evaluator-evading survivors via --survivors-from audit.json) directly into
latchgate.pair.v1 JSONL training pairs for latchgate fit.
latchgate fit compiler (dense_latch + sae_anchor_latch)< 10 s frozen --base-sae task calibration (.safetensors, Gemma Scope .npz, .lgate)latchgate train-sae with optional WSAE channel weightingTransformersLatchHook, VLLMLatchEngine, and SGLangLatchHookCosmosLatchFirewall, DiffusersLatchCallback, and shield_value_criticmendmark export-latchgate JSONL ingestion0.0% benign false-trigger thresholds hold on the calibrated prompt or task distribution and should be re-verified when policies or tool schemas shift05 / GET STARTED
latchgate is MIT-licensed on GitHub with CPU and single-GPU unit tests,
safetensors checkpoint tooling, and end-to-end integration with
mendmark-evals 0.7.2. Explore the source repository, download the
six pre-built .lgate packs, or read the three underlying research studies.