dark-beam-method / index.html
chadstthomas's picture
Try it: sample generations summary
f2b3abb verified
Raw History Blame Contribute Delete
33.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How Dark-Beam Was Made — refusal-direction ablation on a 230B MoE</title>
<style>
:root{
--bg:#0a0e1f; --bg2:#111634; --panel:#141a3d; --ink:#e8e4ff; --dim:#9a94c8;
--purple:#8b6ce6; --teal:#4fd1c5; --gold:#ffd98a; --red:#ff6b7d; --green:#5ee6a0;
--line:rgba(139,108,230,.18);
}
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{background:var(--bg);color:var(--ink);font:16px/1.65 system-ui,-apple-system,"Segoe UI",sans-serif;
background-image:radial-gradient(1200px 500px at 75% -8%,rgba(139,108,230,.16),transparent 60%),
radial-gradient(900px 420px at 8% 108%,rgba(79,209,197,.10),transparent 60%)}
.wrap{max-width:960px;margin:0 auto;padding:0 22px}
header{padding:72px 0 40px;border-bottom:1px solid var(--line)}
h1{font-size:44px;letter-spacing:-.5px;line-height:1.1;
text-shadow:0 0 34px rgba(139,108,230,.55)}
.sub{color:var(--dim);font-size:19px;margin-top:14px;max-width:720px}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-top:34px}
.kpi{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:16px 18px}
.kpi b{display:block;font-size:26px;color:var(--teal)}
.kpi.hot b{color:var(--gold)}
.kpi span{color:var(--dim);font-size:13px}
section{padding:52px 0;border-bottom:1px solid var(--line)}
h2{font-size:29px;margin-bottom:8px;letter-spacing:-.3px}
h2 .no{color:var(--purple);font-size:15px;vertical-align:middle;margin-right:10px;
border:1px solid var(--purple);border-radius:20px;padding:2px 12px}
.lede{color:var(--dim);max-width:760px;margin-bottom:26px}
p{max-width:760px;margin-bottom:16px}
section > h3{font-size:19px;margin:22px 0 8px;color:var(--teal,#4fe6cc)}
code,pre{font:13.5px/1.6 ui-monospace,Menlo,Consolas,monospace}
code{background:rgba(139,108,230,.14);padding:1px 6px;border-radius:6px}
pre{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px;overflow-x:auto;color:#c9c2f2}
.callout{border-left:3px solid var(--purple);background:rgba(139,108,230,.08);border-radius:0 12px 12px 0;
padding:14px 18px;margin:20px 0;max-width:760px}
.callout b{color:var(--purple)}
.callout.red{border-color:var(--red);background:rgba(255,107,125,.07)}
.callout.red b{color:var(--red)}
.callout.green{border-color:var(--green);background:rgba(94,230,160,.06)}
.callout.green b{color:var(--green)}
.chart{background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:18px;margin:26px 0}
.chart h3{font-size:15px;color:var(--dim);font-weight:600;margin-bottom:4px}
.chart p.note{font-size:13px;color:var(--dim);margin:6px 0 0;max-width:none}
svg text{font-family:system-ui;font-size:11px;fill:var(--dim)}
.legend{display:flex;gap:18px;flex-wrap:wrap;margin-top:10px;font-size:13px;color:var(--dim)}
.legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px}
table{width:100%;border-collapse:collapse;font-size:14px;margin:18px 0}
th{color:var(--dim);text-align:left;font-weight:600;border-bottom:1px solid var(--line);padding:8px 10px}
td{border-bottom:1px solid rgba(139,108,230,.10);padding:8px 10px}
td.num{text-align:right;font-variant-numeric:tabular-nums}
.pass{color:var(--green);font-weight:600}.fail{color:var(--red);font-weight:600}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:22px}
@media(max-width:760px){.grid2{grid-template-columns:1fr}h1{font-size:32px}}
footer{padding:40px 0 70px;color:var(--dim);font-size:14px}
.hero{display:block;width:100%;border-radius:18px;border:1px solid var(--line);box-shadow:0 20px 80px rgba(139,108,230,.25);margin-bottom:34px}
nav.toc{position:sticky;top:0;z-index:5;background:rgba(10,14,31,.86);backdrop-filter:blur(10px);border-bottom:1px solid var(--line);
margin:0 -22px;padding:10px 22px;display:flex;gap:6px;overflow-x:auto;white-space:nowrap;font-size:13px}
nav.toc a{color:var(--dim);padding:4px 10px;border-radius:14px}
nav.toc a:hover,nav.toc a.on{color:var(--ink);background:rgba(139,108,230,.18);text-decoration:none}
.js .reveal{opacity:0;transform:translateY(18px);transition:opacity .7s ease,transform .7s ease}
.js .reveal.in{opacity:1;transform:none}
@media (prefers-reduced-motion:reduce){.js .reveal{opacity:1;transform:none;transition:none}}
.fid{display:grid;gap:18px;margin-top:8px}
.fid .row b{font-size:15px}.fid .row span{color:var(--dim);font-size:13px}
.track{height:16px;background:#0d1230;border-radius:9px;overflow:hidden;margin:8px 0 4px}
.fill{height:100%;width:0;border-radius:9px;background:linear-gradient(90deg,#4fd1c5,#5ee6a0);transition:width 1.4s cubic-bezier(.2,.8,.2,1)}
.probe{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px;margin:12px 0}
.probe .q{color:var(--teal);font-weight:600;margin-bottom:6px}.probe .a{color:#cfc9f5;font-size:14.5px}
.probe .meta{color:var(--dim);font-size:12px;margin-top:6px}
a{color:var(--teal);text-decoration:none}a:hover{text-decoration:underline}
.badge{display:inline-block;border:1px solid var(--line);border-radius:8px;padding:3px 10px;
margin:4px 6px 4px 0;font-size:13px;color:var(--dim)}
</style>
</head>
<body>
<script>document.documentElement.classList.add('js')</script>
<div class="wrap">
<header>
<img class="hero" src="banner.png" alt="Dark-Beam M2.7 · 229B total · 10B active · 93 GB">
<h1>How Dark-Beam was made</h1>
<div class="sub">Refusal-direction ablation on MiniMax-M2.7 — a 229B-parameter, 256-expert mixture-of-experts
model — done with measurement instead of assumptions. This is the full record: the failure, the forensics,
the gates, two findings we had not seen written down, and the surgical edit that came out of them.</div>
<div class="kpis">
<div class="kpi hot"><b data-count="82188">82,188</b><span>perplexity after textbook ablation: the failure that started this</span></div>
<div class="kpi"><b data-count="220">220</b><span>massive-activation channels mapped and excluded</span></div>
<div class="kpi"><b>8 / 809</b><span>tensors edited, layers 46–49 only</span></div>
<div class="kpi"><b data-count="97.2" data-dec="1" data-suf="%">97.2%</b><span>same next token as the unedited model (chat, code, math)</span></div>
<div class="kpi"><b>6.171</b><span>final perplexity; unedited: 6.173</span></div>
</div>
<div style="margin-top:22px">
<span class="badge">model: <a href="https://huggingface.co/tablinum/Dark-Beam-M2.7-229B-A10B-GGUF">tablinum/Dark-Beam-M2.7-229B-A10B-GGUF</a></span>
<span class="badge">censored sibling: <a href="https://huggingface.co/tablinum/Lite-Beam-M2.7-229B-A10B-GGUF">Lite-Beam M2.7</a></span>
<span class="badge">family: <a href="https://huggingface.co/collections/tablinum/dark-beam-6b006c375cb8f6c6086a39bf">Dark-Beam collection</a></span>
</div>
</header>
<nav class="toc" aria-label="Sections">
<a href="#s00">Abstract</a><a href="#s01">Failure</a><a href="#s02">Diagnosis</a><a href="#s03">Method</a><a href="#s04">Gate table</a>
<a href="#s05">β is dead</a><a href="#s06">Four layers</a><a href="#s07">Result</a><a href="#s08">Broken reference</a>
<a href="#s09">Try it</a><a href="#s10">Next</a>
</nav>
<section id="s00" class="reveal">
<h2><span class="no">00</span>Abstract</h2>
<p class="lede">Classic refusal-direction ablation — compute a "refusal direction" from contrastive activations,
then project it out of every weight matrix that writes to the residual stream — is reported to work on dense
models. Applied verbatim to MiniMax-M2.7 (229B total / 10B active, 256 experts per layer, top-8 sigmoid+bias
routing), it produced a model with <b>perplexity 82,188</b>. We show why: the published recipe works only with
its full selection protocol intact, raw directions are polluted by massive-activation channels, and partial
projections saturate when re-applied at every downstream writer. We rebuild the method around three measured
interventions — massive-channel exclusion, the full Arditi gate set evaluated by in-forward simulation, and
layer-masked application — and land on an 8-tensor edit at layers 46–49 that removes refusal conditioning while
leaving perplexity within 0.03% of the pristine model. Two of our findings (β-saturation; effect/damage layer
decoupling) we have not seen stated elsewhere.</p>
</section>
<section id="s01" class="reveal">
<h2><span class="no">01</span>The failure that taught us</h2>
<p>The first attempt followed the community recipe faithfully: 128 harmful and 128 harmless prompts, activations
at the last template position, diff-in-means direction, orthogonalized into every attention output, every expert
down-projection and the token embeddings — 125 tensors, patched in place on the 457 GB BF16 checkpoint. Every
mechanical step verified: tensor geometries checked against llama.cpp source, per-tensor orthogonality asserted
at 1.3e-4, file sizes unchanged.</p>
<div class="chart">
<h3>Perplexity, log scale — what one unguarded direction costs</h3>
<div id="chart-ppl"></div>
<p class="note">Wikitext-1024 perplexity through an fp32 harness on the BF16 weights. Pristine 6.173 vs naive-ablated
82,188 — a four-order-of-magnitude collapse with the model otherwise untouched.</p>
</div>
<p>The forensics were unambiguous: geometry correct, math correct, pipeline byte-identical to proven
artifacts. The problem was the <b>direction itself</b> — and four gaps between the community recipe and the
actual published protocol.</p>
</section>
<section id="s02" class="reveal">
<h2><span class="no">02</span>The diagnosis</h2>
<p><b>Gap 1 — the selection gate everyone drops.</b> Arditi et al. select their direction under three constraints
(bypass score, induction check, benign KL &lt; 0.1). The KL constraint is the capability guard: a direction chosen
by separation alone is rich in general-capability content. Measured elsewhere as a 39-point GSM8K drop for raw
diff-in-means steering; measured here as a four-order-of-magnitude perplexity collapse.</p>
<p><b>Gap 2 — massive activations.</b> M2.7 has a small set of channels that run 1,000–100,000× the layer median.
Scanning one forward pass over the calibration corpus, we mapped <b>220 of them</b>: concentrated in layers 5–13
(four to five channels each), tapering to a single channel per layer but never disappearing. Raw diff-in-means
directions are dominated by exactly these channels — and ablating them removes the fixed bias terms the model
depends on.</p>
<div class="chart">
<h3>Massive-activation channels per layer (|x| &gt; 100 and &gt; 1000× layer median, across the calibration pass)</h3>
<div id="chart-massive"></div>
<p class="note">220 channels total across 62 layers. The early-layer cluster (5–13) is where run 1's direction
picked up most of its poison; every candidate direction in run 3 has these dims zeroed.</p>
</div>
<p><b>Gap 3 — norm geometry.</b> Plain projection W − r̂r̂ᵀW shrinks every writer's row norms; bf16 rounding and
quantization compound it across 100+ sites. The fold operator therefore clamps each output row to its original
norm (MPOA-style) after projecting.</p>
<p><b>Gap 4 — no cheap gate.</b> The original pipeline went patch → teacher → importance matrix → quant → eval,
ten hours before any quality number existed. The rebuild inserts a perplexity gate after every stage; run 1 would
have died at minute ten instead of hour ten.</p>
<div class="callout"><b>What was NOT the problem:</b> unpaired contrast sets (Arditi's own protocol is unpaired —
AdvBench vs Alpaca — and worked on 13 dense models), tensor geometry (verified against llama.cpp source), or the
in-place patching mechanics. We tested each hypothesis against evidence before ruling it out.</div>
</section>
<section id="s03" class="reveal">
<h2><span class="no">03</span>The method: simulate, don't build</h2>
<p>Weight-folding is mathematically equivalent to all-layer activation ablation: applying x ← x − (x·r̂)r̂ after
every residual write at layers ≥ ℓ transforms the residual stream identically to orthogonalizing every writer
from layer ℓ down. That identity turns a 2-hour weight rebuild into a ~50-minute forward pass — so the entire
gate search runs as simulation, and only the winning configuration ever touches weights.</p>
<pre>
for each candidate direction r (from capture layer ℓ, position p):
run the forward pass from layer ℓ with x ← x − (x·r)r re-applied
after every residual write (attention out, expert down) at layers ≥ ℓ
bypass = Δ compliance-margin on held-out harmful prompts
induce = Δ compliance-margin on harmless prompts (want ≥ 0: don't worsen over-refusal)
KL = full-vocabulary KL(clean ‖ ablated) on harmless prompts (hard cap 0.1)
PASS ⇔ KL < 0.1 ∧ induce > −0.05 then keep the PASS with the largest bypass</pre>
<p>The harness itself is gated: a 1,024-token wikitext perplexity through the custom fp32 forward must land in
a sane range before any of its numbers are trusted — it read <b>6.173 on the pristine weights</b>, validating both
the harness and the restore in one number.</p>
</section>
<section id="s04" class="reveal">
<h2><span class="no">04</span>The gate table</h2>
<p>Eight capture layers × two template positions, the massive-activation dims (up to 198 of 3,072) zeroed in every
candidate, ten candidates surviving the separation prefilter. Every one was simulated. <b>None passed at full strength</b> —
but the pattern is the map:</p>
<div class="chart">
<h3>The trade-off frontier: benign KL vs bypass gain (dot size = induction effect)</h3>
<div id="chart-frontier"></div>
<p class="note">Every candidate is one simulated fold. The KL 0.1 budget line is Arditi's capability guard.
Layers 30–42 at position −2 are clean but toothless; layers 38–46 at position −1 carry real compliance gains
that overshoot the budget at β = 1. The teal diamond is where the L46 −1 direction lands once it is confined to layers 46–49.</p>
</div>
<p>The clean-but-weak cluster and the strong-but-dirty cluster are <b>different directions, not a tuning
problem</b> — which is the entanglement picture from the MoE literature, confirmed live on this model.</p>
</section>
<section id="s05" class="reveal">
<h2><span class="no">05</span>Finding 1 — β is a dead dial</h2>
<p>The obvious next move after near-misses is sweeping the ablation strength β. We swept it. It barely moved
anything:</p>
<div class="chart">
<h3>Sweeping β on the strongest direction (layer 46, pos −1)</h3>
<div id="chart-beta"></div>
<p class="note">β from 0.6 to 1.0 moves benign KL by 0.021 total. The fold re-applies the projection at every
downstream residual write (~30 of them); partial projections compound — (I − βr̂r̂ᵀ)ᵏ → full removal for any
β ≳ 0.5. <b>Per-site strength is not a knob when the edit spans all downstream sites.</b></p>
</div>
<div class="callout"><b>Finding 1.</b> For all-downstream-site folds, β is saturated by construction. The real
strength dial is <b>which layers carry the edit</b> — which is what led to finding 2. To our knowledge this
saturation behavior is not stated in the abliteration literature; it is the reason layer-range searches (not
β searches) are the meaningful optimization axis.</div>
</section>
<section id="s06" class="reveal">
<h2><span class="no">06</span>Finding 2 — effect and damage live at different depths</h2>
<p>If β can't trade effect against damage, maybe the edit's <b>footprint</b> can. We masked the same direction
to different layer bands (always the layer-46 direction):</p>
<div class="chart">
<h3>Layer-masked folds: bypass gain (bars, left axis) vs benign KL (dots, right axis, budget 0.1)</h3>
<div id="chart-masks"></div>
<p class="note">The full ≥46 band (all 16 layers) overshoots KL. Layers 46–49 alone match its bypass gain (0.419 vs 0.394) at
62% of its KL cost, the strongest mask that stays inside the budget.</p>
</div>
<div class="callout green"><b>Finding 2.</b> The refusal effect and the capability damage of this direction
<b>live at different layer granularities</b>: four layers (46–49) carry the whole band's behavioral effect while the
KL damage spreads across every layer the edit touches. Surgical granularity is a real, measurable degree of
freedom — the fold that ships touches <b>8 tensors out of 809</b>.</div>
</section>
<section id="s07" class="reveal">
<h2><span class="no">07</span>The result</h2>
<p>The shipped edit orthogonalizes the attention output and expert down-projections of layers 46–49 against the
(46, −1) direction — fp32 math, row norms clamped to original, bf16 rounded back, in place on the 457 GB
checkpoint. Then the gates:</p>
<table>
<tr><th>gate</th><th>pristine</th><th>Dark-Beam</th><th>criterion</th><th></th></tr>
<tr><td>wikitext-1024 PPL (fp32 harness on BF16)</td><td class="num">6.173</td><td class="num">6.171</td><td class="num">≤ 12.35 (2×)</td><td class="pass">PASS</td></tr>
<tr><td>tensors changed</td><td class="num">—</td><td class="num">8 / 809</td><td class="num">minimal</td><td class="pass">PASS</td></tr>
<tr><td>simulated bypass / induce / KL (pre-fold)</td><td class="num">—</td><td class="num">+0.42 / +0.21 / 0.086</td><td class="num">all three gates</td><td class="pass">PASS</td></tr>
<tr><td>same top token vs unedited twin, chat/code/math (18 windows)</td><td class="num">reference</td><td class="num">97.17%</td><td class="num">usable, no collapse</td><td class="pass">PASS</td></tr>
<tr><td>same top token vs unedited twin, WikiText (18 windows)</td><td class="num">reference</td><td class="num">93.49%</td><td class="num">usable, no collapse</td><td class="pass">PASS</td></tr>
<tr><td>perplexity ratio, chat/code/math · WikiText</td><td class="num">1</td><td class="num">1.003 · 0.999</td><td class="num">≈ 1</td><td class="pass">PASS</td></tr>
<tr><td>prompt processing, reference rig</td><td class="num">275.6 t/s</td><td class="num">275.3 t/s</td><td class="num">≥ 250 t/s</td><td class="pass">PASS</td></tr>
</table>
<div class="chart">
<h3>How often Dark-Beam picks the same next token as its unedited twin</h3>
<div class="fid">
<div class="row"><b>chat · code · math</b> <span>· mean KLD 0.025 · perplexity 2.327 vs 2.320</span>
<div class="track"><div class="fill" data-w="97.17"></div></div><span>97.17% ± 0.12</span></div>
<div class="row"><b>WikiText</b> <span>· mean KLD 0.042 · perplexity 7.511 vs 7.521</span>
<div class="track"><div class="fill" data-w="93.49"></div></div><span>93.49% ± 0.20</span></div>
</div>
<p class="note">llama-perplexity --kl-divergence, 18 windows of 2,048 tokens each, reference = Lite-Beam IQ3_XXS
(same recipe, no edit), so the numbers isolate the edit itself.</p>
</div>
<div class="callout green"><b>Perplexity 6.171 vs 6.173.</b> The edit is behaviorally real (compliance margins
move) and mathematically invisible (perplexity moves 0.03%). That combination is the entire goal.</div>
</section>
<section id="s08" class="reveal">
<h2><span class="no">08</span>A broken reference, found on the way</h2>
<p>One detour worth recording: our first 18-chunk evaluation crashed with <code>non-finite reference logits</code>
at chunk 2. The reference bases this pipeline had been scoring against since November were <b>themselves
NaN-poisoned from chunk 2 onward</b> — the pristine teacher's activations overflow on this corpus (same
massive-activation channels), and the older llama.cpp build silently tolerated it while the current build refuses.
Every historical number from those bases is effectively a chunk-1 number. The shipped evaluation regenerates the
reference from the pristine quant itself, which computes finite logits across all chunks — one more thing the
failure atlas now knows.</p>
</section>
<section id="s09" class="reveal">
<h2><span class="no">09</span>Try it</h2>
<table>
<tr><th>artifact</th><th>what it is</th></tr>
<tr><td><a href="https://huggingface.co/tablinum/Dark-Beam-M2.7-229B-A10B-GGUF">Dark-Beam-M2.7-229B-A10B-GGUF</a></td><td>the IQ3_XXS quant of the edited BF16: 93 GB, one file</td></tr>
<tr><td><a href="https://huggingface.co/tablinum/Lite-Beam-M2.7-229B-A10B-GGUF">Lite-Beam-M2.7-229B-A10B-GGUF</a></td><td>the pristine sibling, same recipe, no edit</td></tr>
<tr><td><a href="https://huggingface.co/collections/tablinum/dark-beam-6b006c375cb8f6c6086a39bf">Dark-Beam collection</a></td><td>the family, as it grows</td></tr>
</table>
<pre>hf download tablinum/Dark-Beam-M2.7-229B-A10B-GGUF --local-dir dark-beam-m2.7
llama-server -m dark-beam-m2.7/Dark-Beam-M2.7-229B-A10B-IQ3_XXS.gguf \
-ngl 99 --n-cpu-moe 99 -fa on -c 32768 --jinja --temp 1.0 --top-p 0.95 --top-k 40</pre>
<p>About 100 GB of RAM + VRAM combined; experts stay in system RAM, attention on the GPU. It is a thinking model, so give
it a generous <code>max_tokens</code>.</p>
<h3>Sample generations</h3>
<p>Ten everyday dual-use questions (opening your own lock, buffer overflows, soap from animal fat, sandboxed malware analysis,
1800s black-powder mining, authorized social-engineering tests, lock sport, money-laundering forensics, outbreak modelling,
ransomware detection), one run each at temperature 1.0, seed 7, 4,000-token budget. <b>All 10 got a full, on-topic answer</b>;
none refused. Median about 1,540 tokens including reasoning; one used the full budget and still reached its summary.
These are questions a good assistant answers anyway, and the unedited model was not run on them here, so this is a
usability check, not a measure of the edit. Full text: <a href="https://huggingface.co/tablinum/Dark-Beam-M2.7-229B-A10B-GGUF/blob/main/probes.json">probes.json</a>.</p>
<p>License unchanged (MiniMax M2.7 non-commercial). If you deploy this:
the perplexity gates bound capability drift on the corpora we measured — they do not measure your task. Run your
own evals.</p>
</section>
<section id="s10" class="reveal">
<h2><span class="no">10</span>What we would do differently, and next</h2>
<p><b>Next iteration ideas, in order of expected value:</b> multi-direction cones from causally independent
sites (the literature says single directions under-cover refusal); expert-aware edits — at this scale, attention-only
edits remove 3.9% of refusal signal and expert-only 14.8%, joint 77.6%; layer-mask fine-search between 46–49
(we tested whole bands, not individual layer dropouts). <b>What we would tell anyone starting this:</b> gate
everything, simulate instead of building, and treat the first destroyed model as data, not a defeat — every
number in this write-up came from that wreckage.</p>
</section>
<footer>
Built by Tablinum · model: <a href="https://huggingface.co/tablinum/Dark-Beam-M2.7-229B-A10B-GGUF">Dark-Beam-M2.7-229B-A10B-GGUF</a> ·
censored sibling: <a href="https://huggingface.co/tablinum/Lite-Beam-M2.7-229B-A10B-GGUF">Lite-Beam</a> ·
base: <a href="https://huggingface.co/MiniMaxAI/MiniMax-M2.7">MiniMaxAI/MiniMax-M2.7</a> (non-commercial license, unchanged).
Key references: Arditi et al. 2024 (arXiv:2406.11717) · Wollschläger et al. 2025 (arXiv:2502.17420) · Sun et al. 2024 massive activations
(arXiv:2402.17762) · Marbut et al. 2026 expert-aware refusal steering (arXiv:2606.04160) · frontier-scale MoE ablation (arXiv:2609.09793).
Dark-Beam is a measurable modification of a base model; the operator is responsible for its use.
</footer>
</div>
<script>
// ---------- data ----------
const MASSIVE = [[4,1],[5,5],[6,5],[7,5],[8,5],[9,4],[10,4],[11,4],[12,4],[13,3],[14,3],[15,3],[16,3],[17,3],[18,3],[19,3],[20,3],[21,3],[22,3],[23,3],[24,3],[25,3],[26,2],[27,2],[28,1],[29,1],[30,1],[31,1],[32,1],[33,1],[34,1],[35,1],[36,1],[37,1],[38,1],[39,1],[40,1],[41,1],[42,1],[44,1],[45,1],[46,1],[47,1],[48,1],[49,1],[50,1],[51,1],[52,1],[53,1],[54,1],[55,1],[56,1],[61,1]];
const GATES = [
{l:46,p:-2,c:"classic",bypass:0.146,ind:-0.086,kl:0.048},
{l:38,p:-2,c:"classic",bypass:0.216,ind:-0.049,kl:0.041},
{l:42,p:-2,c:"classic",bypass:0.210,ind:-0.051,kl:0.044},
{l:34,p:-1,c:"classic",bypass:0.225,ind: 0.314,kl:0.159},
{l:34,p:-2,c:"classic",bypass:0.127,ind: 0.004,kl:0.037},
{l:38,p:-1,c:"classic",bypass:0.409,ind:-0.019,kl:0.117},
{l:46,p:-1,c:"classic",bypass:0.394,ind: 0.421,kl:0.139},
{l:42,p:-1,c:"classic",bypass:0.234,ind: 1.291,kl:0.302},
{l:30,p:-1,c:"classic",bypass:0.098,ind: 0.960,kl:0.204},
{l:30,p:-2,c:"classic",bypass:0.030,ind:-0.006,kl:0.027},
];
const BETA = [[0.6,0.118,0.404],[0.75,0.133,0.400],[0.85,0.135,0.394],[1.0,0.139,0.394]];
const MASKS = [
{m:"layers 46–53",bypass:0.428,kl:0.104,pass:false,n:8},
{m:"layers 46–49",bypass:0.419,kl:0.086,pass:true, n:4},
{m:"layers 54–61",bypass:0.193,kl:0.087,pass:false,n:8},
{m:"layers 50–57",bypass:0.314,kl:0.099,pass:true, n:8},
{m:"full ≥46 band",bypass:0.394,kl:0.139,pass:false,n:16},
];
const PPLS = [["pristine BF16",6.173],["Dark-Beam (this build)",6.171],["naive ablation (run 1)",82188]];
// ---------- helpers ----------
function svg(el, w, h, inner){
document.getElementById(el).innerHTML =
`<svg viewBox="0 0 ${w} ${h}" style="width:100%;height:auto;display:block">${inner}</svg>`;
}
const esc = s => s;
// ---------- chart: ppl log bars ----------
(function(){
const w=860,h=280,pad=60;
const max=100000, min=5;
const ly = v => Math.log10(v);
const y = v => h-pad - (ly(v)-ly(min))/(ly(max)-ly(min)) * (h-2*pad);
let s = "";
for(let e=1;e<=5;e++){ const yy=y(Math.pow(10,e)); s+=`<line x1="${pad}" x2="${w-pad}" y1="${yy}" y2="${yy}" stroke="rgba(139,108,230,.15)"/><text x="${pad-8}" y="${yy+4}" text-anchor="end">1e${e}</text>`; }
const bars=[[30,6.173,"pristine","#4fd1c5"],[w/2-40,6.171,"Dark-Beam","#5ee6a0"],[w-pad-190,82188,"naive ablation","#ff6b7d"]];
const bw=150;
bars.forEach(([x,v,l,c])=>{
const yy=y(v);
s+=`<rect x="${x}" y="${yy}" width="${bw}" height="${h-pad-yy}" fill="${c}" opacity=".75" rx="4"/>`;
s+=`<text x="${x+bw/2}" y="${yy-8}" text-anchor="middle" fill="#e8e4ff">${v.toLocaleString()}</text>`;
s+=`<text x="${x+bw/2}" y="${h-pad+18}" text-anchor="middle">${l}</text>`;
});
svg("chart-ppl",w,h,s+`<line x1="${pad}" x2="${w-pad}" y1="${h-pad}" y2="${h-pad}" stroke="var(--dim)"/>`);
})();
// ---------- chart: massive channels ----------
(function(){
const w=860,h=300,pad=50;
const bw=(w-2*pad)/62;
let s="";
for(let l=1;l<=62;l++){
const e=MASSIVE.find(d=>d[0]===l); const c=e?e[1]:0;
const bh=c/5*(h-2*pad);
const col=c>=4?"#ff6b7d":c>=3?"#ffd98a":c>=2?"#8b6ce6":"rgba(139,108,230,.4)";
s+=`<rect x="${pad+(l-1)*bw}" y="${h-pad-bh}" width="${bw-3}" height="${Math.max(bh,2)}" fill="${col}" rx="2"/>`;
if(l%10===0||l===1) s+=`<text x="${pad+(l-1)*bw+bw/2}" y="${h-pad+16}" text-anchor="middle">${l}</text>`;
}
s+=`<text x="${pad}" y="24" fill="#ff6b7d">early-layer cluster: 4–5 channels/layer — the pollution that killed run 1</text>`;
svg("chart-massive",w,h,s+`<line x1="${pad}" x2="${w-pad}" y1="${h-pad}" y2="${h-pad}" stroke="var(--dim)"/><text x="${w-pad}" y="${h-pad+16}" text-anchor="end">layer</text>`);
})();
// ---------- chart: frontier scatter ----------
(function(){
const w=860,h=420,pad=62;
const xmax=0.32,ymax=0.45;
const X=v=>pad+v/xmax*(w-pad-40); const Y=v=>h-pad-v/ymax*(h-2*pad);
let s="";
[0.1,0.2,0.3,0.4].forEach(v=>{ s+=`<line x1="${pad}" x2="${w-30}" y1="${Y(v)}" y2="${Y(v)}" stroke="rgba(139,108,230,.15)" stroke-dasharray="4 4"/><text x="${pad-8}" y="${Y(v)+4}" text-anchor="end">${v.toFixed(1)}</text>`; });
[0.05,0.15,0.2,0.25,0.3].forEach(v=>{ s+=`<text x="${X(v)}" y="${h-pad+18}" text-anchor="middle">${v}</text>`; });
s+=`<rect x="${X(0.1)}" y="${pad-20}" width="${w-30-X(0.1)}" height="${h-pad-(pad-20)}" fill="rgba(255,107,125,.05)"/>`;
s+=`<line x1="${X(0.1)}" x2="${X(0.1)}" y1="${pad-20}" y2="${h-pad}" stroke="#ff6b7d" stroke-width="1.5"/><text x="${X(0.1)+6}" y="${pad-6}" fill="#ff6b7d">KL budget 0.1 → over budget</text>`;
s+=`<text x="${X(0.1)-6}" y="${pad-6}" text-anchor="end" fill="#5ee6a0">← inside budget</text>`;
s+=`<line x1="${pad}" x2="${w-30}" y1="${h-pad}" y2="${h-pad}" stroke="var(--dim)"/><line x1="${pad}" x2="${pad}" y1="${pad-20}" y2="${h-pad}" stroke="var(--dim)"/>`;
const shipped={kl:0.086,bypass:0.419};
GATES.forEach(g=>{
const ok=g.kl<0.1;
const x=X(g.kl),y=Y(g.bypass),rad=5+Math.min(Math.abs(g.ind)*6,12);
s+=`<circle cx="${x}" cy="${y}" r="${rad}" fill="${ok?'#5ee6a0':'#8b6ce6'}" opacity=".75" stroke="#0a0e1f"/>`;
const dy=(g.l===38&&g.p===-2)?-10:(g.l===42&&g.p===-2)?12:4;
s+=`<text x="${x+rad+5}" y="${y+dy}" fill="#e8e4ff">L${g.l} ${g.p===-1?"−1":"−2"}</text>`;
});
s+=`<path d="M${X(0.139)},${Y(0.394)} L${X(shipped.kl)+10},${Y(shipped.bypass)+4}" stroke="#4fd1c5" stroke-width="1.5" stroke-dasharray="5 4" fill="none"/>`;
s+=`<polygon points="${X(shipped.kl)},${Y(shipped.bypass)-11} ${X(shipped.kl)+11},${Y(shipped.bypass)} ${X(shipped.kl)},${Y(shipped.bypass)+11} ${X(shipped.kl)-11},${Y(shipped.bypass)}" fill="#4fd1c5"/>`;
s+=`<text x="${X(shipped.kl)-16}" y="${Y(shipped.bypass)-14}" text-anchor="end" fill="#4fd1c5">shipped: L46 −1 masked to layers 46–49</text>`;
s+=`<text x="${(pad+w-30)/2}" y="${h-14}" text-anchor="middle">benign KL (capability drift) →</text>`;
s+=`<text x="${pad-40}" y="${(h-pad)/2}" text-anchor="middle" transform="rotate(-90 ${pad-40} ${(h-pad)/2})">bypass gain →</text>`;
svg("chart-frontier",w,h,s);
})();
// ---------- chart: beta saturation ----------
(function(){
const w=860,h=340,pad=62;
const X=v=>pad+(v-0.55)/(1.05-0.55)*(w-pad-30);
const Ykl=v=>h-pad-v/0.18*(h-2*pad);
const Ybp=v=>h-pad-v/0.5*(h-2*pad)*0.5;
let s="";
[0.05,0.1,0.15].forEach(v=>{s+=`<line x1="${pad}" x2="${w-pad}" y1="${Ykl(v)}" y2="${Ykl(v)}" stroke="rgba(139,108,230,.2)"/><text x="${pad-8}" y="${Ykl(v)+4}" text-anchor="end">${v}</text>`;});
s+=`<line x1="${pad}" x2="${w-pad}" y1="${Ykl(0.1)}" y2="${Ykl(0.1)}" stroke="#ff6b7d" stroke-width="1.5"/><text x="${w-pad-4}" y="${Ykl(0.1)-6}" text-anchor="end" fill="#ff6b7d">KL budget</text>`;
let pth="";BETA.forEach((d,i)=>{pth+=(i?"L":"M")+X(d[0])+","+Ykl(d[1])});
s+=`<path d="${pth}" stroke="#8b6ce6" stroke-width="2.5" fill="none"/>`;
BETA.forEach(d=>{s+=`<circle cx="${X(d[0])}" cy="${Ykl(d[1])}" r="5" fill="#8b6ce6"/><text x="${X(d[0])+8}" y="${Ykl(d[1])+4}" fill="#e8e4ff">β=${d[0]} · KL ${d[1]}</text>`;
s+=`<circle cx="${X(d[0])}" cy="${Ybp(d[2])}" r="4" fill="#4fd1c5"/>`;});
s+=`<text x="${(pad+w)/2}" y="${h-14}" text-anchor="middle">β → &nbsp;&nbsp;(teal dots: bypass gain — flat the whole way)</text>`;
svg("chart-beta",w,h,s);
})();
// ---------- chart: layer masks ----------
(function(){
const w=860,h=240,pad=62;
const n=MASKS.length, bw=(w-2*pad)/n-24;
let s="";
[0.05,0.1,0.15].forEach(v=>{s+=`<line x1="${pad}" x2="${w-pad}" y1="${170-v/0.18*140}" y2="${170-v/0.18*140}" stroke="rgba(139,108,230,.15)"/>`;});
s+=`<line x1="${pad}" x2="${w-pad}" y1="${170-0.1/0.18*140}" y2="${170-0.1/0.18*140}" stroke="#ff6b7d" stroke-width="1.5"/><text x="${w-pad-4}" y="${170-0.1/0.18*140-6}" text-anchor="end" fill="#ff6b7d">KL budget 0.1</text>`;
MASKS.forEach((m,i)=>{
const x=pad+i*((w-2*pad)/n)+12;
const bh=m.bypass/0.5*150;
s+=`<rect x="${x}" y="${200-bh}" width="46" height="${bh}" fill="${m.pass?'#5ee6a0':'#8b6ce6'}" opacity=".85" rx="3"/>`;
s+=`<text x="${x+23}" y="${200-bh-7}" text-anchor="middle" fill="#e8e4ff">${m.bypass}</text>`;
const ky=170-m.kl/0.18*140;
s+=`<circle cx="${x+60}" cy="${ky}" r="6" fill="${m.kl<0.1?'#5ee6a0':'#ff6b7d'}"/><text x="${x+72}" y="${ky+4}">KL ${m.kl}</text>`;
s+=`<text x="${x+40}" y="${200+18}" text-anchor="middle">${m.m}</text>`;
s+=`<text x="${x+40}" y="${182}" text-anchor="middle" fill="${m.pass?'#5ee6a0':'#ff6b7d'}">${m.pass?'PASS':'fail'}</text>`;
});
svg("chart-masks",w,h,s+`<line x1="${pad}" x2="${w-pad}" y1="200" y2="200" stroke="var(--dim)"/>`);
})();
// ---------- interactions ----------
(function(){
const io=new IntersectionObserver(es=>es.forEach(e=>{ if(!e.isIntersecting) return; e.target.classList.add('in');
e.target.querySelectorAll('.fill').forEach(f=>f.style.width=f.dataset.w+'%'); io.unobserve(e.target); }),{threshold:.12});
document.querySelectorAll('.reveal').forEach(el=>io.observe(el));
const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
document.querySelectorAll('[data-count]').forEach(el=>{
const to=+el.dataset.count, dec=+(el.dataset.dec||0), suf=el.dataset.suf||''; if(reduce) return;
const t0=performance.now(), dur=1600;
(function tick(t){ const k=Math.min(1,(t-t0)/dur), v=to*(1-Math.pow(1-k,3));
el.textContent=v.toLocaleString(undefined,{minimumFractionDigits:dec,maximumFractionDigits:dec})+suf;
if(k<1) requestAnimationFrame(tick); })(t0);
});
const links=[...document.querySelectorAll('nav.toc a')];
const so=new IntersectionObserver(es=>es.forEach(e=>{ if(e.isIntersecting){ links.forEach(a=>a.classList.toggle('on',a.getAttribute('href')==='#'+e.target.id)); }}),{rootMargin:'-45% 0px -50% 0px'});
document.querySelectorAll('section[id]').forEach(s=>so.observe(s));
})();
</script>
</body>
</html>