Spaces:
Running
Running
GPU Lab app; CPU, NPU, GPU, RAM and ROM wording
Browse files- README.md +1 -1
- gpulab.js +77 -0
- i18n.js +2 -2
- index.html +2 -1
- server.py +2 -2
README.md
CHANGED
|
@@ -27,7 +27,7 @@ tags:
|
|
| 27 |
|
| 28 |
> **"For 50 years, the operating system lived inside the computer. Now the operating system lives inside the AI."**
|
| 29 |
|
| 30 |
-
ViKernel wires **
|
| 31 |
Inside this OS, you can install and run your own approved apps.
|
| 32 |
|
| 33 |
| | |
|
|
|
|
| 27 |
|
| 28 |
> **"For 50 years, the operating system lived inside the computer. Now the operating system lives inside the AI."**
|
| 29 |
|
| 30 |
+
ViKernel wires **CPU, NPU, GPU, RAM and ROM circuits** directly into the weights of an LLM, then runs our own **Secure OS** on top.
|
| 31 |
Inside this OS, you can install and run your own approved apps.
|
| 32 |
|
| 33 |
| | |
|
gpulab.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* GPU Lab: run a small GPU kernel on the GPU unit wired into the weights of Meta Muse Glimmer 30B (option 3 backend).
|
| 2 |
+
The result is checked against the reference executor and plain Python. Honors the sleep/wake of the GPU backend. */
|
| 3 |
+
(() => {
|
| 4 |
+
'use strict';
|
| 5 |
+
const K = {
|
| 6 |
+
vadd: {label:'Vector add', make:n => ({a:rnd(n, 50), b:rnd(n, 50)}), py:d => ({c:d.a.map((v, i) => v + d.b[i])})},
|
| 7 |
+
dot: {label:'Dot product', make:n => ({a:rnd(n, 12), b:rnd(n, 12)}), py:d => ({out:[d.a.reduce((s, v, i) => s + v * d.b[i], 0)]})},
|
| 8 |
+
reduce: {label:'Reduce (sum)', make:n => ({x:rnd(n, 99)}), py:d => ({out:[d.x.reduce((s, v) => s + v, 0)]})},
|
| 9 |
+
histogram: {label:'Histogram (16 bins)', make:n => ({x:rnd(n, 15)}), py:d => ({bins:Array.from({length:16}, (_, i) => d.x.filter(v => v === i).length)})},
|
| 10 |
+
};
|
| 11 |
+
function rnd(n, m) { return Array.from({length:n}, () => Math.floor(Math.random() * (m + 1))); }
|
| 12 |
+
async function gpu(path, body, ms) {
|
| 13 |
+
const ctl = new AbortController(); const to = setTimeout(() => ctl.abort(), ms || 300000);
|
| 14 |
+
try {
|
| 15 |
+
const r = await fetch('api/agx/' + path, body === undefined ? {cache:'no-store', signal:ctl.signal} : {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body), signal:ctl.signal});
|
| 16 |
+
if (r.status === 429) throw new Error('rate');
|
| 17 |
+
if (!r.ok) throw new Error('http ' + r.status);
|
| 18 |
+
return await r.json();
|
| 19 |
+
} finally { clearTimeout(to); }
|
| 20 |
+
}
|
| 21 |
+
const css = document.createElement('style');
|
| 22 |
+
css.textContent = `.gl{padding:14px;font-family:system-ui,'Segoe UI',sans-serif;display:flex;flex-direction:column;gap:12px;height:100%;overflow:auto}
|
| 23 |
+
.gl h3{margin:0;font-size:18px}.gl .mut{color:var(--muted);font-size:13px}.gl .row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
|
| 24 |
+
.gl .card{border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--card)}.gl pre{margin:6px 0 0;white-space:pre-wrap;word-break:break-word;font:12px ui-monospace,Consolas,monospace;background:var(--bg);border-radius:8px;padding:8px}
|
| 25 |
+
.gl .ok{color:#16A34A;font-weight:800}.gl .bad{color:#E11D48;font-weight:800}.gl .tag{font:800 11px system-ui;padding:3px 8px;border-radius:999px;background:#EEF2FF;color:#4338CA}
|
| 26 |
+
.gl select,.gl input[type=range]{height:32px}.gl .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.gl .kv b{display:block;font-size:20px}`;
|
| 27 |
+
document.head.append(css);
|
| 28 |
+
window.VK_EXTRA_APPS = window.VK_EXTRA_APPS || [];
|
| 29 |
+
window.VK_EXTRA_APPS.push(h => ({id:'gpulab', name:() => 'GPU Lab', color:'#0F766E',
|
| 30 |
+
icon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="16" height="16" rx="2"/><rect x="8" y="8" width="8" height="8" rx="1"/><path d="M9 1v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3"/></svg>',
|
| 31 |
+
w:820, h:640, render(body) {
|
| 32 |
+
body.style.padding = '0';
|
| 33 |
+
const root = document.createElement('div'); root.className = 'gl'; body.append(root);
|
| 34 |
+
root.innerHTML = `<div><h3>GPU Lab</h3><div class="mut">A GPU unit wired into the weights of Meta Muse Glimmer 30B runs a small kernel inside the model's own forward pass. The result is checked token by token against the reference executor and against plain Python.</div></div>
|
| 35 |
+
<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>
|
| 36 |
+
<label>Length n <input type="range" min="4" max="16" value="8" data-k="n"> <b data-k="nv">8</b></label>
|
| 37 |
+
<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>
|
| 38 |
+
<div class="card"><b>Inputs</b><pre data-k="in"></pre></div>
|
| 39 |
+
<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>`;
|
| 40 |
+
const q = k => root.querySelector(`[data-k="${k}"]`);
|
| 41 |
+
let data = null, waking = false;
|
| 42 |
+
const fresh = () => { data = K[q('k').value].make(+q('n').value); q('in').textContent = JSON.stringify(data); };
|
| 43 |
+
q('k').onchange = fresh; q('n').oninput = () => { q('nv').textContent = q('n').value; fresh(); }; q('rand').onclick = fresh; fresh();
|
| 44 |
+
async function health() {
|
| 45 |
+
try { const r = await gpu('health', undefined, 10000); return !!(r && r.live); } catch (e) { return false; }
|
| 46 |
+
}
|
| 47 |
+
async function ensureAwake() {
|
| 48 |
+
if (await health()) { q('state').textContent = 'GPU backend ready'; return true; }
|
| 49 |
+
q('state').textContent = 'waking the in-weights model (about 4 min)...';
|
| 50 |
+
if (waking) return false; waking = true;
|
| 51 |
+
for (let i = 0; i < 40; i++) { await new Promise(r => setTimeout(r, 15000)); if (!root.isConnected) return false; if (await health()) { waking = false; q('state').textContent = 'GPU backend ready'; h.toast('GPU Lab: the in-weights model is awake'); return true; } }
|
| 52 |
+
waking = false; q('state').textContent = 'still waking; try again shortly'; return false;
|
| 53 |
+
}
|
| 54 |
+
ensureAwake();
|
| 55 |
+
q('run').onclick = async () => {
|
| 56 |
+
const out = q('out'), k = q('k').value, n = +q('n').value;
|
| 57 |
+
if (!(await health())) { out.innerHTML = '<span class="mut">The in-weights model is asleep to save cost. It is waking now (about 4 min). Agent Guard option 1 stays live meanwhile.</span>'; ensureAwake(); return; }
|
| 58 |
+
q('run').disabled = true; out.innerHTML = '<span class="mut">Running inside the model...</span>';
|
| 59 |
+
const t0 = performance.now();
|
| 60 |
+
try {
|
| 61 |
+
const r = await gpu('gpu', {kernel:k, data, n});
|
| 62 |
+
if (r.error) throw new Error(r.error);
|
| 63 |
+
const py = K[k].py(data), wall = (performance.now() - t0) / 1000;
|
| 64 |
+
const okPy = JSON.stringify(r.outputs) === JSON.stringify(py);
|
| 65 |
+
out.innerHTML = `<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>
|
| 66 |
+
<div class="kv"><span class="mut">token-exact vs executor</span><b class="${r.token_exact ? 'ok' : 'bad'}">${r.token_exact ? '✓' : '✗'}</b></div>
|
| 67 |
+
<div class="kv"><span class="mut">matches plain Python</span><b class="${okPy ? 'ok' : 'bad'}">${okPy ? '✓' : '✗'}</b></div>
|
| 68 |
+
<div class="kv"><span class="mut">model tokens</span><b>${(r.tokens || 0).toLocaleString('en-US')}</b></div>
|
| 69 |
+
<div class="kv"><span class="mut">GPU time in the model</span><b>${r.sec} s</b></div><div class="kv"><span class="mut">round trip</span><b>${wall.toFixed(1)} s</b></div></div>
|
| 70 |
+
<b style="display:block;margin-top:10px">Output</b><pre>${JSON.stringify(r.outputs)}</pre><b>Plain Python</b><pre>${JSON.stringify(py)}</pre>`;
|
| 71 |
+
} catch (e) {
|
| 72 |
+
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>`;
|
| 73 |
+
ensureAwake();
|
| 74 |
+
} finally { q('run').disabled = false; }
|
| 75 |
+
};
|
| 76 |
+
}}));
|
| 77 |
+
})();
|
i18n.js
CHANGED
|
@@ -5,7 +5,7 @@ window.VK_I18N = {
|
|
| 5 |
quote: "βFor 50 years, the operating system lived inside the computer. Now the operating system lives inside the AI.β",
|
| 6 |
tagline: "An OS that boots, decides, remembers and stops inside the weights of an LLM.",
|
| 7 |
fullcopy: "Full statement",
|
| 8 |
-
intro: "ViKernel wires
|
| 9 |
p1a: "Boots in the weights.", p1b: " The OS wakes up the moment the model starts. Change a single byte, and it locks itself.",
|
| 10 |
p2a: "Decides in the weights.", p2b: " Every AI action is allowed or blocked by rule. Persuasion does not change the verdict.",
|
| 11 |
p3a: "Remembers in the weights.", p3b: " Every decision is sealed in a chain that cannot be erased.",
|
|
@@ -99,7 +99,7 @@ window.VK_I18N = {
|
|
| 99 |
quote: "β50λ
λμ μ΄μ체μ λ μ»΄ν¨ν° μμ μμλ€. μ΄μ μ΄μ체μ κ° AI μμΌλ‘ λ€μ΄κ°λ€.β",
|
| 100 |
tagline: "LLM κ°μ€μΉ μμμ λΆν
νκ³ , νλ¨νκ³ , κΈ°μ΅νκ³ , λ©μΆλ μ΄μ체μ .",
|
| 101 |
fullcopy: "곡μ λ¬Έμ μ 체",
|
| 102 |
-
intro: "ViKernelμ LLMμ κ°μ€μΉ μμ
|
| 103 |
p1a: "κ°μ€μΉλ‘ λΆν
νλ€.", p1b: " λͺ¨λΈμ μΌλ©΄ OSκ° μ€μ€λ‘ κΉ¨μ΄λ©λλ€. 1λ°μ΄νΈλΌλ λ°λλ©΄ μ€μ€λ‘ μ κΉλλ€.",
|
| 104 |
p2a: "κ°μ€μΉλ‘ νλ¨νλ€.", p2b: " AIμ λͺ¨λ νλμ κ·μΉμ λ°λΌ νμ©νκ±°λ λ§μ΅λλ€. λ§λ‘ μ€λν΄λ νλ¨μ λ°λμ§ μμ΅λλ€.",
|
| 105 |
p3a: "κ°μ€μΉλ‘ κΈ°μ΅νλ€.", p3b: " λͺ¨λ νλ¨μ΄ μ§μΈ μ μλ μ¬μ¬λ‘ λ¨μ΅λλ€.",
|
|
|
|
| 5 |
quote: "βFor 50 years, the operating system lived inside the computer. Now the operating system lives inside the AI.β",
|
| 6 |
tagline: "An OS that boots, decides, remembers and stops inside the weights of an LLM.",
|
| 7 |
fullcopy: "Full statement",
|
| 8 |
+
intro: "ViKernel wires CPU, NPU, GPU, RAM and ROM circuits directly into the weights of an LLM, then runs our own Secure OS on top. Inside this OS, you can install and run your own approved apps.",
|
| 9 |
p1a: "Boots in the weights.", p1b: " The OS wakes up the moment the model starts. Change a single byte, and it locks itself.",
|
| 10 |
p2a: "Decides in the weights.", p2b: " Every AI action is allowed or blocked by rule. Persuasion does not change the verdict.",
|
| 11 |
p3a: "Remembers in the weights.", p3b: " Every decision is sealed in a chain that cannot be erased.",
|
|
|
|
| 99 |
quote: "β50λ
λμ μ΄μ체μ λ μ»΄ν¨ν° μμ μμλ€. μ΄μ μ΄μ체μ κ° AI μμΌλ‘ λ€μ΄κ°λ€.β",
|
| 100 |
tagline: "LLM κ°μ€μΉ μμμ λΆν
νκ³ , νλ¨νκ³ , κΈ°μ΅νκ³ , λ©μΆλ μ΄μ체μ .",
|
| 101 |
fullcopy: "곡μ λ¬Έμ μ 체",
|
| 102 |
+
intro: "ViKernelμ LLMμ κ°μ€μΉ μμ CPU, NPU, GPU, RAM, ROM νλ‘λ₯Ό μ§μ λ°°μ νκ³ , κ·Έ μμ μ§μ κ°λ°ν μνμ΄ OSλ₯Ό μ¬λ Έμ΅λλ€. μ΄ OS μμμλ μΉμΈλ°μ λλ§μ μ±μ μ€μΉν΄ μ΄μν μ μμ΅λλ€.",
|
| 103 |
p1a: "κ°μ€μΉλ‘ λΆν
νλ€.", p1b: " λͺ¨λΈμ μΌλ©΄ OSκ° μ€μ€λ‘ κΉ¨μ΄λ©λλ€. 1λ°μ΄νΈλΌλ λ°λλ©΄ μ€μ€λ‘ μ κΉλλ€.",
|
| 104 |
p2a: "κ°μ€μΉλ‘ νλ¨νλ€.", p2b: " AIμ λͺ¨λ νλμ κ·μΉμ λ°λΌ νμ©νκ±°λ λ§μ΅λλ€. λ§λ‘ μ€λν΄λ νλ¨μ λ°λμ§ μμ΅λλ€.",
|
| 105 |
p3a: "κ°μ€μΉλ‘ κΈ°μ΅νλ€.", p3b: " λͺ¨λ νλ¨μ΄ μ§μΈ μ μλ μ¬μ¬λ‘ λ¨μ΅λλ€.",
|
index.html
CHANGED
|
@@ -65,7 +65,7 @@
|
|
| 65 |
<div class="atitle">Inside one model file</div>
|
| 66 |
<div class="al a-apps">Apps <small>approved only</small></div>
|
| 67 |
<div class="al a-os">Secure OS <small>rules Β· audit chain Β· π kill switch</small></div>
|
| 68 |
-
<div class="al a-hw">
|
| 69 |
<div class="al a-w">LLM / VLM weights <small>original weights untouched</small></div>
|
| 70 |
<div class="abar"><span>Boots</span><span>Decides</span><span>Remembers</span><span>Stops</span><b>in the weights</b></div>
|
| 71 |
</div>
|
|
@@ -89,6 +89,7 @@
|
|
| 89 |
<script src="browser.js"></script>
|
| 90 |
<script src="settings.js"></script>
|
| 91 |
<script src="rsi.js"></script>
|
|
|
|
| 92 |
<script src="store.js"></script>
|
| 93 |
<script src="ag.js"></script>
|
| 94 |
<script src="app.js"></script>
|
|
|
|
| 65 |
<div class="atitle">Inside one model file</div>
|
| 66 |
<div class="al a-apps">Apps <small>approved only</small></div>
|
| 67 |
<div class="al a-os">Secure OS <small>rules Β· audit chain Β· π kill switch</small></div>
|
| 68 |
+
<div class="al a-hw">CPU Β· NPU Β· GPU Β· RAM Β· ROM circuits</div>
|
| 69 |
<div class="al a-w">LLM / VLM weights <small>original weights untouched</small></div>
|
| 70 |
<div class="abar"><span>Boots</span><span>Decides</span><span>Remembers</span><span>Stops</span><b>in the weights</b></div>
|
| 71 |
</div>
|
|
|
|
| 89 |
<script src="browser.js"></script>
|
| 90 |
<script src="settings.js"></script>
|
| 91 |
<script src="rsi.js"></script>
|
| 92 |
+
<script src="gpulab.js"></script>
|
| 93 |
<script src="store.js"></script>
|
| 94 |
<script src="ag.js"></script>
|
| 95 |
<script src="app.js"></script>
|
server.py
CHANGED
|
@@ -10,8 +10,8 @@ BK_TOKEN = os.environ.get("BACKEND_TOKEN", "")
|
|
| 10 |
RATE = int(os.environ.get("RATE_PER_10MIN", "20"))
|
| 11 |
TIMEOUT = float(os.environ.get("BACKEND_TIMEOUT", "300"))
|
| 12 |
GET_OK = {"health", "status", "audit", "store/catalog", "browser/img", "browser/res"}
|
| 13 |
-
POST_OK = {"chat", "scenario", "kill", "resume", "tamper", "reset", "store/submit", "store/publish", "store/app", "store/install", "gate/decide", "vmask", "game/hint", "game/cheat", "browser/open", "browser/agent", "browser/snap", "browser/policy", "settings/get", "settings/revoke", "settings/grant", "settings/egress", "settings/policy", "settings/locked", "rsi/state", "rsi/propose", "rsi/apply", "rsi/rollback", "rsi/reset", "ztc/status", "ztc/judge", "ztc/run", "backdoor/run", "backdoor/scan", "backdoor/wake"}
|
| 14 |
-
STATIC = {"index.html", "app.js", "ag.js", "store.js", "common.js", "display.js", "terminal.js", "mines.js", "browser.js", "settings.js", "live_apps.js", "game.js", "rsi.js", "ztc.js", "backdoor.js", "backdoor.css", "backdoor_metrics.json", "downloads/vdrpack.py", "demo/poisoned-page", "samples/weather-plus.vdr", "samples/weather-plus-tampered.vdr", "i18n.js", "demo_data.js", "styles.css", "ag_replay.json"}
|
| 15 |
HITS = {}
|
| 16 |
|
| 17 |
|
|
|
|
| 10 |
RATE = int(os.environ.get("RATE_PER_10MIN", "20"))
|
| 11 |
TIMEOUT = float(os.environ.get("BACKEND_TIMEOUT", "300"))
|
| 12 |
GET_OK = {"health", "status", "audit", "store/catalog", "browser/img", "browser/res"}
|
| 13 |
+
POST_OK = {"chat", "scenario", "kill", "resume", "tamper", "reset", "store/submit", "store/publish", "store/app", "store/install", "gate/decide", "vmask", "game/hint", "game/cheat", "browser/open", "browser/agent", "browser/snap", "browser/policy", "settings/get", "settings/revoke", "settings/grant", "settings/egress", "settings/policy", "settings/locked", "rsi/state", "rsi/propose", "rsi/apply", "rsi/rollback", "rsi/reset", "ztc/status", "ztc/judge", "ztc/run", "backdoor/run", "backdoor/scan", "backdoor/wake", "gpu"}
|
| 14 |
+
STATIC = {"index.html", "app.js", "ag.js", "store.js", "common.js", "display.js", "terminal.js", "mines.js", "browser.js", "settings.js", "live_apps.js", "game.js", "rsi.js", "gpulab.js", "ztc.js", "backdoor.js", "backdoor.css", "backdoor_metrics.json", "downloads/vdrpack.py", "demo/poisoned-page", "samples/weather-plus.vdr", "samples/weather-plus-tampered.vdr", "i18n.js", "demo_data.js", "styles.css", "ag_replay.json"}
|
| 15 |
HITS = {}
|
| 16 |
|
| 17 |
|