on this page
Series Overview · Part I: The Illusion of Safe Tensors · Part II: Trapped Inside <think> · Part III: Project-Then-Heal · Part IV: Spectral Trojans & Pre-Load Sanitization · Secant Repo · Secant Docs
On November 2, 2026, Rikiya Takehi, Jayden Teoh, Alex Zhang, and Omar Khattab at MIT CSAIL published Sparks of Weight-Space Programming, showing an LLM agent (gpt-6-astra) inspecting Qwen3.5-0.8B, editing 0.016% of its weights without gradients, and lifting its MATH-500 score from 7.9% to 48.1%. Within days, follow-ups showed that turning <think> off on the unedited 0.8B model scored the same (51.5% vs. 51.2%), while fresh agent runs varied widely (12.9%).
We built Secant (documentation and technical paper) and ran 59,440 benchmark evaluations across 17 models (0.8B to 32.8B), plus a 17-checkpoint LoRA-lock sweep reaching 72.7B, to test what actually holds up across model scales, quantized .gguf blocks, LoRA fine-tuning, and native C++ inference kernels. Below are the four essays in the series.
The four essays in this series
Part I: The Illusion of Safe Tensors
SafeTensors and GGUF guarantee that opening a model file cannot execute arbitrary pickle code at the container layer (Boundaries 1 and 2). Once the file is memory-mapped into RAM, however, C++ and CUDA kernels use the stored numbers directly as loop sentinels, divisors, sort keys, and array indices (Boundary 3). Part I walks through four classes of poisoned weights in under 30 lines of C++ each, shows why a Class II float-to-int cast of NaN or out-of-range weights crashes on x86-64 (CVTTSS2SI emitting INT32_MIN) while returning 0 or saturating on ARM64 (FCVTZS, passing upper-only bounds checks with a wrong index) whereas Class III sorting comparators can fail open on both architectures, and demonstrates how secant probe and secant sanitize catch them on disk before load.
Read Part I: The Illusion of Safe Tensors →
Part II: Trapped Inside <think>
Why do small reasoning models get stuck inside <think> loops or falsely refuse defensive crash-triage logs, and why does a weight edit that works on 0.8B fail (0/30) when copied onto 4B? Part II runs a 4-arm controlled test on Qwen3.5-0.8B MATH-500 (enable_thinking=True, enable_thinking=False, targeted B1 edit, and norm-matched random edit), introduces activation-calibrated weight surgery (secant analyze + secant compose) across 17 models, and benchmarks paired C/C++ vulnerability discrimination on ASAN-120 (60 sanitizer-verified bugs paired with 60 patched fixes).
Read Part II: Trapped Inside <think> →
Part III: Project-Then-Heal
Once you apply a surgical weight edit, two everyday workflows can undo it: quantizing the checkpoint to GGUF or fine-tuning it with LoRA. Part III shows how secant quant patch modifies only the touched 34-byte Q8_0 blocks in place on disk (0.2% of an 8.7 GB file touched, while Q4_K superblocks bleed across attention heads), explains why AdamW rotates gradient-projected LoRA updates back into removed directions within 60 steps, and introduces ProjectThenHealLinear to keep edited subspaces locked during fine-tuning.
Read Part III: Project-Then-Heal →
Part IV: Static Spectral Trojan Auditing and Pre-Load Checkpoint Sanitization
How much can you verify about a model’s safety by scanning its weights on disk without running a forward pass? Part IV explains why naive subnormal filters falsely flag 8.99 million benign Q4_K scale headers, how role-aware sanitization scans 186.8 million GGUF blocks across 10 production checkpoints with zero false positives, and where static single-file SVD inspection (secant audit-trojan) detects or misses rank-one spectral backdoors.
Read Part IV: Static Spectral Trojan Auditing and Pre-Load Checkpoint Sanitization →
Interactive walkthrough of the four parts
How a checkpoint moves from disk to C++ kernels, surgical weight edits, LoRA training, and pre-load auditing.
Select Part I, Part II, Part III, or Part IV below to inspect the exact problem each post solves, the measured baseline failure vs. Secant result, and the CLI commands that reproduce it.
SafeTensors and GGUF verify that tensor headers and byte offsets are well-formed (Boundaries 1 and 2). Once the file is memory-mapped (mmap), native C++ kernels use stored floats and integers directly as loop sentinels, divisor scales, sort keys, and array indices. For Class II float-to-int casts without sanitizers, the exact same poisoned NaN weight crashes on x86-64 (CVTTSS2SI -> INT32_MIN) while exiting 0 with a wrong index on ARM64 (FCVTZS -> 0), whereas Class III sorting comparators can fail open on both architectures.
$ secant probe --class all --format safetensors \
--out-dir /tmp/b3-probes --receipt /tmp/probe.json \
--attempt-id kernel-check --num-experts 8
$ secant sanitize --model model.safetensors \
--receipt /tmp/scan.json --attempt-id preload-gate \
--num-experts 8 --dry-run Summary of results across the series
Across the four parts, each study isolates a specific failure mode and pairs it with a control:
| Part | Scope | Baseline / Control | Secant Result |
|---|---|---|---|
| Part I | 212 native C++ runs (Class I..IV, x86-64 & ARM64) | 100% pass container format checks; x86-64 faults while ARM64 exits 0 on Class II NaN casts | 100% of poisoned fixtures caught statically before load by secant sanitize |
| Part II | Qwen3.5-0.8B MATH-500 (n = 100) & Qwen3.5-4B triage (n = 30) | 0.8B 3-seed random edit: 1.0% ± 1.0% final, 3.0% ± 2.6% closed (thinking=False: 48.0%). 4B copied ratio & random: 0/30 closed | 0.8B B1 edit: 64/100 closed, 24.0% final (Holm p <= 8.39e-5 across 3 random seeds). 4B calibrated ramp: 2/30 (0.6x), 5/30 (0.7x), 12/30 (0.8x), 14/30 (0.9x), 21/30 (1.0x), 30/30 (1.5x, 19/30 root cause) |
| Part III | Q8_0 vs. Q4_K surgery & 15-model AdamW LoRA sweep | Q4_K leaves 67% residual; gradient-only LoRA leaks 0.33%..1.67% in 60 AdamW steps | Q8_0 removes 98.5% in place (0.2% of file bytes touched); ProjectThenHealLinear holds writer leakage to ~1e-17 in float64 |
| Part IV | 186.8M GGUF blocks (10 models), 17-cell Trojan grid (187 points) & 46-file atlas | Naive subnormal rule flags 8.99M benign Q4_K scales; automatic scalar Z > 3.5 misses 13/17 cells up to 16%, and in 3 late-layer cells output flips 1..5 pp below single-file g* | 0 false positives across 186.8M blocks (plus Rule S-0 companion-config checks in v0.3.0); human-read Stage-2 vocab projection (E · u_1) surfaces the trigger token in the top 16 in 17/17 cells once g >= g* (4%..16%, `mean |
For the Qwen3.5-0.8B MATH-500 follow-up (n = 100, 4,096 max new tokens, BF16, greedy decoding; full analysis in Part II), our four-arm comparison separated template switches, targeted edits, and random perturbations on the same checkpoint:
| Arm | <think> Mode | </think> Closed | Final Answer | Whole-Response | Mean Tokens |
|---|---|---|---|---|---|
base_thinking_on | enable_thinking=True | 1 / 100 (1.0%) | 1.0% | 12.0% | 4,072 |
base_thinking_off | enable_thinking=False | (prefilled) | 48.0% | 48.0% | 1,899 |
secant_b1_edit | enable_thinking=True | 64 / 100 (64.0%) | 24.0% | 31.0% | 3,598 |
random_norm_matched (3 seeds) | enable_thinking=True | 3.0% ± 2.6% (2, 6, 1) | 1.0% ± 1.0% (0, 2, 1) | 17.7% ± 1.5% | 4,078 |
Seven takeaways in plain English
-
A valid file can still contain dangerous numbers. SafeTensors and GGUF check that headers and byte offsets match, not that the numbers inside are safe for C++ and CUDA code. A single
NaN, zero divisor scale, or negative routing index in a valid checkpoint can trigger architecture-dependent failures (for example, Class II float-to-int casts fault onx86-64viaINT32_MINwhile returning0or saturating onARM64, and Class III sorting comparators can fail open on both ISAs). -
Always test a random weight edit of the same size. When a reasoning model is timing out inside
<think>, almost any nudge that breaks a mild loop will boost its score. OnQwen3-8BGSM8K, a random weight edit raised accuracy by the exact same amount (18% -> 30%) as a targeted edit, whereas on severeQwen3.5-0.8BMATH-500loops three independent random direction seeds scored0.0%,2.0%, and1.0%(1.0% ± 1.0%,3.0% ± 2.6%closed) while the targetedB1edit closed64/100and scored24.0%(Holm-adjustedp <= 8.39e-5across all 3 seeds). -
Measure the layer’s activations before choosing an edit size. A weight multiplier copied from
0.8Bfailed completely (0/30loops closed) onQwen3.5-4Bbecause wider layers have different activation scales. Sizing the edit from reference activations (secant analyze+secant compose) closed21/30loops at the calibrated dose and30/30at1.5x. -
Test security models on patched code, not just buggy code. If a benchmark only contains vulnerable functions, a model that labels everything
VULNERABLEscores 100%. Pairing 60 sanitizer-verified C/C++ bugs with their 60 patched fixes (ASAN-120), plus 30 real upstream C/C++ bugs paired with their 30 exact upstream patches across 16 open-source repositories (ASAN-RealWorld-60/ASAN-180), exposed that small non-reasoning models (SmolLM2-1.7BandLlama-3.1-8B) fail on93%to100%of patched code. OnASAN-120, the1.0xRMS-dosed arm (composed_rms_1p0x) had higher balanced accuracy than its norm-matched random control (random_rms_1p0x) on4/4reasoning models (6wins,1loss,2ties across all9models, exact sign-testp = 0.125; no individual model’s McNemar test survives Holm correction; strict root-cause recall rose from45.0%to55.0%onQwen3-14B,+10.0pp,95%bootstrap CI[0.0, +21.67]pp). -
Block size decides whether quantized edits stay clean. In GGUF files, four 32-weight
Q8_0blocks fit cleanly inside a 128-column attention head (98.5%removal,0.2%of file bytes modified in place). A 256-weightQ4_Ksuperblock spans two heads at once and mixes their scales together. -
Lock LoRA inside the forward pass, not just the gradient. If you only project gradients before AdamW, AdamW’s per-weight step scaling rotates the update back into the removed direction within 60 steps (
0.33%to1.67%leakage). Projecting the LoRA weights inside the forward pass (ProjectThenHealLinear) holds leakage at the edited writer to the floating-point floor (~1e-17infloat64). -
Separate multiplier scales from divisor scales when scanning files. Quantized
Q4_Kmodels naturally contain millions of tiny subnormal multiplier scales that are harmless during dequantization, whereas a zero or subnormal divisor scale causes divide-by-zero overflows. Separating the two letssecant sanitizescan186.8 millionGGUF blocks with zero false alarms.
GitHub Repository (professor-moody/secant) · Full Documentation & Technical Paper · Rust CLI (secant), C ABI, and PyTorch secant.nn.ProjectThenHealLinear