single_pickplace / training_dashboard.html
simpk's picture
Update runbook and tooling
84af0a7 verified
Raw History Blame Contribute Delete
41.6 kB
<title>Pickplace Run v1</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
:root{
color-scheme: light;
--ground:#f6f7f9; --card:#ffffff; --ink:#0f141b; --ink-2:#59637a; --ink-3:#8b93a5;
--rule:#e3e7ee; --rule-soft:#eef1f6; --grid:#e8ebf1;
--s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --good:#0ca30c;
--track:#cde2fb; --shadow:0 1px 2px rgba(15,20,27,.05),0 1px 12px rgba(15,20,27,.04);
}
@media (prefers-color-scheme: dark){
:root:not([data-theme="light"]){
color-scheme: dark;
--ground:#0e1116; --card:#14181e; --ink:#f2f4f8; --ink-2:#98a2b8; --ink-3:#6b7488;
--rule:#232936; --rule-soft:#1b212a; --grid:#222835;
--s1:#3987e5; --s2:#d95926; --s3:#199e70; --good:#0ca30c;
--track:#16304f; --shadow:none;
}
}
:root[data-theme="dark"]{
color-scheme: dark;
--ground:#0e1116; --card:#14181e; --ink:#f2f4f8; --ink-2:#98a2b8; --ink-3:#6b7488;
--rule:#232936; --rule-soft:#1b212a; --grid:#222835;
--s1:#3987e5; --s2:#d95926; --s3:#199e70; --good:#0ca30c;
--track:#16304f; --shadow:none;
}
*{box-sizing:border-box}
body{
margin:0; background:var(--ground); color:var(--ink);
font-family:ui-sans-serif,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
font-size:15px; line-height:1.55; -webkit-font-smoothing:antialiased;
}
.mono{font-family:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
font-variant-numeric:tabular-nums}
.wrap{max-width:1080px;margin:0 auto;padding:32px 24px 72px;display:flex;flex-direction:column;gap:22px}
.lbl{font-family:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
font-size:10px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-3);font-weight:600}
header{display:flex;flex-direction:column;gap:10px;padding-bottom:4px}
.runline{display:flex;flex-wrap:wrap;align-items:baseline;gap:10px 14px}
h1{margin:0;font-size:20px;font-weight:650;letter-spacing:-.01em;text-wrap:balance}
.pill{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--rule);
border-radius:999px;padding:2px 9px 2px 7px;font-size:11px;color:var(--ink-2);background:var(--card)}
.dot{width:6px;height:6px;border-radius:50%;background:var(--good);flex:none}
@media (prefers-reduced-motion:no-preference){
.dot{animation:p 2.4s ease-in-out infinite}
@keyframes p{0%,100%{opacity:1}50%{opacity:.35}}
}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{border:1px solid var(--rule);border-radius:5px;padding:2px 7px;font-size:11px;color:var(--ink-2);background:var(--card)}
.chip b{color:var(--ink);font-weight:600}
.card{background:var(--card);border:1px solid var(--rule);border-radius:10px;box-shadow:var(--shadow)}
.pad{padding:18px 20px}
/* step rail */
.rail-head{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap;margin-bottom:14px}
.rail-now{font-size:30px;font-weight:650;letter-spacing:-.02em;line-height:1}
.rail-now span{font-size:15px;color:var(--ink-3);font-weight:500}
.rail{position:relative;height:10px;border-radius:5px;background:var(--track);overflow:visible}
.rail-fill{position:absolute;inset:0 auto 0 0;border-radius:5px;background:var(--s1)}
.tick{position:absolute;top:-5px;width:2px;height:20px;background:var(--ink);border-radius:1px;
outline:2px solid var(--card)}
.tick.floor{background:var(--ink-3);height:16px;top:-3px}
.rail-axis{position:relative;height:34px;margin-top:8px}
.rail-axis i{position:absolute;transform:translateX(-50%);white-space:nowrap;font-size:10px;color:var(--ink-3);
font-family:ui-monospace,Menlo,monospace}
.rail-axis i.k{color:var(--ink-2);font-weight:600}
.rail-axis i em{display:block;font-style:normal;color:var(--ink-3);font-weight:400;font-size:9px;letter-spacing:.04em}
.rail-key{display:flex;flex-wrap:wrap;gap:6px 20px;font-size:11px;color:var(--ink-3);margin-top:2px}
.rail-key span{display:inline-flex;align-items:center;gap:6px}
.rail-key .sw{width:2px;height:11px;border-radius:1px;background:var(--ink-3);opacity:.5}
.rail-key .sw.kept{background:var(--s1);opacity:1}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(148px,1fr));gap:1px;background:var(--rule);
border:1px solid var(--rule);border-radius:10px;overflow:hidden}
.kpi{background:var(--card);padding:14px 16px;display:flex;flex-direction:column;gap:5px}
.kpi .v{font-size:21px;font-weight:650;letter-spacing:-.01em;line-height:1.1}
.kpi .s{font-size:11px;color:var(--ink-3)}
.kpi .v small{font-size:12px;color:var(--ink-3);font-weight:500;letter-spacing:0}
.chart-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap;margin-bottom:2px}
.chart-head h2{margin:0;font-size:14px;font-weight:650;letter-spacing:-.005em}
.chart-head p{margin:3px 0 0;font-size:12px;color:var(--ink-2);max-width:62ch}
.keyline{display:inline-block;width:14px;height:2px;border-radius:1px;vertical-align:3px;margin-right:6px}
figure{margin:0}
.plot{width:100%;display:block;touch-action:none}
.plot:focus-visible{outline:2px solid var(--s1);outline-offset:3px;border-radius:4px}
.pair{display:grid;grid-template-columns:1fr 1fr;gap:22px}
@media (max-width:760px){.pair{grid-template-columns:1fr}}
.tip{position:fixed;z-index:9;pointer-events:none;opacity:0;transition:opacity .09s;
background:var(--card);border:1px solid var(--rule);border-radius:7px;padding:8px 10px;
box-shadow:0 4px 16px rgba(15,20,27,.13);min-width:118px}
.tip .tstep{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);font-weight:600;margin-bottom:5px}
.tip .trow{display:flex;align-items:baseline;justify-content:space-between;gap:12px;font-size:12px}
.tip .trow b{font-size:13px;font-weight:650}
.tip .trow span{color:var(--ink-2)}
details{border-top:1px solid var(--rule);padding-top:16px}
summary{cursor:pointer;font-size:13px;font-weight:600;color:var(--ink-2);width:fit-content}
summary:focus-visible{outline:2px solid var(--s1);outline-offset:3px;border-radius:3px}
.scroll{overflow-x:auto;margin-top:14px;border:1px solid var(--rule);border-radius:8px}
table{border-collapse:collapse;width:100%;font-size:12px}
th,td{padding:7px 12px;text-align:right;white-space:nowrap;border-bottom:1px solid var(--rule-soft)}
th{position:sticky;top:0;background:var(--card);font-size:10px;letter-spacing:.07em;text-transform:uppercase;
color:var(--ink-3);font-weight:600;border-bottom:1px solid var(--rule)}
th:first-child,td:first-child{text-align:left}
tbody tr:last-child td{border-bottom:0}
td.ck{color:var(--ink-2)}
.notes{display:flex;flex-direction:column;gap:12px}
.note{display:grid;grid-template-columns:auto 1fr;gap:12px;align-items:start;font-size:13px;color:var(--ink-2)}
.note b{color:var(--ink);font-weight:600}
.note .n{font-family:ui-monospace,Menlo,monospace;font-size:10px;color:var(--ink-3);
border:1px solid var(--rule);border-radius:4px;padding:1px 5px;line-height:1.5;margin-top:2px}
.note code{font-family:ui-monospace,Menlo,monospace;font-size:12px;background:var(--rule-soft);
padding:1px 4px;border-radius:3px;color:var(--ink)}
footer{font-size:11px;color:var(--ink-3);border-top:1px solid var(--rule);padding-top:14px}
</style>
<div class="wrap">
<header>
<div class="runline">
<h1>pickplace_full_v1</h1>
<span class="pill"><span class="dot"></span><span class="mono" id="pillTxt">running</span></span>
</div>
<div class="chips mono">
<span class="chip">pi0.5 <b>full fine-tune</b></span>
<span class="chip">batch <b>32</b></span>
<span class="chip">lr <b>5e-5</b></span>
<span class="chip">ema <b>0.999</b></span>
<span class="chip">horizon <b>50</b></span>
<span class="chip">A100 80GB <b id="chipRate"></b></span>
</div>
</header>
<section class="card pad">
<div class="rail-head">
<div>
<div class="lbl" style="margin-bottom:7px">Progress</div>
<div class="rail-now mono"><span id="railPct"></span></div>
</div>
<div style="text-align:right">
<div class="lbl" style="margin-bottom:7px">Step</div>
<div class="rail-now mono" id="railStep"></div>
</div>
</div>
<div class="rail" id="rail">
<div class="rail-fill" id="railFill"></div>
</div>
<div class="rail-axis" id="railAxis"></div>
<div class="rail-key mono" id="railKey"></div>
</section>
<div class="kpis" id="kpis"></div>
<section class="card pad">
<div class="chart-head">
<div>
<h2><span class="keyline" style="background:var(--s1)"></span>Flow-matching loss</h2>
<p>Log scale — the value spans 101&times;. One loss is all pi0.5 reports; the vision-language
backbone is trained by gradient flow from this same MSE.</p>
</div>
<div style="text-align:right" class="mono">
<div class="lbl">latest</div>
<div style="font-size:17px;font-weight:650" id="lossNow"></div>
</div>
</div>
<figure><svg class="plot" id="cLoss" height="290" tabindex="0" role="img"
aria-label="Flow-matching loss against training step, log scale, falling from 1.03 to 0.011 and flattening"></svg></figure>
</section>
<div class="pair">
<section class="card pad">
<div class="chart-head"><div>
<h2><span class="keyline" style="background:var(--s2)"></span>Gradient norm</h2>
<p>Log scale. Bounded and settling is healthy; a sustained climb is not.</p>
</div></div>
<figure><svg class="plot" id="cGrad" height="200" tabindex="0" role="img"
aria-label="Gradient norm against training step, log scale, falling from 4.38 to 0.066"></svg></figure>
</section>
<section class="card pad">
<div class="chart-head"><div>
<h2><span class="keyline" style="background:var(--s3)"></span>Parameter norm</h2>
<p>Linear, narrow band. Rising means the weights are actually moving.</p>
</div></div>
<figure><svg class="plot" id="cParam" height="200" tabindex="0" role="img"
aria-label="Parameter norm against training step, rising from 1802.4 to 1835.7"></svg></figure>
</section>
</div>
<section class="card pad">
<details>
<summary>Table view &mdash; every logged point</summary>
<div class="scroll"><table class="mono">
<thead><tr><th>Step</th><th>Epochs</th><th>Loss</th><th>Grad norm</th><th>Param norm</th><th>Checkpoint</th></tr></thead>
<tbody id="tbody"></tbody>
</table></div>
</details>
</section>
<section class="card pad notes">
<div class="lbl">Reading this</div>
<div class="note"><span class="n">1</span><div><b>The loss log lags the run.</b>
Telemetry stops at step <span class="mono" id="nLogged"></span> while the run is at
<span class="mono" id="nCur"></span> &mdash; Python block-buffers stdout when it is piped, so
<code>tee</code> receives the lines late. Add <code>PYTHONUNBUFFERED=1</code> to see it live.</div></div>
<div class="note"><span class="n">2</span><div><b>The absolute value reads low by construction.</b>
11 of the 32 action dimensions are constants &mdash; 7 left-hand joints commanded to exactly 0,
plus 4 padding dims &mdash; so roughly a third of the mean squared error is over channels with
nothing to predict. Compare the curve to itself, never to another dataset.</div></div>
<div class="note"><span class="n">3</span><div><b>The curve has stopped discriminating.</b>
Over the last 2,000 logged steps the mean loss moved
<span class="mono" id="nFlat"></span> &mdash; smaller than the step-to-step noise. Every
checkpoint from here on is indistinguishable <em>by loss</em>, which is not the same as
equivalent on the robot.</div></div>
<div class="note"><span class="n">4</span><div><b>So pick by rollout, not by this page.</b>
Two checkpoints with equal loss can differ by tens of points of success rate, and nothing
plotted here measures grasp success. Choosing among the
<span class="mono" id="nKeptNote"></span> surviving checkpoints needs real-robot trials from a
fixed object-placement grid.</div></div>
</section>
<footer class="mono">Parsed from train_v1.log &middot; <span id="nPts"></span> logged points
&middot; the pruner keeps step 7,500 and later; 10 survive to the end</footer>
</div>
<div class="tip" id="tip" role="status" aria-live="polite"></div>
<script>
const D = {"steps": [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500, 1550, 1600, 1650, 1700, 1750, 1800, 1850, 1900, 1950, 2000, 2050, 2100, 2150, 2200, 2250, 2300, 2350, 2400, 2450, 2500, 2550, 2600, 2650, 2700, 2750, 2800, 2850, 2900, 2950, 3000, 3050, 3100, 3150, 3200, 3250, 3300, 3350, 3400, 3450, 3500, 3550, 3600, 3650, 3700, 3750, 3800, 3850, 3900, 3950, 4000, 4050, 4100, 4150, 4200, 4250, 4300, 4350, 4400, 4450, 4500, 4550, 4600, 4650, 4700, 4750, 4800, 4850, 4900, 4950, 5000, 5050, 5100, 5150, 5200, 5250, 5300, 5350, 5400, 5450, 5500, 5550, 5600, 5650, 5700, 5750, 5800, 5850, 5900, 5950, 6000, 6050, 6100, 6150, 6200, 6250, 6300, 6350, 6400, 6450, 6500, 6550, 6600, 6650, 6700, 6750, 6800, 6850, 6900, 6950, 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500, 7550, 7600, 7650, 7700, 7750, 7800, 7850, 7900, 7950, 8000, 8050, 8100, 8150, 8200, 8250, 8300, 8350, 8400, 8450, 8500, 8550, 8600, 8650, 8700, 8750, 8800, 8850, 8900, 8950, 9000, 9050, 9100, 9150, 9200, 9250, 9300, 9350, 9400, 9450, 9500, 9550, 9600, 9650, 9700, 9750, 9800, 9850, 9900, 9950, 10000, 10050, 10100, 10150, 10200, 10250, 10300, 10350, 10400, 10450, 10500, 10550, 10600, 10650, 10700, 10750, 10800, 10850, 10900, 10950, 11000, 11050, 11100, 11150, 11200, 11250, 11300, 11350, 11400, 11450, 11500, 11550, 11600, 11650, 11700, 11750, 11800, 11850, 11900, 11950, 12000, 12050, 12100, 12150, 12200, 12250, 12300, 12350, 12400, 12450, 12500, 12550, 12600, 12650, 12700, 12750, 12800, 12850, 12900, 12950, 13000, 13050, 13100, 13150, 13200, 13250, 13300, 13350, 13400, 13450, 13500, 13550, 13600, 13650, 13700, 13750, 13800, 13850, 13900, 13950, 14000, 14050, 14100, 14150, 14200, 14250, 14300, 14350, 14400, 14450, 14500, 14550, 14600, 14650, 14700, 14750, 14800, 14850, 14900, 14950, 15000, 15050, 15100, 15150, 15200, 15250, 15300, 15350, 15400, 15450, 15500, 15550, 15600, 15650, 15700, 15750, 15800, 15850, 15900, 15950, 16000, 16050, 16100, 16150, 16200, 16250, 16300, 16350, 16400, 16450, 16500, 16550, 16600, 16650, 16700, 16750, 16800, 16850, 16900, 16950, 17000, 17050, 17100, 17150, 17200, 17250, 17300, 17350, 17400, 17450, 17500, 17550, 17600, 17650, 17700, 17750, 17800, 17850, 17900, 17950, 18000, 18050, 18100, 18150, 18200, 18250, 18300, 18350, 18400, 18450, 18500, 18550, 18600, 18650, 18700, 18750, 18800, 18850, 18900, 18950, 19000, 19050, 19100, 19150, 19200, 19250, 19300, 19350, 19400, 19450, 19500, 19550, 19600, 19650, 19700, 19750, 19800, 19850, 19900, 19950, 20000, 20050, 20100, 20150, 20200, 20250, 20300, 20350, 20400, 20450, 20500, 20550, 20600, 20650, 20700, 20750, 20800, 20850, 20900, 20950, 21000, 21050, 21100, 21150, 21200, 21250, 21300, 21350, 21400, 21450, 21500, 21550, 21600, 21650, 21700, 21750, 21800, 21850, 21900, 21950, 22000, 22050, 22100, 22150, 22200, 22250, 22300, 22350, 22400, 22450, 22500, 22550, 22600, 22650, 22700, 22750, 22800, 22850, 22900, 22950, 23000, 23050, 23100, 23150, 23200, 23250, 23300, 23350, 23400, 23450, 23500, 23550, 23600, 23650, 23700, 23750, 23800, 23850, 23900, 23950, 24000, 24050, 24100, 24150, 24200, 24250, 24300, 24350, 24400, 24450, 24500, 24550, 24600, 24650, 24700, 24750, 24800, 24850, 24900, 24950, 25000, 25050, 25100, 25150, 25200, 25250, 25300, 25350, 25400, 25450, 25500, 25550, 25600, 25650, 25700, 25750, 25800], "loss": [1.0292, 0.5784, 0.1445, 0.1013, 0.0802, 0.0713, 0.0663, 0.0652, 0.0581, 0.0551, 0.0549, 0.0568, 0.0525, 0.0504, 0.0516, 0.0491, 0.05, 0.0497, 0.05, 0.0468, 0.0465, 0.0468, 0.0467, 0.0458, 0.044, 0.0434, 0.0471, 0.0412, 0.0407, 0.042, 0.0432, 0.0375, 0.0404, 0.0412, 0.0386, 0.0369, 0.0385, 0.0388, 0.0352, 0.0371, 0.0348, 0.0332, 0.0361, 0.0371, 0.0341, 0.0339, 0.0337, 0.0318, 0.0339, 0.0316, 0.0318, 0.0318, 0.0309, 0.0323, 0.0317, 0.031, 0.0322, 0.0315, 0.0312, 0.03, 0.03, 0.0313, 0.0292, 0.0294, 0.0304, 0.0307, 0.0287, 0.0306, 0.0285, 0.0286, 0.0282, 0.0285, 0.0283, 0.0285, 0.0285, 0.0269, 0.0271, 0.0276, 0.0259, 0.0265, 0.0264, 0.0262, 0.0267, 0.0266, 0.0251, 0.0281, 0.0264, 0.0252, 0.0265, 0.0256, 0.0248, 0.028, 0.0264, 0.0242, 0.0258, 0.0263, 0.0238, 0.0244, 0.0257, 0.0244, 0.0241, 0.0255, 0.0244, 0.0245, 0.0232, 0.0246, 0.0227, 0.0247, 0.0236, 0.0237, 0.0233, 0.0245, 0.022, 0.0232, 0.0232, 0.0238, 0.0229, 0.0225, 0.0223, 0.0213, 0.0224, 0.0215, 0.0217, 0.0222, 0.0205, 0.0215, 0.0206, 0.0216, 0.0211, 0.0227, 0.0219, 0.0225, 0.0218, 0.0206, 0.0215, 0.0201, 0.0214, 0.0208, 0.0219, 0.0207, 0.0218, 0.0201, 0.0213, 0.0199, 0.0191, 0.0205, 0.0196, 0.0206, 0.0201, 0.0201, 0.02, 0.0195, 0.0195, 0.0202, 0.0187, 0.0195, 0.0189, 0.0196, 0.0204, 0.0195, 0.019, 0.0197, 0.0193, 0.0194, 0.0206, 0.0185, 0.0192, 0.0197, 0.0192, 0.0187, 0.0188, 0.0188, 0.0192, 0.0195, 0.0177, 0.0187, 0.0183, 0.0184, 0.0199, 0.0177, 0.0182, 0.0181, 0.0182, 0.0197, 0.0177, 0.0188, 0.0192, 0.019, 0.0189, 0.0177, 0.0175, 0.0178, 0.0183, 0.0183, 0.0177, 0.0182, 0.0176, 0.017, 0.0179, 0.0161, 0.0172, 0.0179, 0.0178, 0.0172, 0.0181, 0.0182, 0.0182, 0.0175, 0.0166, 0.0161, 0.0167, 0.0168, 0.0159, 0.0165, 0.0164, 0.0163, 0.0159, 0.0166, 0.0182, 0.0159, 0.0161, 0.0158, 0.0165, 0.0172, 0.016, 0.0155, 0.0154, 0.0168, 0.0167, 0.0177, 0.0157, 0.0158, 0.0171, 0.0163, 0.0158, 0.0177, 0.0174, 0.0158, 0.0162, 0.0159, 0.0159, 0.0165, 0.0166, 0.0152, 0.0157, 0.0155, 0.0149, 0.0158, 0.0183, 0.0149, 0.0173, 0.0161, 0.0153, 0.0158, 0.0151, 0.015, 0.0162, 0.0149, 0.0143, 0.0151, 0.0159, 0.0148, 0.0148, 0.0152, 0.0154, 0.0168, 0.0148, 0.0155, 0.0143, 0.0152, 0.0143, 0.0154, 0.0146, 0.0162, 0.0156, 0.0138, 0.0158, 0.0152, 0.0152, 0.0151, 0.0141, 0.0144, 0.0162, 0.0142, 0.0156, 0.015, 0.0149, 0.0142, 0.015, 0.0156, 0.0164, 0.0144, 0.0147, 0.0138, 0.0145, 0.015, 0.0145, 0.0141, 0.0144, 0.015, 0.0146, 0.0144, 0.0145, 0.0139, 0.0142, 0.0145, 0.0144, 0.0145, 0.0137, 0.0145, 0.0144, 0.0136, 0.0147, 0.0131, 0.0138, 0.0137, 0.0141, 0.0135, 0.0139, 0.0134, 0.0158, 0.013, 0.0139, 0.0123, 0.0131, 0.014, 0.0141, 0.0133, 0.0129, 0.0138, 0.0147, 0.0142, 0.0128, 0.0135, 0.0136, 0.0139, 0.0134, 0.0138, 0.0146, 0.0137, 0.0132, 0.0132, 0.0139, 0.0149, 0.0141, 0.0131, 0.0131, 0.013, 0.0123, 0.0149, 0.0134, 0.0127, 0.0134, 0.0133, 0.0144, 0.0134, 0.0125, 0.0135, 0.0128, 0.0132, 0.0137, 0.0135, 0.013, 0.0126, 0.0141, 0.0129, 0.014, 0.013, 0.0135, 0.014, 0.0121, 0.0133, 0.0122, 0.0135, 0.0133, 0.0127, 0.0137, 0.0136, 0.0122, 0.0133, 0.0127, 0.013, 0.0124, 0.0131, 0.0126, 0.0129, 0.0133, 0.0122, 0.0135, 0.0132, 0.0129, 0.0127, 0.0131, 0.0132, 0.0125, 0.013, 0.0132, 0.012, 0.0134, 0.0133, 0.0125, 0.0123, 0.0141, 0.0122, 0.0135, 0.0126, 0.0123, 0.0116, 0.0121, 0.0125, 0.012, 0.0123, 0.0124, 0.0118, 0.0129, 0.0126, 0.0125, 0.0114, 0.0117, 0.0132, 0.0128, 0.0124, 0.0122, 0.0116, 0.0116, 0.0122, 0.0119, 0.0118, 0.0121, 0.0121, 0.0126, 0.0127, 0.012, 0.0129, 0.0115, 0.0119, 0.0118, 0.0118, 0.0121, 0.012, 0.0123, 0.0123, 0.0114, 0.0126, 0.012, 0.0118, 0.0111, 0.0116, 0.0125, 0.0133, 0.0117, 0.0122, 0.0122, 0.0121, 0.013, 0.0112, 0.0115, 0.0117, 0.0117, 0.0123, 0.0112, 0.0122, 0.0113, 0.0124, 0.0116, 0.0113, 0.0123, 0.0113, 0.0111, 0.012, 0.0118, 0.0119, 0.0116, 0.012, 0.0116, 0.0116, 0.0113, 0.0124, 0.0112, 0.0121, 0.0107, 0.0107, 0.0117, 0.0114, 0.0111, 0.0113, 0.0118, 0.0113, 0.0114, 0.0122, 0.0116, 0.011, 0.0116, 0.0103, 0.012, 0.0117, 0.0119, 0.0117, 0.0111, 0.0112, 0.0114, 0.0122, 0.0109, 0.0112, 0.0114, 0.0116, 0.0117, 0.0113, 0.0118, 0.0111, 0.0121, 0.0112, 0.0111, 0.0107, 0.0113, 0.0102, 0.0109], "grad": [4.3841, 2.7584, 0.8733, 0.646, 0.5032, 0.4119, 0.3743, 0.3607, 0.3042, 0.2781, 0.2811, 0.2606, 0.2588, 0.2508, 0.2352, 0.2265, 0.2329, 0.2125, 0.2154, 0.2074, 0.1967, 0.199, 0.1795, 0.1832, 0.1832, 0.173, 0.1836, 0.1689, 0.1696, 0.1633, 0.16, 0.1535, 0.1664, 0.16, 0.1561, 0.1543, 0.1585, 0.168, 0.1394, 0.1506, 0.143, 0.1384, 0.1472, 0.1566, 0.1594, 0.1351, 0.1396, 0.1335, 0.1366, 0.1331, 0.1298, 0.1336, 0.1235, 0.1327, 0.1265, 0.124, 0.1298, 0.1373, 0.1285, 0.1251, 0.1279, 0.1389, 0.1295, 0.1245, 0.1269, 0.1238, 0.1174, 0.1411, 0.1203, 0.1169, 0.1161, 0.1166, 0.1172, 0.1146, 0.1243, 0.1114, 0.1129, 0.1168, 0.1084, 0.1103, 0.1094, 0.113, 0.1125, 0.1124, 0.1061, 0.1213, 0.1152, 0.1059, 0.1135, 0.1111, 0.1042, 0.1188, 0.1036, 0.0982, 0.1051, 0.1115, 0.0995, 0.1008, 0.1102, 0.1054, 0.1034, 0.1119, 0.0988, 0.114, 0.1048, 0.1081, 0.1006, 0.1059, 0.1052, 0.1085, 0.1026, 0.1078, 0.0954, 0.0967, 0.1012, 0.1028, 0.0942, 0.0934, 0.096, 0.0949, 0.1032, 0.0966, 0.0974, 0.0971, 0.0897, 0.0957, 0.0932, 0.0951, 0.0959, 0.0977, 0.0958, 0.0994, 0.0984, 0.0907, 0.0933, 0.0881, 0.0978, 0.0935, 0.0974, 0.0963, 0.095, 0.0924, 0.094, 0.0854, 0.0866, 0.0925, 0.0848, 0.0939, 0.0938, 0.0877, 0.0886, 0.0894, 0.0983, 0.0928, 0.0864, 0.0901, 0.0902, 0.0841, 0.096, 0.0896, 0.0849, 0.0856, 0.0897, 0.082, 0.0939, 0.0834, 0.0831, 0.0919, 0.0893, 0.0869, 0.083, 0.0856, 0.0859, 0.0908, 0.0777, 0.0833, 0.0891, 0.0886, 0.0939, 0.088, 0.0906, 0.0812, 0.0838, 0.0845, 0.0826, 0.0861, 0.0865, 0.0928, 0.0866, 0.079, 0.084, 0.0813, 0.0829, 0.0904, 0.0809, 0.0861, 0.0817, 0.0844, 0.0809, 0.0791, 0.0835, 0.0823, 0.0824, 0.0796, 0.0875, 0.0845, 0.0915, 0.0811, 0.0855, 0.0826, 0.0898, 0.0874, 0.0785, 0.077, 0.0736, 0.0835, 0.0777, 0.0802, 0.0882, 0.0769, 0.0755, 0.0747, 0.0756, 0.0814, 0.0815, 0.075, 0.0759, 0.0891, 0.0863, 0.0871, 0.0779, 0.0783, 0.0859, 0.0796, 0.0737, 0.0886, 0.0927, 0.0764, 0.0784, 0.0761, 0.0806, 0.0803, 0.0806, 0.0777, 0.0766, 0.0769, 0.0783, 0.0792, 0.0907, 0.0781, 0.0849, 0.0768, 0.0837, 0.0762, 0.0739, 0.0739, 0.0811, 0.0829, 0.0721, 0.0793, 0.0772, 0.0735, 0.0764, 0.0748, 0.0733, 0.0841, 0.0721, 0.0779, 0.0696, 0.0799, 0.075, 0.0766, 0.0762, 0.09, 0.077, 0.0684, 0.0776, 0.0759, 0.0757, 0.0775, 0.0719, 0.0732, 0.0769, 0.0698, 0.0759, 0.0777, 0.073, 0.0731, 0.0751, 0.0832, 0.0838, 0.0734, 0.0739, 0.0715, 0.0705, 0.0716, 0.0697, 0.0718, 0.0722, 0.0787, 0.0783, 0.0749, 0.0761, 0.068, 0.0726, 0.0762, 0.0799, 0.073, 0.0687, 0.0764, 0.0729, 0.0731, 0.0753, 0.0671, 0.0725, 0.075, 0.0697, 0.0668, 0.0775, 0.0714, 0.0878, 0.0691, 0.0705, 0.0654, 0.0703, 0.0682, 0.0696, 0.0689, 0.0691, 0.0699, 0.0752, 0.0792, 0.0695, 0.0701, 0.073, 0.0744, 0.0682, 0.073, 0.0733, 0.0709, 0.0685, 0.0721, 0.0722, 0.0754, 0.0741, 0.0712, 0.0727, 0.0797, 0.068, 0.0747, 0.0752, 0.0679, 0.0739, 0.0671, 0.0733, 0.0709, 0.0772, 0.0738, 0.0691, 0.0699, 0.0704, 0.0719, 0.0674, 0.0665, 0.0804, 0.0686, 0.0746, 0.0679, 0.0719, 0.0744, 0.065, 0.072, 0.0692, 0.0713, 0.0724, 0.0693, 0.0701, 0.0722, 0.0628, 0.0679, 0.0703, 0.0708, 0.0644, 0.0728, 0.0659, 0.0682, 0.0708, 0.0631, 0.073, 0.0682, 0.0682, 0.0678, 0.0718, 0.068, 0.0672, 0.0759, 0.0751, 0.0696, 0.0718, 0.0738, 0.0679, 0.067, 0.0695, 0.0645, 0.08, 0.0722, 0.0661, 0.0718, 0.0649, 0.0671, 0.0665, 0.0635, 0.0689, 0.0678, 0.0718, 0.0722, 0.0719, 0.0668, 0.0671, 0.0761, 0.0699, 0.0655, 0.0669, 0.0633, 0.0635, 0.0629, 0.0636, 0.0686, 0.0691, 0.0634, 0.0678, 0.0663, 0.0639, 0.0678, 0.0655, 0.0659, 0.066, 0.0622, 0.0703, 0.0656, 0.0661, 0.069, 0.0668, 0.0766, 0.0717, 0.0667, 0.0646, 0.0646, 0.0723, 0.0737, 0.0661, 0.0707, 0.0665, 0.0688, 0.07, 0.0624, 0.0614, 0.0708, 0.0665, 0.0699, 0.0624, 0.0675, 0.0612, 0.0794, 0.063, 0.0635, 0.0672, 0.0643, 0.0653, 0.0678, 0.0658, 0.0638, 0.0673, 0.0638, 0.0638, 0.062, 0.0626, 0.065, 0.0643, 0.0674, 0.0622, 0.0607, 0.0668, 0.0618, 0.0618, 0.0654, 0.0675, 0.0643, 0.0641, 0.0731, 0.0692, 0.0632, 0.0652, 0.0619, 0.0684, 0.0713, 0.0696, 0.0658, 0.0682, 0.0599, 0.0679, 0.0711, 0.0633, 0.0655, 0.0618, 0.0667, 0.0668, 0.0631, 0.0649, 0.0624, 0.0674, 0.0689, 0.07, 0.0625, 0.0615, 0.0667, 0.0659], "param": [1802.3865, 1802.3859, 1802.3848, 1802.3857, 1802.3872, 1802.389, 1802.3921, 1802.3978, 1802.4056, 1802.4152, 1802.4282, 1802.4451, 1802.4646, 1802.489, 1802.5182, 1802.5516, 1802.5917, 1802.6382, 1802.6899, 1802.7428, 1802.8015, 1802.8684, 1802.9369, 1803.0045, 1803.0773, 1803.144, 1803.214, 1803.2853, 1803.355, 1803.4259, 1803.495, 1803.5653, 1803.6342, 1803.7059, 1803.7792, 1803.849, 1803.921, 1803.993, 1804.0649, 1804.1351, 1804.2056, 1804.2767, 1804.3474, 1804.4236, 1804.4991, 1804.566, 1804.6324, 1804.7029, 1804.7732, 1804.8429, 1804.9147, 1804.9851, 1805.0575, 1805.1284, 1805.2006, 1805.27, 1805.339, 1805.4087, 1805.4829, 1805.5533, 1805.6224, 1805.6964, 1805.7703, 1805.8365, 1805.9056, 1805.9783, 1806.0483, 1806.1194, 1806.1893, 1806.2631, 1806.3322, 1806.4021, 1806.4702, 1806.5402, 1806.6147, 1806.6819, 1806.7502, 1806.8198, 1806.8906, 1806.9592, 1807.0306, 1807.0996, 1807.1713, 1807.2433, 1807.3105, 1807.38, 1807.4531, 1807.5259, 1807.5944, 1807.6688, 1807.7356, 1807.8075, 1807.8802, 1807.9493, 1808.014, 1808.0822, 1808.1537, 1808.2181, 1808.2899, 1808.3618, 1808.4333, 1808.5044, 1808.5753, 1808.644, 1808.7139, 1808.7825, 1808.8501, 1808.9215, 1808.9912, 1809.0601, 1809.1302, 1809.1997, 1809.2671, 1809.33, 1809.3978, 1809.4659, 1809.5343, 1809.6006, 1809.6709, 1809.7378, 1809.806, 1809.8737, 1809.9425, 1810.0112, 1810.0781, 1810.1495, 1810.2188, 1810.2858, 1810.3538, 1810.4241, 1810.495102, 1810.5669, 1810.6378, 1810.7036, 1810.7706, 1810.8398, 1810.9047, 1810.9731, 1811.0441, 1811.1118, 1811.1819, 1811.2502, 1811.3169, 1811.387, 1811.4509, 1811.5197, 1811.5896, 1811.6556, 1811.7278, 1811.7965, 1811.864, 1811.9293, 1812.0026, 1812.0699, 1812.1392, 1812.212, 1812.2781, 1812.3434, 1812.4119, 1812.4768, 1812.547, 1812.613, 1812.678, 1812.7468, 1812.8159, 1812.8828, 1812.9489, 1813.0156, 1813.0837, 1813.1508, 1813.219, 1813.2869, 1813.3534, 1813.4203, 1813.4884, 1813.5531, 1813.6219, 1813.6934, 1813.7635, 1813.8328, 1813.8943, 1813.9629, 1814.0297, 1814.0952, 1814.1631, 1814.2306, 1814.2987, 1814.3679, 1814.4355, 1814.5024, 1814.5693, 1814.6396, 1814.7078, 1814.7756, 1814.8429, 1814.9125, 1814.9796, 1815.0493, 1815.115, 1815.1788, 1815.2472, 1815.3153, 1815.3843, 1815.4518, 1815.5193, 1815.5881, 1815.6531, 1815.7227, 1815.7825, 1815.849, 1815.9181, 1815.9912, 1816.0527, 1816.114, 1816.181, 1816.2444, 1816.3119, 1816.3818, 1816.4503, 1816.5159, 1816.5825, 1816.6465, 1816.7106, 1816.7815, 1816.8518, 1816.9175, 1816.9849, 1817.0538, 1817.1206, 1817.1865, 1817.2528, 1817.3204, 1817.3884, 1817.4575, 1817.5271, 1817.5929, 1817.6603, 1817.7288, 1817.7897, 1817.8538, 1817.9197, 1817.9868, 1818.0597, 1818.1284, 1818.1912, 1818.2568, 1818.3231, 1818.3909, 1818.4604, 1818.5256, 1818.5872, 1818.6559, 1818.7178, 1818.7773, 1818.8418, 1818.9099, 1818.979, 1819.0521, 1819.1156, 1819.1771, 1819.23971, 1819.3059, 1819.3716, 1819.4384, 1819.5026, 1819.5697, 1819.6353, 1819.6978, 1819.7615, 1819.8281, 1819.9041, 1819.9656, 1820.0284, 1820.0962, 1820.1649, 1820.2313, 1820.2949, 1820.3622, 1820.4309, 1820.498, 1820.5581, 1820.6216, 1820.6869, 1820.7559, 1820.8206, 1820.8853, 1820.9497, 1821.0171, 1821.0831, 1821.1525, 1821.2244, 1821.2891, 1821.3516, 1821.4187, 1821.4846, 1821.5497, 1821.6138, 1821.6847, 1821.7484, 1821.8115, 1821.8785, 1821.9421, 1822.0062, 1822.0715, 1822.1346, 1822.205, 1822.2689, 1822.3348, 1822.3993, 1822.4622, 1822.5315, 1822.595, 1822.6593, 1822.7268, 1822.7905, 1822.8528, 1822.9187, 1822.9828, 1823.0469, 1823.1102, 1823.1812, 1823.2379, 1823.2931, 1823.3574, 1823.4215, 1823.4878, 1823.5549, 1823.618, 1823.6805, 1823.7444, 1823.814, 1823.8822, 1823.9465, 1824.0115, 1824.0804, 1824.1431, 1824.2075, 1824.27, 1824.3418, 1824.4108, 1824.4724, 1824.5356, 1824.6018, 1824.6685, 1824.7368, 1824.8008, 1824.8672, 1824.9305, 1824.9906, 1825.0543, 1825.1222, 1825.1873, 1825.2515, 1825.3169, 1825.3835, 1825.4529, 1825.514, 1825.5803, 1825.645, 1825.7061, 1825.7719, 1825.8374, 1825.9009, 1825.9653, 1826.0348, 1826.1012, 1826.1615, 1826.2284, 1826.2941, 1826.358, 1826.4241, 1826.488, 1826.5487, 1826.6112, 1826.6721, 1826.7408, 1826.8065, 1826.8734, 1826.9359, 1826.9978, 1827.0627, 1827.1252, 1827.1906, 1827.2528, 1827.3162, 1827.3794, 1827.4443, 1827.5072, 1827.568717, 1827.6362, 1827.6993, 1827.7637, 1827.8265, 1827.8881, 1827.9525, 1828.019, 1828.0853, 1828.1462, 1828.2092, 1828.2717, 1828.3359, 1828.4003, 1828.4662, 1828.5287, 1828.595, 1828.6654, 1828.7244, 1828.7926, 1828.8528, 1828.9163, 1828.975, 1829.0421, 1829.1038, 1829.1664, 1829.2363, 1829.2997, 1829.3602, 1829.4225, 1829.4884, 1829.5505, 1829.615, 1829.6763, 1829.7368, 1829.8015, 1829.8628, 1829.9258, 1829.9911, 1830.0565, 1830.1206, 1830.1837, 1830.2478, 1830.3125, 1830.3752, 1830.4377, 1830.4984, 1830.5625, 1830.6287, 1830.6906, 1830.7531, 1830.8181, 1830.8806, 1830.9443, 1831.0062, 1831.0688, 1831.132, 1831.1978, 1831.2603, 1831.3276, 1831.3918, 1831.4537, 1831.5171, 1831.5833, 1831.6478, 1831.7087, 1831.7709, 1831.8346, 1831.8975, 1831.9631, 1832.0231, 1832.0887, 1832.1534, 1832.2137, 1832.2834, 1832.345, 1832.4077, 1832.4702, 1832.5363, 1832.5994, 1832.662, 1832.7194, 1832.7806, 1832.844, 1832.9113, 1832.9762, 1833.0393, 1833.1034, 1833.1665, 1833.2323, 1833.2927, 1833.3572, 1833.4231, 1833.483, 1833.5452, 1833.6102, 1833.6758, 1833.7395, 1833.8026, 1833.8629, 1833.9265, 1833.9916, 1834.0543, 1834.1162, 1834.1797, 1834.2424, 1834.3041, 1834.3674, 1834.4326, 1834.4952, 1834.5533, 1834.6208, 1834.6847, 1834.748, 1834.8097, 1834.8694, 1834.9327, 1834.998, 1835.0615, 1835.1244, 1835.1849, 1835.2474, 1835.3112, 1835.3796, 1835.4443, 1835.504, 1835.5675, 1835.6284, 1835.688401], "saves": [2500, 5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 27500], "cur": 28700, "total": 30000, "rate": 4.1, "elapsed": "33:37:50", "remaining": "1:31:22", "loggedTo": 25800, "frames": 161440, "bs": 32, "pruneFloor": 7500, "finalStep": 29999};
const fmt = (n,d=4)=>n.toFixed(d);
const gp = k=>getComputedStyle(document.documentElement).getPropertyValue(k).trim();
const nf = new Intl.NumberFormat('en-US');
const ep = s=>(s*D.bs/D.frames);
/* ---------- header + rail ---------- */
const pct = D.cur/D.total;
document.getElementById('chipRate').textContent = D.rate+'s/step';
document.getElementById('pillTxt').textContent = 'running · '+D.elapsed+' elapsed';
document.getElementById('railPct').textContent = (pct*100).toFixed(1)+'%';
document.getElementById('railStep').innerHTML =
nf.format(D.cur)+' <span>/ '+nf.format(D.total)+'</span>';
document.getElementById('railFill').style.width = (pct*100)+'%';
document.getElementById('lossNow').textContent = fmt(D.loss.at(-1));
document.getElementById('nLogged').textContent = nf.format(D.loggedTo);
document.getElementById('nCur').textContent = nf.format(D.cur);
document.getElementById('nPts').textContent = nf.format(D.steps.length);
document.getElementById('nKeptNote').textContent= D.saves.filter(s=>s>=D.pruneFloor).length+' + 1';
{ /* 2,000 steps at the 50-step log interval = 40 points each side. */
const w=40, mu=a=>a.reduce((x,y)=>x+y,0)/a.length,
a=mu(D.loss.slice(-2*w,-w)), b=mu(D.loss.slice(-w));
document.getElementById('nFlat').textContent =
fmt(a)+' \u2192 '+fmt(b)+' ('+(100*(b-a)/a).toFixed(1)+'%)'; }
const rail = document.getElementById('rail'), axis = document.getElementById('railAxis');
/* A checkpoint below the prune floor is deleted by the janitor, so the rail says which
ones actually survive rather than treating all three as equivalent. */
D.saves.forEach(st=>{
const kept = st >= D.pruneFloor, x = 100*st/D.total;
const t = document.createElement('div');
t.className = 'tick'+(kept?'':' floor'); t.style.left = 'calc('+x+'% - 1px)';
rail.appendChild(t);
/* Every save gets a tick, but only a 5k grid gets a label -- 11 labels at 2.5k
spacing overlap into unreadable mush. Tick STYLE carries pruned-vs-kept; the
key line below carries the counts. */
if(st % 5000) return;
const i = document.createElement('i');
if(kept) i.className='k';
i.style.left = x+'%';
i.textContent = (st/1000)+'k';
axis.appendChild(i);
});
{ const nPruned = D.saves.filter(s=>s < D.pruneFloor).length,
nKept = D.saves.filter(s=>s >= D.pruneFloor).length,
left = Math.floor((D.total - D.saves.at(-1))/2500);
document.getElementById('railKey').innerHTML =
'<span><b class="sw kept"></b>'+nKept+' kept</span>' +
'<span><b class="sw"></b>'+nPruned+' pruned &mdash; below step '+nf.format(D.pruneFloor)+'</span>' +
'<span>'+left+' more to come, last at step '+nf.format(D.finalStep)+'</span>'; }
{ const i=document.createElement('i'); i.style.left='0%'; i.style.transform='none'; i.textContent='0'; axis.appendChild(i);
const j=document.createElement('i'); j.style.left='100%'; j.style.transform='translateX(-100%)'; j.textContent='30k'; axis.appendChild(j); }
/* ---------- KPIs ---------- */
const best = Math.min(...D.loss), bestAt = D.steps[D.loss.indexOf(best)];
const mean = a=>a.reduce((x,y)=>x+y,0)/a.length;
const sd = a=>{const m=mean(a);return Math.sqrt(mean(a.map(v=>(v-m)*(v-m))));};
/* 40 points = 2,000 steps at the 50-step log interval, matching note 3. The shift
between windows only counts as a trend once it clears the in-window spread --
a fixed epsilon like 1e-4 sits far below the noise here and always says
'falling'. */
const cut = Math.min(40, Math.max(1, Math.floor(D.loss.length/4)));
const rec = mean(D.loss.slice(-cut)), prev = mean(D.loss.slice(-2*cut,-cut));
const dev = sd(D.loss.slice(-cut));
const trend = Math.abs(rec-prev) < dev ? 'flat' : (rec < prev ? 'falling' : 'rising');
[['Loss now', fmt(D.loss.at(-1)), 'at step '+nf.format(D.loggedTo)],
['Best loss', fmt(best), 'at step '+nf.format(bestAt)],
['Trend', trend, '\u00b1'+fmt(dev)+' noise over '+nf.format(cut*50)+' steps'],
['Epochs done', ep(D.cur).toFixed(2), 'of '+ep(D.total).toFixed(2)+' planned'],
['Elapsed', D.elapsed.split(':').slice(0,2).join('h ')+'m', D.rate+'s per step'],
['Remaining', D.remaining.split(':').slice(0,2).join('h ')+'m', 'to step '+nf.format(D.total)]
].forEach(([l,v,s])=>{
const d=document.createElement('div'); d.className='kpi';
const a=document.createElement('div'); a.className='lbl'; a.textContent=l;
const b=document.createElement('div'); b.className='v mono'; b.textContent=v;
const c=document.createElement('div'); c.className='s mono'; c.textContent=s;
d.append(a,b,c); document.getElementById('kpis').appendChild(d);
});
/* ---------- table ---------- */
const tb=document.getElementById('tbody');
D.steps.forEach((s,i)=>{
const tr=document.createElement('tr');
const ck=D.saves.includes(s)?'saved':'';
[nf.format(s), ep(s).toFixed(2), fmt(D.loss[i]), fmt(D.grad[i]), D.param[i].toFixed(2), ck]
.forEach((v,j)=>{ const td=document.createElement('td'); if(j===5) td.className='ck';
td.textContent=v; tr.appendChild(td); });
tb.appendChild(tr);
});
/* ---------- charts ---------- */
const SVG='http://www.w3.org/2000/svg';
const el=(n,a={})=>{const e=document.createElementNS(SVG,n);for(const k in a)e.setAttribute(k,a[k]);return e;};
const tip=document.getElementById('tip');
function chart(id, vals, colorVar, opts){
const svg=document.getElementById(id);
const W=svg.clientWidth||720, H=+svg.getAttribute('height');
const M={t:14,r:opts.rightPad||52,b:26,l:opts.leftPad||46};
svg.setAttribute('viewBox','0 0 '+W+' '+H);
svg.replaceChildren();
const iw=W-M.l-M.r, ih=H-M.t-M.b;
const col=gp(colorVar), surf=gp('--card');
const lo=Math.min(...vals), hi=Math.max(...vals);
let ys, ticks;
if(opts.log){
const l0=Math.log10(lo), l1=Math.log10(hi), padv=(l1-l0)*0.08;
const a=l0-padv, b=l1+padv;
ys=v=>M.t+ih-(Math.log10(v)-a)/(b-a)*ih;
ticks=opts.ticks.filter(t=>t>=Math.pow(10,a)&&t<=Math.pow(10,b));
}else{
const padv=(hi-lo)*0.12||1, a=lo-padv, b=hi+padv;
ys=v=>M.t+ih-(v-a)/(b-a)*ih;
const span=hi-lo, raw=span/4, mag=Math.pow(10,Math.floor(Math.log10(raw)));
const stepv=[1,2,5,10].map(m=>m*mag).find(m=>m>=raw)||10*mag;
ticks=[]; for(let t=Math.ceil(a/stepv)*stepv; t<=b; t+=stepv) ticks.push(+t.toFixed(6));
}
const xs=s=>M.l+(s-D.steps[0])/(D.steps.at(-1)-D.steps[0]||1)*iw;
ticks.forEach(t=>{
const y=ys(t);
svg.appendChild(el('line',{x1:M.l,x2:M.l+iw,y1:y,y2:y,stroke:gp('--grid'),'stroke-width':1}));
const tx=el('text',{x:M.l-9,y:y+3.5,'text-anchor':'end',fill:gp('--ink-3'),'font-size':10,
'font-family':'ui-monospace,Menlo,monospace'});
tx.textContent=opts.fmtTick(t); svg.appendChild(tx);
});
/* Checkpoint rules on EVERY save, but text on a 10k grid only. 11 saves x
'ckpt 12.5k' overruns the axis and collides with the endpoint label. */
if(opts.marks) D.saves.filter(s=>s<=D.steps.at(-1)).forEach(s=>{
svg.appendChild(el('line',{x1:xs(s),x2:xs(s),y1:M.t,y2:M.t+ih,stroke:gp('--rule'),'stroke-width':1}));
if(s % 10000 || xs(s) > M.l+iw-46) return;
const t=el('text',{x:xs(s),y:M.t+ih+16,'text-anchor':'middle',fill:gp('--ink-3'),'font-size':9,
'font-family':'ui-monospace,Menlo,monospace'});
t.textContent='ckpt '+(s/1000)+'k'; svg.appendChild(t);
});
/* x ends */
[[D.steps[0],'start'],[D.steps.at(-1),'end']].forEach(([s,anch])=>{
const t=el('text',{x:xs(s),y:H-6,'text-anchor':anch==='start'?'start':'end',fill:gp('--ink-3'),
'font-size':10,'font-family':'ui-monospace,Menlo,monospace'});
t.textContent=nf.format(s); svg.appendChild(t);
});
const pts=vals.map((v,i)=>[xs(D.steps[i]),ys(v)]);
const dpath=pts.map((p,i)=>(i?'L':'M')+p[0].toFixed(2)+' '+p[1].toFixed(2)).join(' ');
svg.appendChild(el('path',{d:dpath+' L'+pts.at(-1)[0]+' '+(M.t+ih)+' L'+pts[0][0]+' '+(M.t+ih)+' Z',
fill:col,opacity:.10,stroke:'none'}));
svg.appendChild(el('path',{d:dpath,fill:'none',stroke:col,'stroke-width':2,
'stroke-linejoin':'round','stroke-linecap':'round'}));
/* endpoint: 8px marker with a 2px surface ring, plus a direct label (relief for the aqua WARN) */
const last=pts.at(-1);
svg.appendChild(el('circle',{cx:last[0],cy:last[1],r:4,fill:col,stroke:surf,'stroke-width':2}));
const lab=el('text',{x:last[0]+9,y:last[1]+3.5,fill:gp('--ink'),'font-size':11,'font-weight':650,
'font-family':'ui-monospace,Menlo,monospace'});
lab.textContent=opts.fmtLabel(vals.at(-1)); svg.appendChild(lab);
/* hover: crosshair snapping to nearest step */
const cross=el('line',{y1:M.t,y2:M.t+ih,stroke:gp('--ink-3'),'stroke-width':1,opacity:0});
const hv=el('circle',{r:4.5,fill:col,stroke:surf,'stroke-width':2,opacity:0});
svg.append(cross,hv);
const hit=el('rect',{x:M.l,y:M.t,width:iw,height:ih,fill:'transparent'});
svg.appendChild(hit);
function show(cx){
const r=svg.getBoundingClientRect(), sx=(cx-r.left)*(W/r.width);
let bi=0,bd=1e9;
D.steps.forEach((s,i)=>{const dd=Math.abs(xs(s)-sx); if(dd<bd){bd=dd;bi=i;}});
cross.setAttribute('x1',xs(D.steps[bi])); cross.setAttribute('x2',xs(D.steps[bi]));
cross.setAttribute('opacity',.45);
hv.setAttribute('cx',pts[bi][0]); hv.setAttribute('cy',pts[bi][1]); hv.setAttribute('opacity',1);
tip.replaceChildren();
const h=document.createElement('div'); h.className='tstep';
h.textContent='step '+nf.format(D.steps[bi])+' · '+ep(D.steps[bi]).toFixed(2)+' ep';
tip.appendChild(h);
[['--s1','loss',fmt(D.loss[bi])],['--s2','grad norm',fmt(D.grad[bi])],
['--s3','param norm',D.param[bi].toFixed(2)]].forEach(([cv,nm,v])=>{
const row=document.createElement('div'); row.className='trow';
const l=document.createElement('span');
const k=document.createElement('span'); k.className='keyline'; k.style.background=gp(cv);
l.append(k,document.createTextNode(nm));
const b=document.createElement('b'); b.className='mono'; b.textContent=v;
row.append(l,b); tip.appendChild(row);
});
const tr=svg.getBoundingClientRect();
const px=tr.left+pts[bi][0]*(tr.width/W), py=tr.top+pts[bi][1]*(tr.height/H);
tip.style.opacity=1;
const tw=tip.offsetWidth, th=tip.offsetHeight;
tip.style.left=Math.min(window.innerWidth-tw-10,Math.max(10,px-tw/2))+'px';
tip.style.top=Math.max(10,py-th-14)+'px';
}
function hide(){cross.setAttribute('opacity',0);hv.setAttribute('opacity',0);tip.style.opacity=0;}
svg.addEventListener('pointermove',e=>show(e.clientX));
svg.addEventListener('pointerleave',hide);
svg.addEventListener('focus',()=>show(svg.getBoundingClientRect().right-20));
svg.addEventListener('blur',hide);
}
const charts=()=>{
chart('cLoss', D.loss, '--s1', {log:true, marks:true,
ticks:[0.02,0.05,0.1,0.2,0.5,1], fmtTick:t=>t<0.1?t.toFixed(2):(t<1?t.toFixed(1):t.toFixed(0)),
fmtLabel:v=>v.toFixed(4)});
chart('cGrad', D.grad, '--s2', {log:true, leftPad:40, rightPad:56,
ticks:[0.1,0.2,0.5,1,2,5], fmtTick:t=>t<1?t.toFixed(1):t.toFixed(0), fmtLabel:v=>v.toFixed(3)});
chart('cParam', D.param, '--s3', {log:false, leftPad:52, rightPad:60,
fmtTick:t=>t.toFixed(0), fmtLabel:v=>v.toFixed(1)});
};
charts();
addEventListener('resize',()=>{clearTimeout(window._t);window._t=setTimeout(charts,120);});
matchMedia('(prefers-color-scheme: dark)').addEventListener('change',charts);
new MutationObserver(charts).observe(document.documentElement,{attributes:true,attributeFilter:['data-theme']});
</script>