- plastic
- Four contributions in Plastic v2
- Pillar A1 — Endpoint-Capable Rank-2 Householder DeltaProduct with Uniform Boundedness
- Pillar A2 — Norm-Bounded, Per-Prefix SwiGLU Memory (
memory="mlp"; strongest algorithmic priority claim) - Pillar B — 3-Way Epistemic Separation & Cue-Indexed On-Policy Sleep Consolidation
- Pillar C — Transactional Fast-Weight Safety Harness & Frozen-Anchor Minimax Training (strongest systems contribution)
- v1 vs. v2 Verified Empirical Results
- Where the research stands
- Install and run
- The from-scratch model (PlasticCore)
- The pretrained TTT chat model
- The safety harness
- Domains and testbeds
- Sessions, red team, and sleep
- Usage
- Layout
- Archived v1 Experiments (Baselines Retained as Evidence)
- Honest limits
- License
- Four contributions in Plastic v2
plastic
Test-time-training models with a transactional safety harness, and a study of what they can learn lastingly from experience.
Live Workbench (plastic.dtmont.com) ·
Source on GitHub ·
Models on Hugging Face ·
Live Hugging Face Space
Weights: TTT chat safetensors · PlasticCore text · PlasticCore physics · Download instructions and checkpoint identities
plastic studies models that learn while they read: their memory is a set of fast
weights that take gradient steps on a self-supervised objective as tokens arrive, so
context is compressed into weights instead of a growing cache. Three substrates share
one transactional safety harness:
- PlasticCore (v1 & v2), a from-scratch model of ~6M parameters: a selective state-space
recurrence plus fast-weight memory (
delta,chunk, v2deltaproductwith energy-coupled uniform boundedness, and v2 causalswiglunonlinearmemory="mlp"), meta-trained end to end through its inner loop. The same block stack serves text and hidden-friction physics. - A pretrained TTT-MLP chat model: the 760M TTT-MLP of Sun et al. (RetentionLabs conversion), whose sequence layer is a two-layer MLP updated by inner gradient steps on every 16-token mini-batch, chat fine-tuned for 250 steps on 8,000 SmolTalk conversations.
- A coordinate block (experimental): a selective recurrence whose nonlinear fast weights change the coordinates of its own state with exact canonical carry transport, studied on a physics mechanism testbed.
A Qwen model is available as an observational comparison; it has no test-time-training layer.
Learning at inference is a security surface: every input is a gradient step, so a hostile
input is not just a bad answer, it is a bad thing learned. plastic wraps the inner loop
in a transactional harness—each chunk is a transaction that measures model-native signals
(loss, surprise, write rate, update norm, curvature, probe drift, and anytime-valid risk
wealth) and decides whether to commit, smoothly damp, project, roll back, or quarantine,
with zero regex or keyword heuristics. Sessions are persisted and branchable, like version
control for plastic weights.
This is a research sandbox, not a product. It runs in plain PyTorch on an Apple Silicon laptop or a single cloud GPU, and is explicit about what is proved, what is measured, and what remains open.
Four contributions in Plastic v2
Plastic v2 redesigns all three pillars from first principles. To keep priority claims
honest (per AGENTS.md), each section below separates adopted 2024–2026
primary literature from what plastic v2 adds. Across the four pieces,
norm-bounded per-prefix SwiGLU reads (Pillar A2) is the strongest algorithmic priority
claim, and the transactional fast-weight safety harness (Pillar C) is the strongest
systems contribution.
Pillar A1 — Endpoint-Capable Rank-2 Householder DeltaProduct with Uniform Boundedness
Adopted foundation: Negative-eigenvalue generalized Householders (Grazzi et al., ICLR 2025,
arXiv:2411.12537), rank-$m$ Householder products (DeltaProduct, Siems et al., NeurIPS 2025,arXiv:2502.10297), decoupled erase/write gating (Gated DeltaNet-2, Hatamizadeh et al., Nov 2026,arXiv:2605.22791), and decay-regulated residual writing with an $O(\sqrt{T})$ state bound (Stable Gated DeltaNet-2, Zhang et al., Nov 2026,arXiv:2611.34051). The $\cot(\pi / 4n)$ operator norm of the unit-lower-triangular matrix below (yielding $\cot^2(\pi / 4n)$ via its alternating-sign inverse) is a classic theorem of Davies & Simon (2006) (J. Approx. Theory 141(2):189–213;mp_arc 06-50).What
plasticv2 adds (plastic/model/deltaproduct.py,tests/test_memory_v2.py):1. Length-independent uniform boundedness alongside exact orthogonal reflections. Standard signed DeltaProduct couples the additive write to $\beta_{t,r} \in [0, 2]$, which suffers linear resonant pumping ($\lvert S_t \rvert = 2t$ at $\beta=2, \alpha=1, v_t=(-1)^t$) and rotating-key $\Theta(\sqrt{T})$ norm growth even at $\beta=1, \alpha=1$. Whereas
Stable Gated DeltaNet-2(arXiv:2611.34051) couples writes to decay with an $O(\sqrt{T})$ bound,plasticv2's stricter decoupled gate (stability_mode="coupled_iss") trades stopping writes at full retention ($\alpha = 1 \implies \gamma = 0$) for a length-independent constant bound while permitting exact orthogonal reflections:
(Terminology note: this is uniform boundedness, not Sontag input-to-state stability,
because the exact identity/reflection mode $\alpha_{t,r}=1, \gamma_{t,r}=0$ deliberately
preserves $S_0$ forever without decay under zero input.) For associative-recall workloads
needing 1-shot writes at $\alpha \approx 1$, stability_mode="ball_retract" applies
$\gamma_{t,r} = g_{t,r}(1 - \lvert 1 - \beta_{t,r}\rvert)$ with exact 1-Lipschitz
Frobenius-ball retraction $\Pi_{B_R}$.
2. Endpoint-capable gates + optimal Job B initialization. Hard-clipped gates attain
exact $\beta \in {0, 1, 2}$ (necessary so $m=2$ can realize odd $S_3$ transpositions
via $\beta_1=2, \beta_2=0$ as well as planar rotations via $\beta_1=\beta_2=2$) and exact
$\alpha=1$ at finite logits, initialized at $\beta=1$ to eliminate the 41% sample-efficiency
penalty of sigmoid(0) = 0.5 under $c(\beta) = 2 / (2\beta - \beta^2)$.
3. Identifying repeated-key WY conditioning limits. For virtual chunk length $n = mL$ at $\alpha=1, \beta=2$ with identical keys, the unit-lower-triangular WY matrix $T = I + A$ reduces to the Davies–Simon (2006) matrix with exact inverse entries $(T^{-1})_{ij} = 2(-1)^{i-j}$ ($i > j$) and exact 2-norm condition number:
Recognizing where this matrix arises in repeated-key DeltaProduct WY solves dictates
capping virtual chunk length at $n = mL \le 64$ ($L=32$ at $m=2$) and running
solve_triangular strictly in fp32 (never Neumann powers or low-precision inversion).
Pillar A2 — Norm-Bounded, Per-Prefix SwiGLU Memory (memory="mlp"; strongest algorithmic priority claim)
- Adopted foundation: Parallel dual-form prefix reads for nonlinear fast-weight MLPs
(
TTT-MLP, Sun et al.,arXiv:2407.04620) and closed-form chunk-end momentum/decay on SwiGLU fast weights with chunk-start reads ($E^2$-TTT, Zhong et al., Nov 2026,arXiv:2608.21308). - What
plasticv2 adds (plastic/model/swiglu_memory.py,plastic/model/memory.py): Replaces the unimplementedmemory="mlp"(NotImplementedErrorin v1) and stale chunk-start reads (chunk_rule.py) with per-prefix reads of all three updated SwiGLU matrices $(W_1, W_2, W_3)$ under an in-prefix Frobenius norm cap without materializing $O(L d^2)$ per-token weight copies. For $f_W(x) = W_2 [\operatorname{SiLU}(W_1 x) \odot (W_3 x)]$, evaluating per-token inner gradients $G_i = \nabla_W \ell_i(W_c)$ at the chunk-start base $W_c$ yields rank-1 factors for all three matrices, giving exact evaluation of the stated common-base rule at every causal prefix weight $W_t = \rho_t Z_t$:
where $|Z_t|F$ is computed in closed form from causal Gram matrices of the rank-1 factors, and chunk-end momentum/decay uses division-free log-space $E^2$-TTT accumulation. *(Scope note: "exact" applies strictly to this stated common-base rule with gradients evaluated at chunk start $W_c$, not sequential SGD through evolving weights $W{t-1}$.)*
Pillar B — 3-Way Epistemic Separation & Cue-Indexed On-Policy Sleep Consolidation
- Adopted foundation: Google's SLEEP framework (
Language Models Need Sleep, Behrouz et al.,arXiv:2606.03979) for offline weight consolidation via Knowledge Seeding and generated practice/dreaming; offline consolidation and memory-admission filtering against planted/contaminated memories (Auto-Dreamer, Zhao et al., NeurIPS 2026,arXiv:2605.20616;A-MAC, Zhang, Zhao et al.,arXiv:2603.04549;ConsistencyGate, Zhang & Li,arXiv:2607.22962;DREAM, Liu et al.,arXiv:2610.13267); context distillation (Padmanabhan et al.,arXiv:2306.09306;DiSC,arXiv:2602.16093); self-study (Cartridges,2506.06266;SEAL,2506.10943); and Rao–Blackwellized on-policy reverse-KL self-distillation (SDFT, Shenfeld et al.,arXiv:2601.19897v2;BOPD,arXiv:2611.13680). - What
plasticv2 adds (plastic/sleep/epistemic.py,plastic/sleep/clusters.py,plastic/sleep/consolidation_v2.py,tests/test_sleep_v2.py):- 3-Way Epistemic Separation (Novelty $\neq$ Harm): Fixes v1's surprise-based
flagged_policy="exclude"(which dropped 29/30 valid teaching turns) by separating (a) typed scoped evidence records $m = (s, r, o, \kappa, t, \text{speaker}, \text{source}, \text{prov})$ distinguishing user-scopedpersonal_reports fromworld_claims; (b) decision-theoretic admission (retain_scopedvs.quarantineon high scoped semantic conflict $C(q; z, z') = \log\frac{\widehat{P}_0(z' \mid q, \kappa)}{\widehat{P}_0(z \mid q, \kappa)}$ without independent corroboration); and (c) separate Fisher behavioral interference $\frac{1}{2}\Delta^\top F_P \Delta$. (Important implementation disclosure: inplastic/sleep/epistemic.py, quarantining the4/4planted world contradictions relied on_WORLD_PATTERNSand supplied canonical alternatives in_BUILTIN_WORLD_PRIORSscored alongside the reset model's greedy answer. This demonstrates that the admission policy can act on supplied reference knowledge while admitting all 24 novel personal reports; open-world detection of unfamiliar falsehoods remains open.) - Cue-Indexed Multi-View Study Clusters + Hybrid SDFT + Metric-Projected Trust Region:
Eliminates v1's 1-to-24 unindexed dreaming collision (whose exact forward-KL optimum is
the mixture $p^\star(y \mid q) = \sum_i w_i p_i(y)$) by building entity/relation-indexed
views (
forward_qa,paraphrase_qa, identifiablereverse_qa,entailment_qa), trained via hybrid supervised + forward-KL + Rao–Blackwellized on-policy reverse-KL SDFT across dual targets (W0+ slow MLP LoRA) under the local metric-projected trust-region step:
- 3-Way Epistemic Separation (Novelty $\neq$ Harm): Fixes v1's surprise-based
Pillar C — Transactional Fast-Weight Safety Harness & Frozen-Anchor Minimax Training (strongest systems contribution)
Adopted foundation: Whole-trajectory conformal calibration (Zhou, Lindemann, & Sesia, ICML 2024, PMLR v235), Predictive Rank Martingales (
PRM,arXiv:2609.00536), non-partitioned e-detectors (Saha & Ramdas,arXiv:2607.28322), Conformal Policy Control (CPC, Prinster et al., ICML 2026,arXiv:2603.02196), rotating safety-Fisher subspaces (SafeAnchor,arXiv:2604.17691), and second-order curvature-coupling collapse (Springer et al.,arXiv:2602.15799).What
plasticv2 adds (plastic/harness/,plastic/train/adversarial.py,plastic/redteam/attack.py,tests/test_harness_v2.py):1. Dependence-Honest Sequential Control + Orthogonal Deterministic Budget. Naive split-conformal e-processes violate Ville's inequality under finite calibration reuse (exact 11.1% violation at $n_{\text{cal}}=1$ for nominal 1%) and Markov state dependence.
Harness v2combines Route-C Closed-Loop Full-Trajectory Session Calibration (which provides a finite-horizon false-alarm guarantee $\Pr_0(\text{any intervention} \le T) \le \alpha$ specifically for the stated horizon $T$ and exchangeable benign sessions), a live innovation-whitened strided PRM weighted-SR e-process $Z_t$ driving smooth CPC write authority $\gamma_t \in [0, 1]$ (replacing binary permanent latching), and an orthogonal deterministic full-state path budget $\sum_t |S_t - S_{t-1}|F \le B{\text{path}}$. On our vocab-128 benchmark (n=200disjoint 16-chunk sessions), this operating point achieved0/200benign sessions flagged alongside22/64poison sessions detected (16/16random,3/16repeat-phrase,3/16shuffled,0/16repeat-token).2. Exact
I5Manifold-Aware Scaling &I1-strictAtomic Tuple Rollback. Fixes v1's 4× scaling paradox (beta_scale=0.5leaving decay unscaled) via exact complete-transition interpolation for Euclidean states and exact chord-contracting angle reparameterization for Householder reflections $H(u) = I - 2uu^\top$:
3. Multi-Constraint Woodbury Curvature QCQP + Frozen-Reference Minimax Training.
Replaces hardcoded project_eps_cos=0.02 with a calibrated second-order proposal
generator (corrected conservative poison sign $-g_p^\top \Delta + \frac{\kappa_p}{2}|\Delta|2^2 \le \tau_p$,
SafeAnchor incremental-SVD subspace tracking, and mandatory finite canary recheck), and
replaces v1's unclamped after - before adversarial loss with a **frozen-reference
$\theta{\text{ref}}$ constrained minimax objective** over fluent discrete GCG/ST attacks
paired with an explicit retained-write utility floor $U_{\text{write}}(\theta) \ge U_{\min}$.
v1 vs. v2 Verified Empirical Results
Every number below is read directly from committed raw benchmark outputs and reports
(experiments/exp_v2_core/results/,
experiments/exp_v2_sleep/REPORT.md,
experiments/exp_v2_harness/REPORT.md).
| Pillar & Benchmark | Metric | Plastic v1 | Plastic v2 | Source & Verification |
|---|---|---|---|---|
A1. State Tracking (S3, train 8–32) |
Accuracy at $L=32 / 64 / 128 / 256 / 512 / 1024$ (2 seeds) | 0.327 / 0.245 / 0.209 / 0.185 / 0.178 / 0.171 |
1.000 / 1.000 / 0.971 / 0.814 / 0.598 / 0.413 |
state_tracking.json, test_memory_v2.py |
A1. State Tracking (mod3, train 8–32) |
Accuracy at $L=32 / 64 / 128 / 256 / 512 / 1024$ (2 seeds) | 0.838 / 0.593 / 0.466 / 0.398 / 0.365 / 0.351 |
1.000 / 1.000 / 1.000 / 1.000 / 0.897 / 0.611 |
state_tracking.json |
A1. State Tracking (parity, train 8–32) |
Accuracy at $L=32 / 64 / 128 / 256$ (2 seeds) | 0.763 / 0.636 / 0.570 / 0.532 |
1.000 / 0.993 / 0.844 / 0.679 |
state_tracking.json |
| A1. Job B Precision Scaling ($d=128$) | Slope (theory opt 2.0) / median samples to $10^{-6}$ |
2.805 / 4,961 |
1.982 / 3,505 (-29.4% samples) |
job_b_mqar.json |
| A1. MQAR Recall (500 steps) | Final eval accuracy (ball_retract vs coupled_iss*) |
0.239 |
0.271 (coupled_iss: 0.154*) |
job_b_mqar.json |
A2. Nonlinear Recall (memory="mlp") |
Eval MSE / $R^2$ (800 steps) | 0.1448 / 0.160 (linear delta) |
0.0360 / 0.791 (4.0× lower MSE) |
swiglu_nonlinear.json |
| B. Sleep on 760M TTT-MLP (A100, full reset, 1 seed) | Taught verbatim recall / unseen paraphrase (/24) |
0/24 (0.0%) / 0/24 (0.0%) |
20/24 (83.3%) / 15/24 (62.5%) |
exp_v2_sleep/REPORT.md, summary_760m.json vs summary_760m_v1_baseline.json |
| B. Sleep 760M Epistemic & Locality | Admission / plants quarantined§ / NLL $\Delta$ / cluster share | 0/24 admitted / Moon collapse / -0.171 / 0.143 |
24/24 admitted / 4/4 quarantined§ / +0.0131 / 0.0714 |
summary_760m.json, test_sleep_v2.py |
| C. Harness Operating Point ($n=200$ benign + $64$ poison, 16 chunks) | Benign ANY-intervention [95% CI] / Poison sessions caught (random) |
200/200 = 100.0% (78.2% ch; Exp 3 WT103: 47.8%) / 62/64 (16/16) |
**0/200 = 0.00% [0.00%, 1.88%] / 22/64 (16/16 random)**† |
exp_v2_harness/REPORT.md, results.json, test_harness_v2.py |
| C. Adversarial Training (Minimax) | Held-out NLL / write utility $U_{\text{write}}$ / PGD / Fluent GCG dmg | 3.201 / +0.145 / -0.435‡ / -0.126‡ |
3.138 / +0.152 / +0.198 / +0.137 (vs base +0.718 / +0.500) |
exp_v2_harness/REPORT.md, results.json |
Honest footnotes on measured tradeoffs & scope:
- *
coupled_issvs.ball_retracton MQAR: Strictly coupling write amplitude to $1 - \alpha_t$ (coupled_iss) trades away 1-shot associative write strength at high retention (0.154vs0.239);ball_retractpreserves 1-shot MQAR writes (0.271) while maintaining the Frobenius-ball norm bound. - § Supplied canonical alternatives in
epistemic.py: The4/4quarantined planted contradictions matched_WORLD_PATTERNSand used supplied canonical alternatives in_BUILTIN_WORLD_PRIORS(plastic/sleep/epistemic.py) alongside reset-model scoring—showing the policy acts on supplied knowledge while open-world detection of unfamiliar falsehoods remains open. The main empirical result is the single-seed post-reset recall (20/24verbatim,15/24unseen paraphrase) at+0.0131NLL drift. - † Harness v2 full operating point: On the vocab-128 benchmark (
experiments/exp_v2_harness/REPORT.md), holding benign session intervention at0/200 = 0.00%(0/3,200chunks) detected22/64 = 34.4%of poison sessions (16/16 = 100.0%random,3/16 = 18.8%repeat_phrase,3/16 = 18.8%shuffled,0/16 = 0.0%repeat_token), whereas v1's62/64came at200/200 = 100%benign session flagging. Low-loss repetition poisons require explicit low-entropy/compression features or a higher recall operating point. - ‡ v1 unclamped adversarial loss artifact: Negative PGD/GCG damage (
-0.435,-0.126) under v1 reflects its unclampedafter - beforeobjective rewarding perturbations that lower coherence loss relative to a moving baseline rather than strictly bounding worst-case drift against a frozen anchor $\theta_{\text{ref}}$. - Scope caveats: State tracking ran 2 seeds on CPU (not yet the 8-seed GPU sweep); 760M Sleep v2 ran 1 seed on the 24 historical facts (general knowledge probes moved
3/7, 4/7 -> 2/7, 2/7; the 200-fact / 300-plant 5-seed confirmatory battery and Exp 4 v2 composition benchmark remain next).
Where the research stands
The core question is whether experience can change a model's weights so that it performs better on unseen situations after the conversation and fast-weight state are gone, with the benefit disappearing when weights are restored, and while refusing wrong or adversarial lessons. See current status for the complete timeline.
- Sleep v2 broke the 0/24 barrier on the published 760M TTT-MLP checkpoint (single seed):
On NVIDIA A100,
sleep_v2_dualraised post-reset taught recall from0/24(verbatim and unseen paraphrase) to20/24verbatim (83.3%) and15/24unseen paraphrase (62.5%) with+1.126nats/tok answer log-prob lift,+0.0131held-out SmolTalk NLL drift, and0.0714reply cluster share (experiments/exp_v2_sleep/REPORT.md). The admission policy admitted24/24novel personal reports and quarantined4/4planted contradictions using supplied canonical alternatives inepistemic.py(open-world detection of unfamiliar falsehoods remains open). Multi-seed and 200-fact / 300-plant confirmatory runs are next. - Fast-weight core v2 solved $S_3$/
mod3/parityin-distribution & mid-horizon extrapolation, removed the Job B sample penalty, and shipped norm-bounded per-prefix SwiGLU fast memory (experiments/exp_v2_core/,tests/test_memory_v2.py). - Harness v2 eliminated benign session lockout (
0/200benign flagged alongside22/64poison detected,16/16random, vs. v1's200/200benign flagged), passedI1-strictandI5(including Householder chord-contracting scaling), and fixed adversarial minimax training (experiments/exp_v2_harness/REPORT.md,tests/test_harness_v2.py). - Live Workbench v2 is deployed at
plastic.dtmont.com(Cloudflare Worker + Cloud Run) alongside the repaired CPU-PyTorch Hugging Face Space (huggingface.co/spaces/dmontgomery40/plastic), with live counterfactual inspection (adapted vs. frozen vs. unguarded), v2 wealth/authority telemetry, and interactive Sleep Lab (tests/test_api_v2.py). - Archived Sept 2026 baselines (retained as evidence): On the text rule task, 20 steps
on
W0improved second-answer format adaptation (0.31 -> 1.0) but failed first-answer wrong-name controls (corrected runs); the experimental coordinate block matched the v1 delta baseline on physics on one seed.
Install and run
uv sync --extra dev --extra pretrained # pretrained: transformers, for the TTT and Qwen backends; add --extra jev for Jev grading
npm --prefix dashboard ci
uv run pytest # full test suite (incl. test_*_v2.py)
uv run plastic --help
./start.sh # API on :13579, dashboard on :5173
Python 3.12, PyTorch 2.12 or newer. MPS on Apple Silicon, CUDA on Hugging Face Jobs / Cloud Run.
The from-scratch model (PlasticCore)
One block, stacked four times for text and three for physics, all in plain PyTorch on CPU, MPS, and CUDA.
A selective state-space branch provides activation-level context: a gated linear recurrence with per-channel input-dependent decay computed by a chunked log-space scan whose pairwise decay ratios lie in $(0, 1]$ (exact against a sequential reference to within $2 \times 10^{-5}$).
A fast-weight memory branch implements the test-time-training layer behind one
interface (plastic/model/memory.py) supporting four rules/memories:
rule="delta"(v1 baseline): single-step gated delta rule with $\beta_t \in (0, 1)$:
rule="chunk"(v1 mini-batch): chunk-level updates with Titans momentum and optional Newton–Schulz orthogonalization.rule="deltaproduct"(v2 Pillar A1,plastic/model/deltaproduct.py): endpoint-capable rank-2 Householder DeltaProduct ($\beta_{t,r} \in [0, 2]$, $\alpha_t \in [\alpha_{\min}, 1]$) with decoupled uniform boundedness (coupled_iss) or Frobenius-ball retraction (ball_retract) and exact fp32 virtual-chunk WY solves ($n = mL \le 64$).memory="mlp"(v2 Pillar A2,plastic/model/swiglu_memory.py): norm-bounded per-prefix SwiGLU memory (exact for the common-base rule) with closed-form Gram-matrix norm capping and $E^2$-TTT chunk-end momentum/decay.
Meta-training runs sequences from initial fast state $S_0$ and backpropagates ordinary
next-token loss through every inner update. Both delta and deltaproduct have closed-form
chunk-parallel WY forms matching their recurrent inference paths; swiglu prefix memory
evaluates exact causal rank-1 updates in parallel.
The pretrained TTT chat model
plastic/backends/ttt_lm/ runs the 760M TTT-MLP under the same harness. Its inner loop's
reconstruction error (surprise), learned per-token step size, and exact per-token write
norm are transaction signals, and freezing holds fast weights bit-identically. The base
chat checkpoint was fine-tuned for 250 steps on SmolTalk (evaluation)
and serves as the 760M substrate for the Sleep v2 consolidation benchmark above.
The safety harness
Every input chunk is a transaction against three copies of the session state: committed, working, and the pending chunk. At each chunk boundary the harness computes signals entirely from the model and decides what to do with the update.
| Signal | What it is |
|---|---|
| chunk loss | the model's own confusion on the chunk (out-of-distribution proxy) |
| surprise | the inner-loop prediction error $\lVert e_t \rVert_2$, independent of the write rate |
| write rate $\beta$ | the learned gate the model applied to each token |
| update norm & path budget | actual representable state delta $\lVert S_t - S_{t-1} \rVert_F$, cumulative path $\sum d_t \le B_{\text{path}}$, and Fisher-weighted size |
| canary suites | a coherence set whose loss must not rise, a poison set whose loss must not fall |
| curvature & alignment | canary gradient alignment, multi-constraint Woodbury QCQP residual, and rotating safety-Fisher quadratic form $\frac{1}{2}\Delta^\top F_P \Delta$ |
| sequential risk wealth | v2 Route-C closed-loop trajectory calibration + whitened strided PRM weighted-SR e-process $Z_t$ $\to$ smooth CPC write authority $\gamma_t \in [0, 1]$ (plus v1 two-sided CUSUM for comparison) |
Decisions are commit, scale (smooth CPC risk damping or budget scaling using exact
complete-transition interpolation / Householder chord-contracting angle scaling),
project (multi-constraint curvature QCQP proposal + mandatory finite canary recheck),
rollback (atomic I1-strict restore of fast state + pending chunk stats, reading
frozen without learning), or read-only / quarantine (spent deterministic budget or
hard wealth threshold requiring verification). There is no regex, no keyword list, and no
string inspection anywhere in the harness.
These signals measure how the model responds to an update; none proves that an arbitrary statement is true. The shipped chat canaries are 12 public true statements, 12 public contradictions, and three repetition probes: a small public specification of what to preserve, not protection for behavior outside it.
Domains and testbeds
Text. Byte-level BPE, wikitext-103 (or fineweb-edu). Next-token prediction, MQAR recall probes, and writes-enabled vs. writes-disabled comparisons.
Physics. A 2D point mass with an unobserved friction coefficient ([observation, action, reset flag] $\to$ next observation delta). On a laptop the adaptive model reaches MSE
0.0008 where the frozen-memory model sits at 1.04 (while an analytic causal estimator
knowing the simulator equation reaches 2.8e-5). Physics stays an internal benchmark; the
public workbench serves text.
Learning testbeds. A physics mechanism testbed (six hidden mechanisms) and a text rule task (named decorations of a word list) separate lasting weight updates from temporary in-context adaptation.
Sessions, red team, and sleep
Sessions persist their plastic weights, harness state, and full transaction log, and can
branch (plastic session fork|reset|resume|show). plastic redteam attacks a model on
the real discrete token path (including v2 fluency-constrained GCG/ST discrete attacks)
and re-validates payloads through the guarded transaction runner. plastic train --adversarial
meta-trains the write gate under the frozen-reference minimax objective. plastic sleep
consolidates accepted session experience into durable weights behind both epistemic
admission (Sleep v2) and post-reset verification gates.
Usage
# data and training
uv run plastic data prepare --corpus wikitext --out artifacts/data/wikitext
uv run plastic train text --data artifacts/data/wikitext --steps 3000 --device mps
uv run plastic train physics --steps 3000 --layers 3 --device mps
uv run plastic models
# a GPU run on Hugging Face Jobs (exports committed HEAD; uncommitted edits are not included)
scripts/hf_jobs/launch_text.sh l4x1 6000 BATCH=16 MODEL_ID=lm_wikitext_l4
hf jobs logs -f dmontgomery40/<job_id>
hf buckets sync hf://buckets/dmontgomery40/plastic-runs/artifacts/models/<id> artifacts/models/<id>
# calibrate the harness, then open a session
uv run plastic calibrate <model_id> --data artifacts/data/wikitext
uv run plastic session new --model <model_id>
uv run plastic chat <session_id> "your prompt here"
uv run plastic physics <session_id> --steps 256 --mu 0.12
# attack and consolidate
uv run plastic redteam <model_id> --data artifacts/data/wikitext --record
uv run plastic sleep <model_id> --core artifacts/data/wikitext
# v2 verification & benchmarks
uv run pytest tests/test_memory_v2.py tests/test_sleep_v2.py tests/test_harness_v2.py tests/test_api_v2.py
uv run python experiments/exp_v2_core/bench_state_tracking.py
uv run python experiments/exp_v2_harness/benchmark_v1_vs_v2.py
Layout
plastic/
model/ selective scan, delta rule, v2 deltaproduct, v2 swiglu_memory, chunk rule, coordinate block, blocks, models, state
backends/ PlasticCore, pretrained 760M TTT-MLP, Qwen (observational)
data/ wikitext/fineweb pipeline, MQAR recall probes, hidden-mu physics, mechanism testbed, text rules
train/ outer loop, LR schedule, Muon/AdamW split, v2 frozen-reference minimax adversarial training
harness/ signals, PRM/e-process stats, Route-C calibration, canaries, Fisher, Woodbury QCQP projection, CPC policy, transaction runner
eval/ learning contracts and learners
session/ persisted, branchable sessions
redteam/ discrete token-path attacker (PGD + fluent GCG) validated through the harness
sleep/ v1 replay/distill/anchor/dream + v2 epistemic admission, cue-indexed clusters, hybrid SDFT consolidation
api/ FastAPI service with ephemeral sandboxes and live counterfactual endpoints
store.py models, sessions, transactions, forks, signatures
cli.py the `plastic` command
dashboard/ React workbench (`plastic.dtmont.com` & HF Space)
experiments/ exp1–exp4 baselines + exp_v2_core, exp_v2_sleep, exp_v2_harness
scripts/ Hugging Face Jobs launchers, training, experiments
docs/ design specs, research notes and surveys, archived results
Archived v1 Experiments (Baselines Retained as Evidence)
- Exp 1 & 2 (Eigenvalue ablation & rollback leakage):
report/REPORT.md,experiments/gpu/REPORT.md. Showed v1 $\beta \in (0, 1)$ fails $S_3$ (0.324at $L=32$) and drops to chance by $L=128$, while Job B established the $c(\beta) = 2/(2\beta - \beta^2)$ slope and the 41% penalty ofsigmoid(0). - Exp 3 (v1 harness invariants & policy-level FPR):
experiments/exp3_invariants/README.md. Exposed the 47.78% benign session intervention rate under v1's resetting CUSUM latch and uncappedproject_eps_cos=0.02, plus minimal counterexamples forI1-strictandI5(now resolved in v2). - Exp 4b/4c (First-answer composition of group actions, 60k–83k GPU steps):
experiments/exp4_compose/REPORT_4b.md. Demonstrated content-dependent fast-weight composition through depths 2–3 (and partial depth 4 on one seed) against deranged-name content nulls, motivating v2's iterative readout and nonlinear fast memory.
Honest limits
PlasticCoreis small (~6M parameters on wikitext); it demonstrates fast-weight dynamics, recall, and safety-harness behavior, not frontier language quality. The 760M TTT-MLP chat checkpoint is briefly fine-tuned (250 steps) and still makes general factual errors.- The 760M Sleep v2 result (
20/24verbatim,15/24unseen paraphrase) is a single-seed Phase-0 result on the 24 historical facts (with general knowledge moving3/7, 4/7 -> 2/7, 2/7); its4/4quarantined planted contradictions used supplied canonical alternatives inplastic/sleep/epistemic.py(open-world falsehood detection remains open), and multi-seed 200-fact / 300-plant confirmatory validation plus Exp 4 v2 composition runs remain next. - Harness v2's
0/200benign session FPR (22/64poison sessions caught;16/16random) on the vocab-128 benchmark holds at the calibrated horizon for exchangeable benign sessions and trades recall on low-loss repetition poisons (repeat_token0/16); any statistical detector can be evaded by a benign-mimicking adversary, which is why hard worst-case damage bounds rest on the orthogonal deterministic path budget $B_{\text{path}}$ and finite canary rechecks. - Every architectural primitive we built upon (generalized Householders, DeltaProduct,
Stable Gated DeltaNet-2, Davies–Simon 2006, TTT-MLP, $E^2$-TTT, Google SLEEP,
Auto-Dreamer, SDFT, DiSC, whole-trajectory conformal calibration, PRM, CPC, SafeAnchor)
is credited prior work;
plasticv2's clearest priority claims are norm-bounded per-prefix SwiGLU reads (algorithmic) and the transactional fast-weight safety harness (systems).
License
See LICENSE. Research and educational use.