Spaces:
Running
Running
GPU Lab: verify/reference mode toggle + parity line
Browse files
gpulab.js
CHANGED
|
@@ -35,6 +35,7 @@ window.VK_EXTRA_APPS.push(h => ({id:'gpulab', name:() => 'GPU Lab', color:'#0F76
|
|
| 35 |
<div class="note" style="margin-top:8px">Exact and auditable, not a GPU replacement: a real GPU is roughly a trillion times faster in raw throughput.</div></div>
|
| 36 |
<div class="card row"><label>Kernel <select data-k="k">${Object.entries(K).map(([k, v]) => `<option value="${k}">${v.label}</option>`).join('')}</select></label>
|
| 37 |
<label>Length n <input type="range" min="4" max="16" value="8" data-k="n"> <b data-k="nv">8</b></label>
|
|
|
|
| 38 |
<button class="btn" data-k="rand">Random inputs</button><button class="btn pri" data-k="run">Run on the GPU in the weights</button><span class="tag" data-k="state">checking backend...</span></div>
|
| 39 |
<div class="card"><b>Inputs</b><pre data-k="in"></pre></div>
|
| 40 |
<div class="card" data-k="out"><span class="mut">Pick a kernel and press Run. A run takes from a few seconds to about a minute, because every GPU step is computed by the model.</span></div>`;
|
|
@@ -59,15 +60,19 @@ window.VK_EXTRA_APPS.push(h => ({id:'gpulab', name:() => 'GPU Lab', color:'#0F76
|
|
| 59 |
q('run').disabled = true; out.innerHTML = '<span class="mut">Running inside the model...</span>';
|
| 60 |
const t0 = performance.now();
|
| 61 |
try {
|
| 62 |
-
const
|
|
|
|
| 63 |
if (r.error) throw new Error(r.error);
|
| 64 |
const py = K[k].py(data), wall = (performance.now() - t0) / 1000;
|
| 65 |
const okPy = JSON.stringify(r.outputs) === JSON.stringify(py);
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
<div class="kv"><span class="mut">matches plain Python</span><b class="${okPy ? 'ok' : 'bad'}">${okPy ? '✓' : '✗'}</b></div>
|
| 69 |
<div class="kv"><span class="mut">model tokens</span><b>${(r.tokens || 0).toLocaleString('en-US')}</b></div>
|
| 70 |
-
<div class="kv"><span class="mut">GPU time in the model</span><b>${r.sec
|
| 71 |
<b style="display:block;margin-top:10px">Output</b><pre>${JSON.stringify(r.outputs)}</pre><b>Plain Python</b><pre>${JSON.stringify(py)}</pre>`;
|
| 72 |
} catch (e) {
|
| 73 |
out.innerHTML = `<span class="mut">${e.message === 'rate' ? 'Too many requests from your network; try again in a few minutes.' : 'The in-weights model is busy or waking. Please try again in a minute.'}</span>`;
|
|
|
|
| 35 |
<div class="note" style="margin-top:8px">Exact and auditable, not a GPU replacement: a real GPU is roughly a trillion times faster in raw throughput.</div></div>
|
| 36 |
<div class="card row"><label>Kernel <select data-k="k">${Object.entries(K).map(([k, v]) => `<option value="${k}">${v.label}</option>`).join('')}</select></label>
|
| 37 |
<label>Length n <input type="range" min="4" max="16" value="8" data-k="n"> <b data-k="nv">8</b></label>
|
| 38 |
+
<label>Mode <select data-k="mode"><option value="verify">Verify in the weights</option><option value="reference">Reference executor only</option></select></label>
|
| 39 |
<button class="btn" data-k="rand">Random inputs</button><button class="btn pri" data-k="run">Run on the GPU in the weights</button><span class="tag" data-k="state">checking backend...</span></div>
|
| 40 |
<div class="card"><b>Inputs</b><pre data-k="in"></pre></div>
|
| 41 |
<div class="card" data-k="out"><span class="mut">Pick a kernel and press Run. A run takes from a few seconds to about a minute, because every GPU step is computed by the model.</span></div>`;
|
|
|
|
| 60 |
q('run').disabled = true; out.innerHTML = '<span class="mut">Running inside the model...</span>';
|
| 61 |
const t0 = performance.now();
|
| 62 |
try {
|
| 63 |
+
const mode = q('mode').value;
|
| 64 |
+
const r = await gpu('gpu', {kernel:k, data, n, mode});
|
| 65 |
if (r.error) throw new Error(r.error);
|
| 66 |
const py = K[k].py(data), wall = (performance.now() - t0) / 1000;
|
| 67 |
const okPy = JSON.stringify(r.outputs) === JSON.stringify(py);
|
| 68 |
+
const fms = v => v == null ? 'n/a' : (+v).toFixed(1) + ' ms';
|
| 69 |
+
const parity = r.parity == null ? `<div class="note" style="margin-top:8px">Parity: not checked in this mode. Reference executor only, ${fms(r.ms_reference)}.</div>`
|
| 70 |
+
: `<div class="note" style="margin-top:8px">Parity: in-weights ${r.parity ? '✓ equals' : '✗ differs from'} reference. In the weights ${fms(r.ms_verify)}, reference ${fms(r.ms_reference)}.</div>`;
|
| 71 |
+
out.innerHTML = `${parity}<div class="grid"><div class="kv"><span class="mut">exact vs reference</span><b class="${r.equals_reference ? 'ok' : 'bad'}">${r.equals_reference ? '✓ exact' : '✗ differs'}</b></div>
|
| 72 |
+
<div class="kv"><span class="mut">token-exact vs executor</span><b class="${r.token_exact == null ? '' : r.token_exact ? 'ok' : 'bad'}">${r.token_exact == null ? 'n/a' : r.token_exact ? '✓' : '✗'}</b></div>
|
| 73 |
<div class="kv"><span class="mut">matches plain Python</span><b class="${okPy ? 'ok' : 'bad'}">${okPy ? '✓' : '✗'}</b></div>
|
| 74 |
<div class="kv"><span class="mut">model tokens</span><b>${(r.tokens || 0).toLocaleString('en-US')}</b></div>
|
| 75 |
+
<div class="kv"><span class="mut">GPU time in the model</span><b>${r.sec == null ? 'n/a' : r.sec + ' s'}</b></div><div class="kv"><span class="mut">round trip</span><b>${wall.toFixed(1)} s</b></div></div>
|
| 76 |
<b style="display:block;margin-top:10px">Output</b><pre>${JSON.stringify(r.outputs)}</pre><b>Plain Python</b><pre>${JSON.stringify(py)}</pre>`;
|
| 77 |
} catch (e) {
|
| 78 |
out.innerHTML = `<span class="mut">${e.message === 'rate' ? 'Too many requests from your network; try again in a few minutes.' : 'The in-weights model is busy or waking. Please try again in a minute.'}</span>`;
|