Download index.html from NagaYu/molt: direct link, hf CLI and curl.
- Browser
- Download file 41.2 kB
-
https://huggingface.co/spaces/NagaYu/molt/resolve/main/index.html
- Command line
-
hf download hf://spaces/NagaYu/molt/index.html
-
curl -L -o index.html https://huggingface.co/spaces/NagaYu/molt/resolve/main/index.html
41.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width,initial-scale=1"> | |
| <title>Molt — elastic on-device inference</title> | |
| <style> | |
| :root{ | |
| /* A memory gauge, not a mood board: the neutrals carry a faint green bias | |
| (the colour of a healthy meter), the accent is that same green at full | |
| strength, and the alarm hue is the one an OS uses when it takes memory | |
| back. The three rungs get a deliberate cool -> warm ramp so a stripe of | |
| tokens reads as a ladder rather than as three arbitrary categories. */ | |
| --paper:#f2f4ee; --ink:#12160f; --ink-2:#4a5147; --ink-3:#7b8177; | |
| --line:#dfe3d9; --raise:#fafbf7; | |
| --gauge:#37734a; --gauge-soft:#e2ede3; | |
| --alarm:#b0402a; --alarm-soft:#f6e2dc; | |
| --t0:#264f6e; --t1:#a8763a; --t2:#8a5a7a; | |
| --t0-soft:#dbe6ef; --t1-soft:#f2e6d3; --t2-soft:#ece0eb; | |
| --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace; | |
| --sans:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto, | |
| "Helvetica Neue",Arial,sans-serif; | |
| --w:68ch; | |
| } | |
| @media (prefers-color-scheme:dark){ | |
| :root{--paper:#0e110d; --ink:#e8ece4; --ink-2:#a9b0a4; --ink-3:#767d72; | |
| --line:#242a22; --raise:#151a13; | |
| --gauge:#6fb684; --gauge-soft:#1b2a1f; | |
| --alarm:#e0705a; --alarm-soft:#2c1a16; | |
| --t0:#7aa8cd; --t1:#d5a865; --t2:#bb92b4; | |
| --t0-soft:#1b2a37; --t1-soft:#332714; --t2-soft:#2c1f2b;} | |
| } | |
| :root[data-theme="dark"]{--paper:#0e110d; --ink:#e8ece4; --ink-2:#a9b0a4; | |
| --ink-3:#767d72; --line:#242a22; --raise:#151a13; | |
| --gauge:#6fb684; --gauge-soft:#1b2a1f; --alarm:#e0705a; --alarm-soft:#2c1a16; | |
| --t0:#7aa8cd; --t1:#d5a865; --t2:#bb92b4; | |
| --t0-soft:#1b2a37; --t1-soft:#332714; --t2-soft:#2c1f2b;} | |
| :root[data-theme="light"]{--paper:#f2f4ee; --ink:#12160f; --ink-2:#4a5147; | |
| --ink-3:#7b8177; --line:#dfe3d9; --raise:#fafbf7; | |
| --gauge:#37734a; --gauge-soft:#e2ede3; --alarm:#b0402a; --alarm-soft:#f6e2dc; | |
| --t0:#264f6e; --t1:#a8763a; --t2:#8a5a7a; | |
| --t0-soft:#dbe6ef; --t1-soft:#f2e6d3; --t2-soft:#ece0eb;} | |
| *{box-sizing:border-box} | |
| body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--sans); | |
| font-size:16.5px;line-height:1.6;-webkit-font-smoothing:antialiased} | |
| .page{max-width:var(--w);margin:0 auto;padding:0 24px} | |
| .bleed{max-width:1120px;margin:0 auto;padding:0 24px} | |
| section{padding:8px 0 40px} | |
| h1{font-size:clamp(38px,7vw,66px);line-height:.98;letter-spacing:-.035em; | |
| font-weight:800;margin:0 0 18px;text-wrap:balance} | |
| h2{font-size:clamp(23px,3.4vw,31px);line-height:1.18;letter-spacing:-.02em; | |
| font-weight:750;margin:52px 0 14px;text-wrap:balance} | |
| h3{font-size:18px;letter-spacing:-.01em;font-weight:700;margin:32px 0 8px} | |
| p{margin:0 0 16px} | |
| a{color:var(--gauge);text-underline-offset:3px} | |
| strong{font-weight:680} | |
| .eyebrow{font-family:var(--mono);font-size:11.5px;letter-spacing:.16em; | |
| text-transform:uppercase;color:var(--ink-3);margin:0 0 14px} | |
| .lede{font-size:20px;line-height:1.5;color:var(--ink-2);margin:0 0 26px} | |
| .note{font-size:14.5px;color:var(--ink-2)} | |
| .mono{font-family:var(--mono)} | |
| code{font-family:var(--mono);font-size:.88em;background:var(--raise); | |
| border:1px solid var(--line);border-radius:4px;padding:1px 5px} | |
| /* ---- claim strip ------------------------------------------------------ */ | |
| .claims{display:grid;grid-template-columns:repeat(auto-fit,minmax(168px,1fr)); | |
| gap:1px;background:var(--line);border:1px solid var(--line); | |
| border-radius:8px;overflow:hidden;margin:26px 0 6px} | |
| .claim{background:var(--paper);padding:15px 16px} | |
| .claim b{display:block;font-family:var(--mono);font-size:26px;font-weight:600; | |
| letter-spacing:-.02em;font-variant-numeric:tabular-nums;line-height:1.1} | |
| .claim span{display:block;font-family:var(--mono);font-size:11px; | |
| letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3); | |
| margin-top:6px} | |
| .good{color:var(--gauge)} .bad{color:var(--alarm)} | |
| /* ---- the trace -------------------------------------------------------- */ | |
| figure{margin:26px 0 8px} | |
| figcaption{font-size:13.5px;color:var(--ink-2);margin-top:10px; | |
| font-family:var(--sans)} | |
| .chart{width:100%;height:auto;display:block;background:var(--raise); | |
| border:1px solid var(--line);border-radius:8px} | |
| /* ---- token stripe ----------------------------------------------------- */ | |
| .stripe{display:flex;gap:2px;flex-wrap:wrap;margin:14px 0 6px} | |
| .cell{width:11px;height:22px;border-radius:2px} | |
| .c-tier0{background:var(--t0)} .c-tier1{background:var(--t1)} | |
| .c-tier2{background:var(--t2)} .c-dead{background:var(--alarm);opacity:.35} | |
| .key{display:flex;gap:16px;flex-wrap:wrap;font-family:var(--mono); | |
| font-size:11.5px;letter-spacing:.06em;color:var(--ink-2);margin-top:8px} | |
| .key i{display:inline-block;width:10px;height:10px;border-radius:2px; | |
| margin-right:6px;vertical-align:-1px} | |
| /* ---- tables ----------------------------------------------------------- */ | |
| .scroll{overflow-x:auto;border:1px solid var(--line);border-radius:8px; | |
| background:var(--raise)} | |
| table{border-collapse:collapse;width:100%;font-family:var(--mono); | |
| font-size:13px;font-variant-numeric:tabular-nums} | |
| th,td{padding:9px 13px;text-align:right;white-space:nowrap; | |
| border-bottom:1px solid var(--line)} | |
| th:first-child,td:first-child{text-align:left} | |
| thead th{font-size:10.5px;letter-spacing:.09em;text-transform:uppercase; | |
| color:var(--ink-3);font-weight:600;position:sticky;top:0; | |
| background:var(--raise)} | |
| tbody tr:last-child td{border-bottom:none} | |
| tr.hero td{background:var(--gauge-soft)} | |
| tr.dead td{color:var(--ink-2)} | |
| tr.dead td:first-child::after{content:" ✕";color:var(--alarm)} | |
| /* ---- ladder ----------------------------------------------------------- */ | |
| .ladder{display:grid;gap:8px;margin:18px 0} | |
| .rung{display:grid;grid-template-columns:auto 1fr auto;gap:14px; | |
| align-items:center;border:1px solid var(--line);border-radius:8px; | |
| padding:12px 14px;background:var(--raise)} | |
| .rung .tag{font-family:var(--mono);font-size:11px;letter-spacing:.09em; | |
| text-transform:uppercase;padding:3px 8px;border-radius:999px; | |
| color:var(--paper)} | |
| .rung .bar{height:9px;border-radius:5px;background:var(--line);overflow:hidden} | |
| .rung .bar>i{display:block;height:100%} | |
| .rung .mb{font-family:var(--mono);font-size:13px; | |
| font-variant-numeric:tabular-nums;color:var(--ink-2)} | |
| /* ---- misc ------------------------------------------------------------- */ | |
| ol,ul{margin:0 0 16px;padding-left:22px} | |
| li{margin:0 0 8px} | |
| hr{border:none;border-top:1px solid var(--line);margin:44px 0} | |
| .foot{font-size:13.5px;color:var(--ink-3);font-family:var(--mono); | |
| padding:8px 0 60px;line-height:1.7} | |
| .callout{border-left:3px solid var(--gauge);background:var(--gauge-soft); | |
| padding:14px 18px;border-radius:0 8px 8px 0;margin:22px 0; | |
| font-size:15.5px} | |
| .callout.warn{border-left-color:var(--alarm);background:var(--alarm-soft)} | |
| @media (prefers-reduced-motion:no-preference){ | |
| .reveal{animation:rise .5s cubic-bezier(.2,.7,.3,1) both} | |
| @keyframes rise{from{opacity:0;transform:translateY(7px)}to{opacity:1;transform:none}} | |
| } | |
| .player{background:var(--raise);border:1px solid var(--line);border-radius:10px; | |
| padding:20px 22px;margin:26px 0 8px} | |
| .player .out{line-height:2.1;font-size:17.5px;min-height:132px;margin-bottom:14px} | |
| .player .tok{border-radius:2px;padding:2px 0} | |
| .player .mig{display:inline-block;font-family:var(--mono);font-size:11px; | |
| font-weight:600;border:1px dashed currentColor;border-radius:999px; | |
| padding:1px 9px;margin:0 6px;white-space:nowrap} | |
| .player .bar{height:10px;border-radius:5px;background:var(--line);position:relative; | |
| overflow:hidden;margin:6px 0 4px} | |
| .player .bar>.use{height:100%;transition:width .18s linear,background .18s} | |
| .player .bar>.bud{position:absolute;top:0;bottom:0;border-right:2px solid var(--alarm)} | |
| .player .row{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:12px} | |
| .player button{font:600 14px/1 var(--sans);color:var(--paper);background:var(--gauge); | |
| border:none;border-radius:8px;padding:10px 18px;cursor:pointer} | |
| .player button.ghost{background:transparent;color:var(--ink); | |
| border:1px solid var(--line)} | |
| .player .meta{font-family:var(--mono);font-size:12px;color:var(--ink-3)} | |
| .player input[type=range]{accent-color:var(--gauge)} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="page reveal"> | |
| <p class="eyebrow">On-device inference · research prototype</p> | |
| <h1>Molt</h1> | |
| <p class="lede">A generation that runs out of memory mid-answer does not have to die, and does not have to start over. Molt moves it onto a smaller model <em>between two tokens</em> and carries the KV cache across — the animal walks out of the shell.</p> | |
| <div class="claims"> | |
| <div class="claim"><b class="bad">5</b><span>kills · always-large</span></div> | |
| <div class="claim"><b class="good">0</b><span>kills · Molt</span></div> | |
| <div class="claim"><b>4.0×</b><span>cheaper switch than restart</span></div> | |
| </div> | |
| <div class="claims" style="margin-top:1px"> | |
| <div class="claim"><b>5.1×</b><span>transplant vs re-prefill</span></div> | |
| <div class="claim"><b class="good">-166</b><span>MiB over budget · 3 tenants</span></div> | |
| </div> | |
| <p class="note">Measured on qwen2.5-1.5b-ladder, cpu / float32, 5 prompts per condition, identical pressure trace for every condition.</p> | |
| </div> | |
| <div class="bleed"><figure> | |
| <div class="player" id="molt-player"> | |
| <div class="out" id="mp-out"><em style="opacity:.55">press play</em></div> | |
| <div class="bar"><i class="use" id="mp-use" style="display:block;width:0%"></i> | |
| <span class="bud" id="mp-bud" style="left:100%"></span></div> | |
| <div class="meta" id="mp-meta"> </div> | |
| <div class="row"> | |
| <button id="mp-play">Play</button> | |
| <button class="ghost" id="mp-reset">Reset</button> | |
| <label class="meta">speed | |
| <input id="mp-speed" type="range" min="1" max="8" step="1" value="3"></label> | |
| <span class="meta" id="mp-speedv">3x</span> | |
| </div> | |
| </div> | |
| <script id="mp-data" type="application/json">{"events":[{"type":"start","tier":"tier0","prompt_tokens":17,"ttft_ms":4418.8,"t":4.4214,"budget_mb":9422.1,"in_use_mb":5889.8},{"type":"token","text":" An","tier":"tier0","t":4.4274,"budget_mb":9422.1,"in_use_mb":5889.8},{"type":"token","text":" operating","tier":"tier0","t":5.0795,"budget_mb":9422.1,"in_use_mb":5889.9},{"type":"token","text":" system","tier":"tier0","t":5.2842,"budget_mb":9422.1,"in_use_mb":5890.0},{"type":"token","text":" re","tier":"tier0","t":5.434,"budget_mb":9422.1,"in_use_mb":5890.0},{"type":"token","text":"claims","tier":"tier0","t":5.6368,"budget_mb":9422.1,"in_use_mb":5890.1},{"type":"token","text":" memory","tier":"tier0","t":5.7848,"budget_mb":9422.1,"in_use_mb":5890.1},{"type":"token","text":" from","tier":"tier0","t":5.9344,"budget_mb":9422.1,"in_use_mb":5890.2},{"type":"token","text":" background","tier":"tier0","t":6.0845,"budget_mb":9422.1,"in_use_mb":5890.3},{"type":"token","text":" processes","tier":"tier0","t":6.2351,"budget_mb":9422.1,"in_use_mb":5890.3},{"type":"token","text":" to","tier":"tier0","t":6.3795,"budget_mb":2473.9,"in_use_mb":5890.4},{"type":"migration","from":"tier0","to":"tier1","at_token":10,"cost_ms":261.4,"flops_saved":0.786,"t":8.7191,"budget_mb":2473.9,"in_use_mb":2144.4},{"type":"token","text":" free","tier":"tier1","t":8.7219,"budget_mb":2473.9,"in_use_mb":2144.4},{"type":"token","text":" up","tier":"tier1","t":9.7707,"budget_mb":2473.9,"in_use_mb":2144.5},{"type":"token","text":" resources","tier":"tier1","t":10.7872,"budget_mb":2473.9,"in_use_mb":2144.5},{"type":"token","text":" and","tier":"tier1","t":11.8407,"budget_mb":2473.9,"in_use_mb":2144.6},{"type":"migration","from":"tier1","to":"tier2","at_token":14,"cost_ms":31.1,"flops_saved":0.743,"t":13.9425,"budget_mb":2473.9,"in_use_mb":1885.4},{"type":"token","text":" free","tier":"tier2","t":13.945,"budget_mb":2473.9,"in_use_mb":1885.4},{"type":"token","text":" up","tier":"tier2","t":14.0032,"budget_mb":2473.9,"in_use_mb":1885.4},{"type":"token","text":" resources","tier":"tier2","t":14.0616,"budget_mb":2473.9,"in_use_mb":1885.5},{"type":"token","text":" for","tier":"tier2","t":14.1139,"budget_mb":2473.9,"in_use_mb":1885.5},{"type":"token","text":" other","tier":"tier2","t":14.1663,"budget_mb":2473.9,"in_use_mb":1885.5},{"type":"token","text":" tasks","tier":"tier2","t":14.2184,"budget_mb":2473.9,"in_use_mb":1885.6},{"type":"token","text":".","tier":"tier2","t":14.2717,"budget_mb":2473.9,"in_use_mb":1885.6},{"type":"token","text":" This","tier":"tier2","t":14.3266,"budget_mb":2473.9,"in_use_mb":1885.6},{"type":"token","text":" is","tier":"tier2","t":14.3855,"budget_mb":2473.9,"in_use_mb":1885.6},{"type":"token","text":" known","tier":"tier2","t":14.4491,"budget_mb":2473.9,"in_use_mb":1885.7},{"type":"token","text":" as","tier":"tier2","t":14.502,"budget_mb":2473.9,"in_use_mb":1885.7},{"type":"token","text":" the","tier":"tier2","t":14.5558,"budget_mb":2473.9,"in_use_mb":1885.7},{"type":"token","text":" principle","tier":"tier2","t":14.6102,"budget_mb":2473.9,"in_use_mb":1885.7},{"type":"token","text":" of","tier":"tier2","t":14.664,"budget_mb":2473.9,"in_use_mb":1885.8},{"type":"token","text":" least","tier":"tier2","t":14.7171,"budget_mb":2473.9,"in_use_mb":1885.8},{"type":"token","text":" privilege","tier":"tier2","t":14.7699,"budget_mb":2473.9,"in_use_mb":1885.8},{"type":"token","text":".","tier":"tier2","t":14.823,"budget_mb":2473.9,"in_use_mb":1885.8},{"type":"token","text":" The","tier":"tier2","t":14.8764,"budget_mb":2473.9,"in_use_mb":1885.9},{"type":"token","text":" principle","tier":"tier2","t":14.9305,"budget_mb":2473.9,"in_use_mb":1885.9},{"type":"token","text":" of","tier":"tier2","t":14.9845,"budget_mb":2473.9,"in_use_mb":1885.9},{"type":"token","text":" least","tier":"tier2","t":15.0376,"budget_mb":2473.9,"in_use_mb":1886.0},{"type":"token","text":" privilege","tier":"tier2","t":15.0912,"budget_mb":2473.9,"in_use_mb":1886.0},{"type":"token","text":" is","tier":"tier2","t":15.1447,"budget_mb":2473.9,"in_use_mb":1886.0},{"type":"token","text":" a","tier":"tier2","t":15.1983,"budget_mb":2473.9,"in_use_mb":1886.0},{"type":"token","text":" security","tier":"tier2","t":15.2517,"budget_mb":2473.9,"in_use_mb":1886.1},{"type":"token","text":" principle","tier":"tier2","t":15.3059,"budget_mb":2473.9,"in_use_mb":1886.1},{"type":"token","text":" that","tier":"tier2","t":15.3594,"budget_mb":2473.9,"in_use_mb":1886.1},{"type":"token","text":" states","tier":"tier2","t":15.4125,"budget_mb":2473.9,"in_use_mb":1886.1},{"type":"token","text":" that","tier":"tier2","t":15.4662,"budget_mb":2473.9,"in_use_mb":1886.2},{"type":"token","text":" only","tier":"tier2","t":15.5188,"budget_mb":2473.9,"in_use_mb":1.6},{"type":"done","text":" An operating system reclaims memory from background processes to free up resources and free up resources for other tasks. This is known as the principle of least privilege. The principle of least privilege is a security principle that states that only","tokens":44,"tiers":["tier0","tier1","tier2"],"killed":false,"migration_ms":292.6,"t":15.5195,"budget_mb":2473.9,"in_use_mb":1.6},{"type":"end","t":15.7145,"budget_mb":2473.9,"in_use_mb":0}]}</script> | |
| <script> | |
| (function(){ | |
| var D=JSON.parse(document.getElementById('mp-data').textContent); | |
| var EV=D.events, T=EV.filter(function(e){return e.type==='token';}); | |
| var M={}; EV.forEach(function(e){ if(e.type==='migration') M[e.at_token]=e; }); | |
| var start=EV.find(function(e){return e.type==='start';})||{}; | |
| var done=EV.find(function(e){return e.type==='done';})||{}; | |
| var COL={tier0:'--t0',tier1:'--t1',tier2:'--t2'}; | |
| var out=document.getElementById('mp-out'), meta=document.getElementById('mp-meta'); | |
| var use=document.getElementById('mp-use'), bud=document.getElementById('mp-bud'); | |
| var btn=document.getElementById('mp-play'), rst=document.getElementById('mp-reset'); | |
| var sp=document.getElementById('mp-speed'), spv=document.getElementById('mp-speedv'); | |
| var TOP=0; EV.forEach(function(e){ if(e.budget_mb>TOP) TOP=e.budget_mb; }); | |
| var i=0,timer=null; | |
| function esc(s){return (s||'').replace(/[&<>]/g,function(c){ | |
| return {'&':'&','<':'<','>':'>'}[c];});} | |
| function paint(){ | |
| var h=''; | |
| for(var k=0;k<i;k++){ | |
| var m=M[k]; | |
| if(m) h+='<span class="mig" style="color:var('+COL[m.to]+')">⇆ '+ | |
| m.from+' → '+m.to+' · '+Math.round(m.cost_ms)+' ms</span>'; | |
| var c='var('+COL[T[k].tier]+')'; | |
| h+='<span class="tok" style="background:color-mix(in srgb,'+c+ | |
| ' 22%,transparent);box-shadow:inset 0 -2px 0 '+c+'">'+esc(T[k].text)+'</span>'; | |
| } | |
| out.innerHTML=h||'<em style="opacity:.55">press play</em>'; | |
| var e=i?T[i-1]:start, b=e.budget_mb||TOP, u=e.in_use_mb||0; | |
| use.style.width=Math.min(100,100*u/TOP)+'%'; | |
| use.style.background=u>b?'var(--alarm)':'var('+(COL[e.tier]||'--gauge')+')'; | |
| bud.style.left=Math.min(100,100*b/TOP)+'%'; | |
| meta.textContent=i?(i+'/'+T.length+' tokens | on '+e.tier+ | |
| ' | '+Math.round(u).toLocaleString()+' MiB in use / '+ | |
| Math.round(b).toLocaleString()+' MiB budget') | |
| :(start.prompt_tokens+' prompt tokens | TTFT '+ | |
| Math.round(start.ttft_ms)+' ms'); | |
| } | |
| function stop(){ if(timer){clearTimeout(timer);timer=null;} btn.textContent='Play'; } | |
| function step(){ | |
| if(i>=T.length){ stop(); | |
| meta.textContent=done.tokens+' tokens | '+ | |
| (done.migrations||Object.keys(M).length)+' migration(s) costing '+ | |
| Math.round(done.migration_ms||0)+' ms | rungs '+ | |
| (done.tiers||[]).join(', ')+' | forced terminations: '+ | |
| (done.killed?1:0); | |
| return; } | |
| var prev=i?T[i-1].t:T[0].t, gap=(T[i].t-prev)*1000/(+sp.value); | |
| i++; paint(); | |
| timer=setTimeout(step, Math.max(35, Math.min(gap, 1400))); | |
| } | |
| btn.onclick=function(){ if(timer){stop();return;} | |
| if(i>=T.length) i=0; btn.textContent='Pause'; step(); }; | |
| rst.onclick=function(){ stop(); i=0; paint(); }; | |
| sp.oninput=function(){ spv.textContent=sp.value+'x'; }; | |
| paint(); | |
| })(); | |
| </script> | |
| <div class="key" style="margin-top:12px"> | |
| <span><i style="background:var(--t0)"></i>tier0</span> | |
| <span><i style="background:var(--t1)"></i>tier1</span> | |
| <span><i style="background:var(--t2)"></i>tier2</span> | |
| <span>the bar is memory: fill = in use, red line = the budget</span> | |
| </div> | |
| <figcaption><strong>One paragraph, three models.</strong> A replay of a recorded session — every token, timestamp and migration cost comes from the raw event stream. The budget is cut mid-sentence; the background colour behind each token is the rung that produced it. Nothing restarts.</figcaption> | |
| </figure></div> | |
| <div class="bleed"> | |
| <figure> | |
| <svg class="chart" viewBox="0 0 1040 330" preserveAspectRatio="xMidYMid meet" role="img" aria-label="Per-token latency for the restart baseline and for Molt across a memory-pressure event"><rect x="222.8" y="18" width="247.1" height="278" fill="var(--alarm-soft)"/><text x="346.3" y="31" font-size="10.5" fill="var(--alarm)" text-anchor="middle" font-family="var(--mono)" letter-spacing="1.2">BUDGET EXCEEDED</text><line x1="58" y1="246.9" x2="1026" y2="246.9" stroke="var(--line)" stroke-width="1"/><text x="50" y="250.4" font-size="10.5" fill="var(--ink-3)" text-anchor="end" font-family="var(--mono)">10 ms</text><line x1="58" y1="160.9" x2="1026" y2="160.9" stroke="var(--line)" stroke-width="1"/><text x="50" y="164.4" font-size="10.5" fill="var(--ink-3)" text-anchor="end" font-family="var(--mono)">100 ms</text><line x1="58" y1="74.9" x2="1026" y2="74.9" stroke="var(--line)" stroke-width="1"/><text x="50" y="78.4" font-size="10.5" fill="var(--ink-3)" text-anchor="end" font-family="var(--mono)">1 s</text><path d="M58.0,291.3 L78.6,141.8 L99.2,141.0 L119.8,144.5 L140.4,144.2 L161.0,142.4 L181.6,139.0 L202.2,143.9 L222.8,26.0 L243.4,69.8 L264.0,71.9 L284.6,71.7 L305.1,72.1 L325.7,72.0 L346.3,72.1 L366.9,69.8 L387.5,72.0 L408.1,71.7 L428.7,72.2 L449.3,72.1 L469.9,57.9 L490.5,177.9 L511.1,176.9 L531.7,180.4 L552.3,180.8 L572.9,181.0 L593.5,180.6 L614.1,180.8 L634.7,181.3 L655.3,180.9 L675.9,180.7 L696.5,180.1 L717.1,181.3 L737.7,181.6 L758.3,180.4 L778.9,181.3 L799.4,182.4 L820.0,44.3 L840.6,143.5 L861.2,143.6 L881.8,144.7 L902.4,144.9 L923.0,145.2 L943.6,145.6 L964.2,144.9 L984.8,144.9 L1005.4,145.0 L1026.0,145.8" fill="none" stroke="var(--t1)" stroke-width="2" stroke-linejoin="round" opacity=".95"/><path d="M58.0,296.0 L78.6,141.3 L99.2,141.2 L119.8,141.7 L140.4,141.0 L161.0,140.6 L181.6,139.9 L202.2,140.3 L222.8,41.1 L243.4,69.9 L264.0,68.7 L284.6,64.9 L305.1,65.2 L325.7,65.5 L346.3,64.4 L366.9,65.2 L387.5,64.5 L408.1,64.6 L428.7,61.1 L449.3,63.3 L469.9,64.2 L490.5,174.5 L511.1,177.1 L531.7,179.9 L552.3,181.1 L572.9,178.0 L593.5,176.0 L614.1,176.7 L634.7,179.1 L655.3,177.9 L675.9,177.1 L696.5,178.7 L717.1,181.5 L737.7,179.9 L758.3,181.0 L778.9,179.1 L799.4,179.6 L820.0,18.0 L840.6,126.9 L861.2,128.0 L881.8,129.0 L902.4,130.5 L923.0,107.2 L943.6,139.2 L964.2,140.4 L984.8,141.1 L1005.4,140.1 L1026.0,141.2" fill="none" stroke="var(--t0)" stroke-width="2.4" stroke-linejoin="round"/><line x1="222.8" y1="18" x2="222.8" y2="296" stroke="var(--t0)" stroke-width="1" stroke-dasharray="3 3" opacity=".55"/><text x="227.8" y="290" font-size="10" fill="var(--t0)" font-family="var(--mono)">tier0→tier1</text><line x1="469.9" y1="18" x2="469.9" y2="296" stroke="var(--t0)" stroke-width="1" stroke-dasharray="3 3" opacity=".55"/><text x="474.9" y="290" font-size="10" fill="var(--t0)" font-family="var(--mono)">tier1→tier2</text><line x1="820.0" y1="18" x2="820.0" y2="296" stroke="var(--t0)" stroke-width="1" stroke-dasharray="3 3" opacity=".55"/><text x="825.0" y="290" font-size="10" fill="var(--t0)" font-family="var(--mono)">tier2→tier0</text><text x="58" y="320" font-size="10.5" fill="var(--ink-3)" font-family="var(--mono)">generated token index →</text><text x="1026" y="32" font-size="11.5" fill="var(--t0)" text-anchor="end" font-family="var(--mono)">D · Molt</text><text x="1026" y="48" font-size="11.5" fill="var(--t1)" text-anchor="end" font-family="var(--mono)">C · restart</text></svg> | |
| <figcaption><strong>The whole argument in one plot.</strong> Per-token latency through the same pressure event. The shaded band is where the memory budget is exceeded. Both arms switch models at the same moment; the restart baseline pays a full re-prefill of the prompt each time, Molt carries the cache across. Log scale.</figcaption> | |
| </figure> | |
| <div class="stripe"><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier1"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier2"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div><div class="cell c-tier0"></div></div> | |
| <div class="key"><span><i style="background:var(--t0)"></i>tier0 · Qwen2.5-1.5B fp32</span><span><i style="background:var(--t1)"></i>tier1 · Qwen2.5-1.5B int8</span><span><i style="background:var(--t2)"></i>tier2 · Qwen2.5-0.5B fp32</span><span>one cell = one generated token, coloured by the model that produced it</span></div> | |
| </div> | |
| <div class="page"> | |
| <h2>The three bad options</h2> | |
| <p>On a phone or a laptop the model shares memory with everything else. When the camera app launches, the OS wants memory back now. An inference process conventionally has three choices, and all three are bad:</p> | |
| <ul><li><strong>Hold the big model.</strong> The process is reclaimed. The answer is lost mid-sentence.</li><li><strong>Always run the small model.</strong> You survive — and pay for it on every request, including the overwhelming majority where there was no pressure at all.</li><li><strong>Switch models and restart the request.</strong> You survive, and the user watches a multi-second stall while the prompt is re-read.</li></ul> | |
| <p>Molt adds a fourth: change the model between two tokens, and take the attention state with you.</p> | |
| <h2>Why per-request model selection cannot fix this</h2> | |
| <p>Every conventional elastic-serving stack picks a model <em>per request</em>. That is useless here, and the reason is structural rather than an implementation detail: a long answer takes tens of seconds, an app launch takes one, so the spike lands <em>inside</em> the answer and the next request boundary is far away in the future. Between the two, the process is holding a footprint the OS has already decided it cannot have.</p> | |
| <div class="callout warn">Measured, not asserted: the same Molt machinery restricted to switching only at request boundaries (<code>D-reqbound</code>) was reclaimed <strong>5 times out of 5 prompts</strong> — the same score as never adapting at all. Allowed to switch mid-stream, the identical code was reclaimed 0 times.</div> | |
| <h2>The ladder</h2> | |
| <p>Three rungs of one model family, sharing a tokenizer. Two of the three transplant routes are structurally different problems, which is the point of this particular ladder:</p> | |
| <div class="ladder"> | |
| <div class="rung"><span class="tag" style="background:var(--t0)">tier0</span><div><div style="font-size:14.5px;font-weight:600">Qwen2.5-1.5B fp32</div><div class="note" style="font-size:13px">the rung you want to be on</div><div class="bar" style="margin-top:7px"><i style="width:100.0%;background:var(--t0)"></i></div></div><span class="mb">5,889 MiB</span></div> | |
| <div class="rung"><span class="tag" style="background:var(--t1)">tier1</span><div><div style="font-size:14.5px;font-weight:600">Qwen2.5-1.5B int8</div><div class="note" style="font-size:13px">same weights, lower precision — a diagonal scale re-alignment</div><div class="bar" style="margin-top:7px"><i style="width:36.4%;background:var(--t1)"></i></div></div><span class="mb">2,143 MiB</span></div> | |
| <div class="rung"><span class="tag" style="background:var(--t2)">tier2</span><div><div style="font-size:14.5px;font-weight:600">Qwen2.5-0.5B fp32</div><div class="note" style="font-size:13px">different depth <em>and</em> head_dim — a learned linear projection</div><div class="bar" style="margin-top:7px"><i style="width:32.0%;background:var(--t2)"></i></div></div><span class="mb">1,885 MiB</span></div> | |
| </div> | |
| <p class="note">The pressure trace drops the budget to <strong>2,002 MiB</strong> — well below what tier0 needs (5,889 MiB) — and it does so in two steps, so every rung of the ladder is exercised in a single run. The spike is timed to land mid-answer on purpose.</p> | |
| <h2>Results</h2> | |
| </div> | |
| <div class="bleed"><div class="scroll"><table> | |
| <thead><tr><th>condition</th><th>kills</th><th>worst ITL</th><th>mean ITL</th><th>switches</th><th>switch cost</th><th>handoff JSD</th><th>judge agree</th><th>accuracy</th><th>peak MiB</th></tr></thead><tbody> | |
| <tr class="dead"><td>A · Static-large</td><td>5</td><td>246</td><td>—</td><td>0.0</td><td>0</td><td>—</td><td>—</td><td>0.00</td><td>5,915</td></tr> | |
| <tr class=""><td>B · Static-small</td><td>0</td><td>80</td><td>58</td><td>0.0</td><td>0</td><td>—</td><td>0.750</td><td>0.67</td><td>1,896</td></tr> | |
| <tr class=""><td>C · Restart-on-pressure</td><td>0</td><td>4,528</td><td>655</td><td>2.2</td><td>3,615</td><td>0.0386</td><td>0.975</td><td>1.00</td><td>5,915</td></tr> | |
| <tr class="hero"><td>D · Molt</td><td>0</td><td>4,586</td><td>606</td><td>2.2</td><td>900</td><td>0.2199</td><td>0.817</td><td>1.00</td><td>7,802</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no calibration</td><td>0</td><td>2,561</td><td>567</td><td>2.2</td><td>755</td><td>0.2313</td><td>0.792</td><td>1.00</td><td>5,918</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no learned projection</td><td>0</td><td>3,664</td><td>571</td><td>2.2</td><td>22</td><td>0.1917</td><td>0.717</td><td>1.00</td><td>7,799</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no top-k recompute</td><td>0</td><td>3,708</td><td>664</td><td>2.2</td><td>29</td><td>0.2243</td><td>0.817</td><td>1.00</td><td>7,799</td></tr> | |
| <tr class="dead"><td>D⁻ · Molt, request-boundary only</td><td>5</td><td>210</td><td>—</td><td>0.0</td><td>0</td><td>—</td><td>—</td><td>0.00</td><td>5,918</td></tr> | |
| </tbody></table></div> | |
| <p class="note" style="margin-top:10px">Latencies in milliseconds. <em>Handoff JSD</em> is the divergence between what the outgoing model would have said at the switch position and what the incoming model actually said — lower is a smoother seam. A killed run scores 0 on accuracy rather than dropping out of the average.</p></div> | |
| <div class="page"> | |
| <h2>The trade-off, stated plainly</h2> | |
| <p>Condition C re-reads the prompt on the new model, so its handoff divergence is the irreducible floor: two different models simply disagree by that much about the next token. Molt does not reach that floor.</p> | |
| <div class="claims"> | |
| <div class="claim"><b>0.039</b><span>handoff JSD · re-prefill floor</span></div> | |
| <div class="claim"><b>0.220</b><span>handoff JSD · transplant</span></div> | |
| <div class="claim"><b>4.0×</b><span>faster switch</span></div> | |
| </div> | |
| <p>So the honest summary is a purchase, not a free lunch: a <strong>4.0× cheaper switch</strong> costs <strong>5.7× more distribution discontinuity</strong> at the seam than a full re-prefill would. Most of that gap is the value projection, which is the weakest map in the system.</p> | |
| <div class="callout warn"><strong>And one number that does not move much.</strong> The <em>worst single token</em> is 4,528 ms for restart against 4,586 ms for Molt — nearly the same, because in a cold-start run that token is dominated by <em>loading the destination model from disk</em>, which both strategies pay identically. What Molt removes is the re-prefill on top of it: 3,615 ms → 900 ms. The sweep below isolates that component with both rungs already warm.</div> | |
| </div> | |
| <div class="page"><h2>What a switch costs</h2> | |
| <p>Carrying the cache versus re-reading the prompt, both rungs kept warm so the comparison is about the KV work rather than about model loading, which both strategies pay identically.</p></div> | |
| <div class="bleed"><div class="scroll"><table> | |
| <thead><tr><th>route</th><th>tokens carried</th><th>transplant</th><th>re-prefill</th><th>speed-up</th><th>FLOPs avoided</th></tr></thead><tbody> | |
| <tr><td>tier0->tier2</td><td>128</td><td>54 ms</td><td>262 ms</td><td>4.85×</td><td>74%</td></tr> | |
| <tr><td>tier0->tier2</td><td>256</td><td>93 ms</td><td>415 ms</td><td>4.46×</td><td>74%</td></tr> | |
| <tr><td>tier0->tier2</td><td>512</td><td>180 ms</td><td>793 ms</td><td>4.41×</td><td>74%</td></tr> | |
| <tr><td>tier0->tier2</td><td>1,024</td><td>399 ms</td><td>1,746 ms</td><td>4.38×</td><td>74%</td></tr> | |
| <tr><td>tier0->tier1</td><td>128</td><td>345 ms</td><td>1,696 ms</td><td>4.91×</td><td>79%</td></tr> | |
| <tr><td>tier0->tier1</td><td>256</td><td>421 ms</td><td>2,069 ms</td><td>4.91×</td><td>79%</td></tr> | |
| <tr><td>tier0->tier1</td><td>512</td><td>596 ms</td><td>3,013 ms</td><td>5.06×</td><td>79%</td></tr> | |
| <tr><td>tier0->tier1</td><td>1,024</td><td>985 ms</td><td>4,830 ms</td><td>4.90×</td><td>79%</td></tr> | |
| </tbody></table></div></div> | |
| <div class="page"><h2>Ablations</h2> | |
| <p>Each mechanism removed on its own, same trace, same prompts. Reported as measured, including where a mechanism did not pay for itself — an ablation table that only ever confirms the design is not an ablation table.</p> | |
| <div class="callout warn"><strong>Read the two quality columns together.</strong> Handoff JSD measures the <em>seam</em>, at one position. It is bounded, and it rewards blurring: a map that degrades the cache into a flat distribution can score a <em>lower</em> one-shot divergence while the text falls apart a few tokens later. Judge agreement catches that. Where the two disagree in the table below, agreement is the one to trust.</div></div> | |
| <div class="bleed"><div class="scroll"><table> | |
| <thead><tr><th>arm</th><th>what is removed</th><th>judge agree</th><th>judge ppl</th><th>handoff JSD</th><th>switch cost</th><th>peak MiB</th><th>kills</th></tr></thead><tbody> | |
| <tr class="hero"><td>D · Molt</td><td>— (full system)</td><td>0.817</td><td>3.09</td><td>0.2199</td><td>900 ms</td><td>7,802</td><td>0</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no calibration</td><td>logit blending (core #3)</td><td>0.792</td><td>3.69</td><td>0.2313</td><td>755 ms</td><td>5,918</td><td>0</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no learned projection</td><td>learned projection + RoPE sandwich (core #1i, and with it the top-k recompute, which needs a learned map)</td><td>0.717</td><td>24.14</td><td>0.1917</td><td>22 ms</td><td>7,799</td><td>0</td></tr> | |
| <tr class=""><td>D⁻ · Molt, no top-k recompute</td><td>top-k native recompute (core #1iii)</td><td>0.817</td><td>3.21</td><td>0.2243</td><td>29 ms</td><td>7,799</td><td>0</td></tr> | |
| <tr class=""><td>D⁻ · Molt, request-boundary only</td><td>the ability to switch mid-stream (core #2)</td><td>—</td><td>—</td><td>—</td><td>0 ms</td><td>5,918</td><td>5</td></tr> | |
| </tbody></table></div></div> | |
| <div class="page"> | |
| <h2>How the cache crosses</h2> | |
| <p>HuggingFace caches keys <em>after</em> RoPE. Two rungs with different <code>head_dim</code> rotate by different angles, so no position-independent matrix can map one cache onto the other — the required map would depend on each token's absolute position. Molt therefore sandwiches the learned matrix between an un-rotation at the source's angles and a re-rotation at the destination's. That one detail is what makes a cross-size transplant well-posed at all.</p> | |
| <p>Three mechanisms, fitted offline by closed-form ridge regression on a few thousand tokens of generic text:</p> | |
| <ol><li><strong>A learned linear projection</strong> per destination layer, inside the RoPE sandwich, plus a depth remap.</li><li><strong>A diagonal scale re-alignment</strong> when the rungs share weights and differ only in precision.</li><li><strong>Selective top-k recompute</strong>: the destination's last few layers are recomputed natively from a projected boundary hidden state, rather than projected. Verified bit-exact against a full forward pass.</li></ol> | |
| <p class="note">Held-out fit residuals (relative RMS, on windows the map never saw):</p> | |
| <div class="scroll"><table><thead><tr><th>route</th><th>map</th><th>K</th><th>V</th><th>hidden</th></tr></thead><tbody> | |
| <tr><td>tier0->tier1</td><td>diag</td><td>0.013</td><td>0.028</td><td>0.006</td></tr> | |
| <tr><td>tier0->tier2</td><td>dense</td><td>0.185</td><td>0.424</td><td>0.077</td></tr> | |
| <tr><td>tier1->tier0</td><td>diag</td><td>0.013</td><td>0.028</td><td>0.006</td></tr> | |
| <tr><td>tier1->tier2</td><td>dense</td><td>0.185</td><td>0.424</td><td>0.077</td></tr> | |
| <tr><td>tier2->tier0</td><td>dense</td><td>0.295</td><td>0.604</td><td>0.054</td></tr> | |
| <tr><td>tier2->tier1</td><td>dense</td><td>0.295</td><td>0.604</td><td>0.054</td></tr> | |
| </tbody></table></div> | |
| <p class="note">The value map is the weak one, and most of the residual post-migration quality gap lives there.</p> | |
| <div class="callout">Worth one measurement, because the ablation table above looks contradictory at first: against a naive truncated map, the fitted projection has a <em>higher</em> handoff JSD but far better text. Running both through the same prefix (<code>scripts/diagnose_projection.py</code>) shows why — the naive map's cache has a reconstruction error of <strong>1.31</strong> (worse than predicting zeros) and induces attention <strong>11.4×</strong> flatter than the destination model's own, against <strong>1.5×</strong> for the fitted map. That flatness is exactly the blur that flatters a bounded divergence.</div> | |
| <h2>Three tenants, one budget, nobody killed</h2> | |
| <p>A foreground conversation and two background batch jobs share one moving budget. The scheduler has four levers, applied <em>synchronously, before anyone takes a step</em>, in order of increasing harm: defer admission, demote a rung, park the weights while keeping the cache, and finally shed the oldest context. Terminating is not on the list.</p> | |
| <div class="claims"> | |
| <div class="claim"><b class="good">0</b><span>forced terminations</span></div> | |
| <div class="claim"><b class="good">-166</b><span>MiB max overshoot</span></div> | |
| <div class="claim"><b>6</b><span>demotions</span></div> | |
| <div class="claim"><b>3</b><span>parks</span></div> | |
| </div> | |
| <p class="note">Max overshoot is <code>max over time of (usage − budget)</code>, sampled after enforcement at every scheduling round. Negative means the budget was never exceeded.</p> | |
| <h2>It runs as a service</h2> | |
| <p>The prototype ships a streaming server whose elasticity is visible on the wire: every token event names the rung that produced it, and a switch arrives as its own event rather than as a surprise. Below is a real session — not a mock-up — with the budget cut to 2651 MiB eight tokens into the answer.</p> | |
| <pre style="font-family:var(--mono);font-size:12.5px;line-height:1.65;background:var(--raise);border:1px solid var(--line);border-radius:8px;padding:16px;overflow-x:auto"><code>[start on tier0 · 17 prompt tokens · TTFT 3122 ms] | |
| An operating system reclaims memory from background | |
| <b>[budget cut to 2651 MiB]</b> | |
| processes | |
| <b>⇆ tier0 → tier1 (molt, 260 ms, 79% FLOPs saved, pressure 0.81)</b> | |
| to free up resources and improve system performance. When a process is | |
| no longer actively using memory, the operating system can reclaim that | |
| memory for other processes or applications | |
| [done: 40 tokens · rungs used tier0, tier1 · 1 migration costing 260 ms · killed=False]</code></pre> | |
| <p>The sentence <em>“…reclaims memory from background processes to free up resources…”</em> is written by two different models. The word before the switch and the word after it are separated by a 260 ms migration and nothing else — no re-prefill, no restart, no dropped connection.</p> | |
| <h2>What this does not show</h2> | |
| <p>Stated plainly, because a prototype that hides its edges is worth less than one that marks them.</p> | |
| <ul><li>The <strong>INT8 rung buys memory, not speed.</strong> bitsandbytes is CUDA-only, so the portable fallback dequantises on use: prefill is slightly faster than fp32, single-token decode is roughly 4× slower. A tuned kernel removes this; the memory result stands either way.</li><li><strong>The value projection is weak</strong> compared with the key projection, and up-shifts (expanding a cache) are harder than down-shifts. Per-head or low-rank non-linear maps are the obvious next step.</li><li><strong>Cross-family migration is not supported.</strong> Every rung must share a tokenizer; the loader refuses otherwise.</li><li>The budget is <strong>simulated by default</strong> for reproducibility. A real allocating child process is available and gives the same qualitative result, noisier.</li><li>Server-side cache sharing and weight streaming from flash are <strong>deliberately out of scope</strong>: this is about on-device multi-tenancy and mid-generation migration.</li><li>Three metrics were <strong>discarded</strong> during the work for measuring nothing — step-to-step JSD (saturated at <code>ln 2</code> on real text), judge perplexity alone (rewards degenerate repetition), and a single-needle recall task (every condition scored 1.00, including the ones that were killed). The replacements are what the table reports.</li></ul> | |
| <hr> | |
| <p class="foot">Molt · elastic on-device inference · research prototype<br>Every number on this page is read directly from the benchmark's own output; the page is generated, not transcribed.<br>Ladder qwen2.5-1.5b-ladder · cpu · trace spike_mid_answer</p> | |
| </div> | |
| </body> | |
| </html> | |