Spaces:
Running
Running
feat(frontier): moe+formalmath+ccattest+ringattn surfaces+tabs (organs on killinchu)
Browse filesSurfaces 22-25. Poll killinchu cross-origin. MODELED. Nothing in locked-8; Lambda stays Conjecture 1.
- static/3d/holographic.html +4 -0
- static/3d/surfaces/ccattest.js +422 -0
- static/3d/surfaces/formalmath.js +491 -0
- static/3d/surfaces/moe.js +438 -0
- static/3d/surfaces/ringattn.js +456 -0
- szl3d_holographic.py +4 -0
static/3d/holographic.html
CHANGED
|
@@ -80,6 +80,10 @@ const SURFACES = [
|
|
| 80 |
{ id: "specdecode", title: "Speculative Decoding", mod: "/static/3d/surfaces/specdecode.js" },
|
| 81 |
{ id: "flowmatch", title: "Flow Matching", mod: "/static/3d/surfaces/flowmatch.js" },
|
| 82 |
{ id: "dllm", title: "Diffusion LLM", mod: "/static/3d/surfaces/dllm.js" },
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
{ id: "energy", title: "Energy", mod: "/static/3d/surfaces/energy.js" },
|
| 84 |
{ id: "fabric", title: "Fabric", mod: "/static/3d/surfaces/fabric.js" },
|
| 85 |
{ id: "pnt", title: "PNT", mod: "/static/3d/surfaces/pnt.js" },
|
|
|
|
| 80 |
{ id: "specdecode", title: "Speculative Decoding", mod: "/static/3d/surfaces/specdecode.js" },
|
| 81 |
{ id: "flowmatch", title: "Flow Matching", mod: "/static/3d/surfaces/flowmatch.js" },
|
| 82 |
{ id: "dllm", title: "Diffusion LLM", mod: "/static/3d/surfaces/dllm.js" },
|
| 83 |
+
{ id: "moe", title: "MoE Router", mod: "/static/3d/surfaces/moe.js" },
|
| 84 |
+
{ id: "formalmath", title: "Formal-Math Retrieval", mod: "/static/3d/surfaces/formalmath.js" },
|
| 85 |
+
{ id: "ccattest", title: "Confidential-Compute Attest", mod: "/static/3d/surfaces/ccattest.js" },
|
| 86 |
+
{ id: "ringattn", title: "Ring Attention", mod: "/static/3d/surfaces/ringattn.js" },
|
| 87 |
{ id: "energy", title: "Energy", mod: "/static/3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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/ccattest.js — CONFIDENTIAL-COMPUTE ATTESTATION CHAIN (TEE / NVIDIA H100 CC)
|
| 5 |
+
// organ for the holographic frontier ring. DISTINCT from the L6 chain-of-title receipt
|
| 6 |
+
// organ (governance/provenance/sovereign-compute doctrine) — this is a hardware-
|
| 7 |
+
// attestation hash-chain simulation, not a build/agent-action provenance receipt.
|
| 8 |
+
//
|
| 9 |
+
// Renders a vertical lattice-blue tower of stacked hash-blocks driven by a live
|
| 10 |
+
// deterministic snapshot from /api/killinchu/v1/cc-attest/verify:
|
| 11 |
+
// device_identity (sha384) -> measurement_chain[] (bootloader -> firmware -> driver ->
|
| 12 |
+
// microcode -> gpu-vbios) -> final_digest -> golden_match (bool).
|
| 13 |
+
// Each block in the tower is one measurement-log stage; blocks whose chained digest
|
| 14 |
+
// matches the fixed golden reference glow proof-teal, non-matching/pending blocks are
|
| 15 |
+
// grey. A HUD shows golden_match + a truncated final_digest. Honesty label "MODELED" is
|
| 16 |
+
// read VERBATIM from the JSON and displayed as-is; it is never upgraded.
|
| 17 |
+
//
|
| 18 |
+
// Surface export shape (mirrors testtime.js / neuromorphic.js / interpretability.js):
|
| 19 |
+
// export default { id, title, endpoints, mount(ctx), unmount() }
|
| 20 |
+
// ctx = { stage, container, live, label, THREE, szl3d }
|
| 21 |
+
//
|
| 22 |
+
// DATA SHOWN (all from live endpoint):
|
| 23 |
+
// label, seed, stages, device_identity, measurement_chain[{stage,digest}],
|
| 24 |
+
// final_digest, golden_match, honest_note
|
| 25 |
+
//
|
| 26 |
+
// CONCEPT CITED (clean-room; NOT claimed as SZL's own; NO real GPU/TEE/network used):
|
| 27 |
+
// NVIDIA, "Confidential Computing on H100 GPUs for Secure and Trustworthy AI" (2023):
|
| 28 |
+
// https://developer.nvidia.com/blog/confidential-computing-on-h100-gpus-for-secure-and-trustworthy-ai/
|
| 29 |
+
//
|
| 30 |
+
// HONESTY LABEL: MODELED (deterministic sha256/sha384 hash-chain simulation of the TEE +
|
| 31 |
+
// H100 CC attestation concept; NOT a real TDX/SEV-SNP/NRAS verifier; NEVER-CLAIMED-AS
|
| 32 |
+
// actual hardware attestation). Read verbatim from JSON; never upgraded here.
|
| 33 |
+
// COLOURS: lattice-blue 0x5b8dee (pending/tower body), proof-teal 0x3af4c8 (golden-match
|
| 34 |
+
// glow ring), violet-blue 0x8a6bff (device-identity marker, data-viz only), greys for
|
| 35 |
+
// pending/unverified/degraded. Purple BANNED as UI/background.
|
| 36 |
+
// 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
|
| 37 |
+
// DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
|
| 38 |
+
// Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100% — the
|
| 39 |
+
// attestation is MODELED, not real trust.
|
| 40 |
+
|
| 41 |
+
const ID = "ccattest";
|
| 42 |
+
const TITLE = "Confidential-Compute Attestation Chain · TEE / H100 CC (live)";
|
| 43 |
+
|
| 44 |
+
// Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
|
| 45 |
+
// cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
|
| 46 |
+
const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/cc-attest/verify?seed=42&stages=5";
|
| 47 |
+
|
| 48 |
+
// data-viz hues — purple BANNED
|
| 49 |
+
const C_BLOCK = 0x5b8dee; // lattice-blue (tower block body)
|
| 50 |
+
const C_IDENT = 0x8a6bff; // violet-blue (device-identity marker — data-viz only)
|
| 51 |
+
const C_DIM = 0x42505d; // grey (pending / unverified / no-live-data)
|
| 52 |
+
const C_ACCENT = 0x3af4c8; // proof-teal (golden-match glow ring / HUD accent)
|
| 53 |
+
const C_GRID = 0x1b3a44; // floor / link colour
|
| 54 |
+
|
| 55 |
+
// tower layout geometry
|
| 56 |
+
const BLOCK_H = 1.1; // world-units, height of one hash-block
|
| 57 |
+
const BLOCK_W = 2.2; // world-units, block footprint (X/Z)
|
| 58 |
+
const BLOCK_GAP = 0.22; // world-units, gap between stacked blocks
|
| 59 |
+
const MAX_BLOCKS = 5; // bootloader..gpu-vbios
|
| 60 |
+
|
| 61 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
|
| 62 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null;
|
| 63 |
+
let _plain = false;
|
| 64 |
+
|
| 65 |
+
// geometry handles
|
| 66 |
+
let _blocks = []; // Array<{ mesh: THREE.Mesh, ring: THREE.Mesh }> — stacked hash-blocks
|
| 67 |
+
let _identMarker = null; // THREE.Mesh — device-identity marker (base of tower)
|
| 68 |
+
let _floor = null;
|
| 69 |
+
|
| 70 |
+
// live state
|
| 71 |
+
const S = {
|
| 72 |
+
label: null,
|
| 73 |
+
seed: null,
|
| 74 |
+
stagesReq: null,
|
| 75 |
+
deviceId: null, // device_identity hex
|
| 76 |
+
chain: null, // measurement_chain[]
|
| 77 |
+
finalDigest:null,
|
| 78 |
+
goldenMatch:null, // bool
|
| 79 |
+
honestNote: null,
|
| 80 |
+
state: "init",
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
// =============================================================================
|
| 84 |
+
// mount(ctx)
|
| 85 |
+
// =============================================================================
|
| 86 |
+
export function mount(ctx) {
|
| 87 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 88 |
+
_group = new _THREE.Group();
|
| 89 |
+
_stage.scene.add(_group);
|
| 90 |
+
_stage.camera.position.set(3, 7, 14);
|
| 91 |
+
try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 3, 0); _stage.controls.update(); } } catch (_) {}
|
| 92 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 93 |
+
|
| 94 |
+
_buildFloor();
|
| 95 |
+
_buildIdentMarker();
|
| 96 |
+
_buildTower();
|
| 97 |
+
|
| 98 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 99 |
+
|
| 100 |
+
_badge = ctx.live.createBadge();
|
| 101 |
+
_polls.push(ctx.live.poll(EP, 5000, _onAttest, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
|
| 102 |
+
|
| 103 |
+
_buildOverlay();
|
| 104 |
+
return { id: ID, started: true };
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
// =============================================================================
|
| 108 |
+
// builders
|
| 109 |
+
// =============================================================================
|
| 110 |
+
function _buildFloor() {
|
| 111 |
+
const THREE = _THREE;
|
| 112 |
+
const grid = new THREE.GridHelper(30, 30, C_GRID, 0x0f2027);
|
| 113 |
+
grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
|
| 114 |
+
_group.add(grid);
|
| 115 |
+
_floor = grid;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function _buildIdentMarker() {
|
| 119 |
+
const THREE = _THREE;
|
| 120 |
+
_identMarker = new THREE.Mesh(
|
| 121 |
+
new THREE.OctahedronGeometry(0.4, 0),
|
| 122 |
+
new THREE.MeshStandardMaterial({ color: C_IDENT, emissive: C_IDENT, emissiveIntensity: 0.35, wireframe: true, transparent: true, opacity: 0.85 }),
|
| 123 |
+
);
|
| 124 |
+
_identMarker.position.set(0, 0.35, 0);
|
| 125 |
+
_group.add(_identMarker);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// Pre-allocate MAX_BLOCKS stacked hash-block meshes + glow rings; visibility and
|
| 129 |
+
// colour are updated in-place as live data arrives (no per-poll geometry churn).
|
| 130 |
+
function _buildTower() {
|
| 131 |
+
const THREE = _THREE;
|
| 132 |
+
const boxGeo = new THREE.BoxGeometry(BLOCK_W, BLOCK_H, BLOCK_W);
|
| 133 |
+
const ringGeo = new THREE.TorusGeometry(BLOCK_W * 0.62, 0.05, 8, 24);
|
| 134 |
+
|
| 135 |
+
for (let i = 0; i < MAX_BLOCKS; i++) {
|
| 136 |
+
const y = 0.9 + i * (BLOCK_H + BLOCK_GAP);
|
| 137 |
+
|
| 138 |
+
const mat = new THREE.MeshStandardMaterial({
|
| 139 |
+
color: C_DIM, emissive: C_DIM, emissiveIntensity: 0.15,
|
| 140 |
+
transparent: true, opacity: 0.5, wireframe: false,
|
| 141 |
+
});
|
| 142 |
+
const mesh = new THREE.Mesh(boxGeo, mat);
|
| 143 |
+
mesh.position.set(0, y, 0);
|
| 144 |
+
mesh.visible = false;
|
| 145 |
+
_group.add(mesh);
|
| 146 |
+
|
| 147 |
+
const ringMat = new THREE.MeshBasicMaterial({ color: C_ACCENT, transparent: true, opacity: 0.0 });
|
| 148 |
+
const ring = new THREE.Mesh(ringGeo, ringMat);
|
| 149 |
+
ring.position.set(0, y, 0);
|
| 150 |
+
ring.rotation.x = Math.PI / 2;
|
| 151 |
+
ring.visible = false;
|
| 152 |
+
_group.add(ring);
|
| 153 |
+
|
| 154 |
+
_blocks.push({ mesh, ring, y });
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
// vertical spine (edge lines) connecting block centers, grey, data-viz only
|
| 158 |
+
const spinePts = [];
|
| 159 |
+
for (let i = 0; i < MAX_BLOCKS; i++) spinePts.push(new THREE.Vector3(0, _blocks[i].y, 0));
|
| 160 |
+
const spineGeo = new THREE.BufferGeometry().setFromPoints(spinePts);
|
| 161 |
+
const spine = new THREE.Line(spineGeo, new THREE.LineBasicMaterial({ color: C_GRID, transparent: true, opacity: 0.5 }));
|
| 162 |
+
_group.add(spine);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// =============================================================================
|
| 166 |
+
// live data handler
|
| 167 |
+
// =============================================================================
|
| 168 |
+
function _onAttest(j) {
|
| 169 |
+
// read honesty label VERBATIM — never upgrade
|
| 170 |
+
S.label = (j.label || "MODELED").toUpperCase();
|
| 171 |
+
S.seed = typeof j.seed === "number" ? j.seed : null;
|
| 172 |
+
S.stagesReq = typeof j.stages === "number" ? j.stages : null;
|
| 173 |
+
S.deviceId = typeof j.device_identity === "string" ? j.device_identity : null;
|
| 174 |
+
S.chain = Array.isArray(j.measurement_chain) ? j.measurement_chain : null;
|
| 175 |
+
S.finalDigest = typeof j.final_digest === "string" ? j.final_digest : null;
|
| 176 |
+
S.goldenMatch = typeof j.golden_match === "boolean" ? j.golden_match : null;
|
| 177 |
+
S.honestNote = typeof j.honest_note === "string" ? j.honest_note : null;
|
| 178 |
+
|
| 179 |
+
_updateTower();
|
| 180 |
+
_paintOverlay();
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
// =============================================================================
|
| 184 |
+
// geometry updater — drives the stacked hash-block tower from live data
|
| 185 |
+
// =============================================================================
|
| 186 |
+
function _updateTower() {
|
| 187 |
+
const live = S.state === "live";
|
| 188 |
+
|
| 189 |
+
if (live && S.chain && S.chain.length) {
|
| 190 |
+
const n = Math.min(MAX_BLOCKS, S.chain.length);
|
| 191 |
+
for (let i = 0; i < MAX_BLOCKS; i++) {
|
| 192 |
+
const b = _blocks[i];
|
| 193 |
+
if (i < n) {
|
| 194 |
+
b.mesh.visible = true;
|
| 195 |
+
// Golden-match applies to the CHAIN AS A WHOLE (final_digest comparison);
|
| 196 |
+
// if golden_match is true, light every realized block proof-teal to show
|
| 197 |
+
// the whole verified chain; otherwise blocks stay lattice-blue (present,
|
| 198 |
+
// computed) but the top block + ring signal the mismatch in grey/teal below.
|
| 199 |
+
const isFinal = i === n - 1;
|
| 200 |
+
const verified = S.goldenMatch === true;
|
| 201 |
+
b.mesh.material.color.setHex(verified ? C_ACCENT : C_BLOCK);
|
| 202 |
+
b.mesh.material.emissive.setHex(verified ? C_ACCENT : C_BLOCK);
|
| 203 |
+
b.mesh.material.emissiveIntensity = verified ? 0.55 : 0.25;
|
| 204 |
+
b.mesh.material.opacity = 0.88;
|
| 205 |
+
|
| 206 |
+
b.ring.visible = isFinal;
|
| 207 |
+
if (isFinal) {
|
| 208 |
+
b.ring.material.color.setHex(verified ? C_ACCENT : C_DIM);
|
| 209 |
+
b.ring.material.opacity = verified ? 0.9 : 0.35;
|
| 210 |
+
}
|
| 211 |
+
} else {
|
| 212 |
+
b.mesh.visible = false;
|
| 213 |
+
b.ring.visible = false;
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
} else {
|
| 217 |
+
_blocks.forEach((b) => {
|
| 218 |
+
b.mesh.visible = false;
|
| 219 |
+
b.ring.visible = false;
|
| 220 |
+
});
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if (_identMarker) {
|
| 224 |
+
if (live && S.deviceId) {
|
| 225 |
+
_identMarker.material.color.setHex(C_IDENT);
|
| 226 |
+
_identMarker.material.emissive.setHex(C_IDENT);
|
| 227 |
+
_identMarker.material.opacity = 0.85;
|
| 228 |
+
} else {
|
| 229 |
+
_identMarker.material.color.setHex(C_DIM);
|
| 230 |
+
_identMarker.material.emissive.setHex(C_DIM);
|
| 231 |
+
_identMarker.material.opacity = 0.3;
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
// =============================================================================
|
| 237 |
+
// per-frame animation
|
| 238 |
+
// =============================================================================
|
| 239 |
+
function _onFrame() {
|
| 240 |
+
const t = performance.now();
|
| 241 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00009) * 0.12;
|
| 242 |
+
if (_identMarker) {
|
| 243 |
+
_identMarker.rotation.y += 0.015;
|
| 244 |
+
_identMarker.rotation.x += 0.008;
|
| 245 |
+
}
|
| 246 |
+
// pulse the top (final-digest) glow ring, if visible and golden_match
|
| 247 |
+
for (const b of _blocks) {
|
| 248 |
+
if (b.ring.visible && S.goldenMatch === true) {
|
| 249 |
+
const pulse = 1.0 + 0.12 * Math.sin(t * 0.0035);
|
| 250 |
+
b.ring.scale.setScalar(pulse);
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
// =============================================================================
|
| 256 |
+
// overlay
|
| 257 |
+
// =============================================================================
|
| 258 |
+
function _buildOverlay() {
|
| 259 |
+
const ctx = _ctx;
|
| 260 |
+
_overlay = document.createElement("div");
|
| 261 |
+
Object.assign(_overlay.style, {
|
| 262 |
+
position: "absolute", left: "14px", top: "14px", zIndex: "6",
|
| 263 |
+
display: "flex", flexDirection: "column", gap: "8px",
|
| 264 |
+
maxWidth: "min(94%,440px)",
|
| 265 |
+
font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
|
| 266 |
+
color: "#eef3f6",
|
| 267 |
+
});
|
| 268 |
+
|
| 269 |
+
const h = document.createElement("div");
|
| 270 |
+
h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
|
| 271 |
+
h.textContent = TITLE;
|
| 272 |
+
_overlay.appendChild(h);
|
| 273 |
+
|
| 274 |
+
const sub = document.createElement("div");
|
| 275 |
+
sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
|
| 276 |
+
sub.innerHTML =
|
| 277 |
+
'A deterministic <b>sha256/sha384 hash-chain</b> stand-in for a TEE + ' +
|
| 278 |
+
'<b>NVIDIA H100 Confidential Computing</b>-style measured-boot attestation: ' +
|
| 279 |
+
'device identity \\u2192 ordered stage digests \\u2192 final digest checked ' +
|
| 280 |
+
'against a fixed golden reference. Honesty label <b>MODELED</b> \\u2014 NOT a real ' +
|
| 281 |
+
'TDX/SEV-SNP/NRAS verifier, no real key material, no live GPU, no network. 0 runtime CDN.';
|
| 282 |
+
_overlay.appendChild(sub);
|
| 283 |
+
|
| 284 |
+
const brow = document.createElement("div");
|
| 285 |
+
brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
|
| 286 |
+
if (_badge && _badge.el) brow.appendChild(_badge.el);
|
| 287 |
+
_overlay.appendChild(brow);
|
| 288 |
+
|
| 289 |
+
const card = document.createElement("div");
|
| 290 |
+
card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
|
| 291 |
+
|
| 292 |
+
const chead = document.createElement("div");
|
| 293 |
+
chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
|
| 294 |
+
const dot = document.createElement("span");
|
| 295 |
+
dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#5b8dee;box-shadow:0 0 7px #5b8dee";
|
| 296 |
+
const nm = document.createElement("b");
|
| 297 |
+
nm.style.cssText = "font-size:12px;color:#5b8dee;letter-spacing:.3px";
|
| 298 |
+
nm.textContent = "cc-attest";
|
| 299 |
+
chead.appendChild(dot); chead.appendChild(nm);
|
| 300 |
+
card.appendChild(chead);
|
| 301 |
+
|
| 302 |
+
const grid = document.createElement("div");
|
| 303 |
+
grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
|
| 304 |
+
|
| 305 |
+
function kpiRow(id, label) {
|
| 306 |
+
const r = document.createElement("div");
|
| 307 |
+
r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
|
| 308 |
+
const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
|
| 309 |
+
const v = document.createElement("b");
|
| 310 |
+
v.id = id;
|
| 311 |
+
v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:62%;overflow-wrap:anywhere";
|
| 312 |
+
v.textContent = "\u2014";
|
| 313 |
+
_el[id] = v;
|
| 314 |
+
r.appendChild(l); r.appendChild(v); return r;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
grid.appendChild(kpiRow("cc-seed", "seed"));
|
| 318 |
+
grid.appendChild(kpiRow("cc-stages", "stages (measurement log depth)"));
|
| 319 |
+
grid.appendChild(kpiRow("cc-ident", "device identity (sha384, truncated)"));
|
| 320 |
+
grid.appendChild(kpiRow("cc-final", "final digest (truncated)"));
|
| 321 |
+
grid.appendChild(kpiRow("cc-golden", "golden_match \\u2014 MODELED"));
|
| 322 |
+
grid.appendChild(kpiRow("cc-label", "honesty label"));
|
| 323 |
+
card.appendChild(grid);
|
| 324 |
+
|
| 325 |
+
const fn = document.createElement("div");
|
| 326 |
+
fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
|
| 327 |
+
fn.textContent = "NVIDIA, \"Confidential Computing on H100 GPUs for Secure and Trustworthy AI\" (2023), developer.nvidia.com/blog/confidential-computing-on-h100-gpus-for-secure-and-trustworthy-ai. MODELED \\u00b7 not claimed-as.";
|
| 328 |
+
card.appendChild(fn);
|
| 329 |
+
_overlay.appendChild(card);
|
| 330 |
+
|
| 331 |
+
const pl = document.createElement("button");
|
| 332 |
+
pl.textContent = "\u25d1 what this means";
|
| 333 |
+
pl.title = "Toggle plain-language explanation for investors & consumers.";
|
| 334 |
+
pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
|
| 335 |
+
pl.addEventListener("click", () => {
|
| 336 |
+
_plain = !_plain;
|
| 337 |
+
pl.style.background = _plain ? "#0f2a20" : "#08140f";
|
| 338 |
+
_applyPlain();
|
| 339 |
+
});
|
| 340 |
+
_overlay.appendChild(pl);
|
| 341 |
+
|
| 342 |
+
const pd = document.createElement("div");
|
| 343 |
+
pd.id = "cc-plain";
|
| 344 |
+
pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
|
| 345 |
+
_el["plain"] = pd;
|
| 346 |
+
_overlay.appendChild(pd);
|
| 347 |
+
|
| 348 |
+
(ctx.container || document.body).appendChild(_overlay);
|
| 349 |
+
_paintOverlay();
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
function _applyPlain() {
|
| 353 |
+
const pd = _el["plain"];
|
| 354 |
+
if (!pd) return;
|
| 355 |
+
pd.style.display = _plain ? "block" : "none";
|
| 356 |
+
if (!_plain) return;
|
| 357 |
+
const match = S.goldenMatch === true ? "MATCHES" : (S.goldenMatch === false ? "does NOT match" : "loading\u2026");
|
| 358 |
+
pd.innerHTML =
|
| 359 |
+
"<b>What this means:</b> Real NVIDIA H100 Confidential-Computing hardware boots " +
|
| 360 |
+
"through a measured sequence \\u2014 bootloader, firmware, driver, microcode, GPU " +
|
| 361 |
+
"VBIOS \\u2014 and produces a signed attestation report a relying party checks " +
|
| 362 |
+
"against NVIDIA's remote attestation service before trusting the GPU with secrets. " +
|
| 363 |
+
"This view is a <b>toy stand-in</b>: it hashes together a synthetic device ID and a " +
|
| 364 |
+
"chain of stage names with plain SHA-256/SHA-384, then compares the result to a " +
|
| 365 |
+
"single fixed \\u201cgolden\\u201d value. Right now the computed chain <b>" + match +
|
| 366 |
+
"</b> that golden value. There is <b>no real GPU, no real key, and no network call</b> " +
|
| 367 |
+
"involved \\u2014 it exists to show how attestation-chain verification WORKS, not to " +
|
| 368 |
+
"perform one. Plain: this is a labeled toy model of a real security concept, not a " +
|
| 369 |
+
"working hardware verifier.";
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
function _tok(s) {
|
| 373 |
+
if (s === "live") return null;
|
| 374 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 375 |
+
if (s === "degraded") return "DEGRADED";
|
| 376 |
+
if (s === "error") return "OFFLINE";
|
| 377 |
+
return "\u2026";
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
function _trunc(s, n) { return typeof s === "string" ? (s.length > n ? s.slice(0, n) + "\u2026" : s) : "\u2014"; }
|
| 381 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 382 |
+
|
| 383 |
+
function _paintOverlay() {
|
| 384 |
+
const t = _tok(S.state);
|
| 385 |
+
_set("cc-seed", t || (S.seed != null ? String(S.seed) : "\u2014"));
|
| 386 |
+
_set("cc-stages", t || (S.stagesReq != null ? String(S.stagesReq) : "\u2014"));
|
| 387 |
+
_set("cc-ident", t || _trunc(S.deviceId, 20));
|
| 388 |
+
_set("cc-final", t || _trunc(S.finalDigest, 20));
|
| 389 |
+
_set("cc-golden", t || (S.goldenMatch === true ? "MATCH" : (S.goldenMatch === false ? "MISMATCH" : "\u2014")));
|
| 390 |
+
// honesty label verbatim — never upgraded
|
| 391 |
+
_set("cc-label", t || (S.label || "MODELED"));
|
| 392 |
+
if (_plain) _applyPlain();
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
// =============================================================================
|
| 396 |
+
// unmount — clean up everything; must not affect other organs
|
| 397 |
+
// =============================================================================
|
| 398 |
+
export function unmount() {
|
| 399 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 400 |
+
try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
|
| 401 |
+
try {
|
| 402 |
+
if (_group && _stage) {
|
| 403 |
+
_group.traverse((o) => {
|
| 404 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 405 |
+
if (o.material) {
|
| 406 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 407 |
+
ms.forEach((m) => { if (m.dispose) m.dispose(); });
|
| 408 |
+
}
|
| 409 |
+
});
|
| 410 |
+
_stage.scene.remove(_group);
|
| 411 |
+
}
|
| 412 |
+
} catch (_) {}
|
| 413 |
+
_group = _overlay = null;
|
| 414 |
+
_blocks = []; _identMarker = null; _floor = null;
|
| 415 |
+
_el = {}; _badge = null; _plain = false; _frameReg = false;
|
| 416 |
+
_stage = _THREE = _ctx = null;
|
| 417 |
+
S.label = S.seed = S.stagesReq = S.deviceId = S.chain = null;
|
| 418 |
+
S.finalDigest = S.goldenMatch = S.honestNote = null;
|
| 419 |
+
S.state = "init";
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|
static/3d/surfaces/formalmath.js
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/formalmath.js — FORMAL-MATH RETRIEVAL-AUGMENTED TACTIC SELECTION organ
|
| 5 |
+
// for the holographic frontier ring (LeanDojo/ReProver-style premise retrieval +
|
| 6 |
+
// best-first proof search). Renders the synthetic tactic tree explored by the live
|
| 7 |
+
// snapshot from /api/killinchu/v1/formalmath/retrieve as a branching lattice-blue
|
| 8 |
+
// wireframe: nodes sized/colored proof-teal by retrieval similarity (the branch's
|
| 9 |
+
// premise_bias score), grey dashed edges mark unexplored/pruned branches beyond the
|
| 10 |
+
// live search_trace. A HUD shows the top retrieved premise + the tree depth reached.
|
| 11 |
+
// Honesty label "MODELED" is read VERBATIM from the JSON and displayed as-is; it is
|
| 12 |
+
// never upgraded.
|
| 13 |
+
//
|
| 14 |
+
// Surface export shape (mirrors testtime.js / specdecode.js exactly):
|
| 15 |
+
// export default { id, title, endpoints, mount(ctx), unmount() }
|
| 16 |
+
// ctx = { stage, container, live, label, THREE, szl3d }
|
| 17 |
+
//
|
| 18 |
+
// DATA SHOWN (all from live endpoint):
|
| 19 |
+
// goal, corpus_size, k, top_k_premises[], similarity_scores{},
|
| 20 |
+
// simulated_proof_tree_depth, nodes_expanded, search_trace[]
|
| 21 |
+
//
|
| 22 |
+
// LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
|
| 23 |
+
// LeanDojo (premise-annotated Lean data/benchmark toolkit):
|
| 24 |
+
// Yang et al. 2023, NeurIPS (Datasets and Benchmarks Track)
|
| 25 |
+
// https://github.com/lean-dojo/LeanDojo
|
| 26 |
+
// ReProver (Retrieval-Augmented Prover; ByT5 premise retriever + tactic generator):
|
| 27 |
+
// lean-dojo/ReProver
|
| 28 |
+
// https://github.com/lean-dojo/ReProver
|
| 29 |
+
// DeepSeek-Prover-V2 (subgoal decomposition + recursive proof search for Lean 4):
|
| 30 |
+
// DeepSeek-AI et al. 2025, arXiv:2504.21801
|
| 31 |
+
// https://arxiv.org/abs/2504.21801
|
| 32 |
+
//
|
| 33 |
+
// HONESTY LABELS: MODELED (deterministic bag-of-tokens cosine retrieval + best-first
|
| 34 |
+
// search simulation; NOT connected to Lean 4 or Mathlib; NEVER-CLAIMED-AS
|
| 35 |
+
// DeepSeek-Prover or ReProver output). Read verbatim from JSON; never upgraded here.
|
| 36 |
+
// COLOURS: lattice-blue 0x5b8dee (tactic-tree wireframe / explored edges), proof-teal
|
| 37 |
+
// 0x3af4c8 (nodes sized/colored by retrieval similarity / HUD accent), greys
|
| 38 |
+
// (unexplored/pruned branches, degraded state). Purple BANNED as UI/background.
|
| 39 |
+
// 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
|
| 40 |
+
// DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
|
| 41 |
+
// Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
|
| 42 |
+
|
| 43 |
+
const ID = "formalmath";
|
| 44 |
+
const TITLE = "Formal-Math Retrieval-Augmented Tactic Selection (live)";
|
| 45 |
+
|
| 46 |
+
// Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
|
| 47 |
+
// cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
|
| 48 |
+
// This keeps the formal-math organ's rebuilds/faults isolated from the flagship.
|
| 49 |
+
const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/formalmath/retrieve?seed=42&goal=theorem%20add_comm_example%20(a%20b%20%3A%20Nat)%20%3A%20a%20%2B%20b%20%3D%20b%20%2B%20a&corpus_size=24&k=5";
|
| 50 |
+
|
| 51 |
+
// data-viz hues — purple BANNED
|
| 52 |
+
const C_TREE = 0x5b8dee; // lattice-blue (tactic-tree wireframe / explored edges)
|
| 53 |
+
const C_NODE = 0x3af4c8; // proof-teal (nodes, sized/colored by retrieval similarity)
|
| 54 |
+
const C_UNEXPL = 0x5a6570; // grey (unexplored / pruned branch, dashed)
|
| 55 |
+
const C_DIM = 0x42505d; // grey (degraded / no-live-data)
|
| 56 |
+
const C_GRID = 0x1b3a44; // floor / link colour
|
| 57 |
+
|
| 58 |
+
// tactic-tree layout geometry
|
| 59 |
+
const DEPTH_LEN = 2.4; // world-units between depth levels along X
|
| 60 |
+
const LANE_GAP = 1.1; // world-units between sibling nodes (Y)
|
| 61 |
+
const MAX_DEPTH = 6; // matches server _MAX_DEPTH
|
| 62 |
+
const MAX_TRACE = 64; // matches server search_trace cap
|
| 63 |
+
const BRANCH = 3; // matches server _BRANCH_FACTOR (layout hint only)
|
| 64 |
+
|
| 65 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
|
| 66 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null;
|
| 67 |
+
let _plain = false;
|
| 68 |
+
|
| 69 |
+
// geometry handles
|
| 70 |
+
let _floor = null;
|
| 71 |
+
let _spine = null; // THREE.Line — root->depth axis
|
| 72 |
+
let _nodeMesh = []; // Array<THREE.Mesh> — one per trace slot
|
| 73 |
+
let _edgeLines = []; // Array<THREE.Line> — explored edges (lattice-blue)
|
| 74 |
+
let _unexplLines = []; // Array<THREE.Line> — grey dashed unexplored-branch stubs
|
| 75 |
+
let _marker = null; // THREE.Mesh — HUD "top premise" pulsing marker
|
| 76 |
+
|
| 77 |
+
// live state
|
| 78 |
+
const S = {
|
| 79 |
+
label: null,
|
| 80 |
+
goal: null, // goal
|
| 81 |
+
corpusSize: null, // corpus_size
|
| 82 |
+
k: null, // k
|
| 83 |
+
topPremises: null, // top_k_premises[]
|
| 84 |
+
simScores: null, // similarity_scores{}
|
| 85 |
+
treeDepth: null, // simulated_proof_tree_depth
|
| 86 |
+
nodesExpand: null, // nodes_expanded
|
| 87 |
+
trace: null, // search_trace[]
|
| 88 |
+
state: "init",
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
// =============================================================================
|
| 92 |
+
// mount(ctx)
|
| 93 |
+
// =============================================================================
|
| 94 |
+
export function mount(ctx) {
|
| 95 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 96 |
+
_group = new _THREE.Group();
|
| 97 |
+
_stage.scene.add(_group);
|
| 98 |
+
_stage.camera.position.set(5, 8, 20);
|
| 99 |
+
try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(6, 2, 0); _stage.controls.update(); } } catch (_) {}
|
| 100 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 101 |
+
|
| 102 |
+
_buildFloor();
|
| 103 |
+
_buildLattice();
|
| 104 |
+
_buildMarker();
|
| 105 |
+
|
| 106 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 107 |
+
|
| 108 |
+
_badge = ctx.live.createBadge();
|
| 109 |
+
_polls.push(ctx.live.poll(EP, 5000, _onFormalmath, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
|
| 110 |
+
|
| 111 |
+
_buildOverlay();
|
| 112 |
+
return { id: ID, started: true };
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// =============================================================================
|
| 116 |
+
// builders
|
| 117 |
+
// =============================================================================
|
| 118 |
+
function _buildFloor() {
|
| 119 |
+
const THREE = _THREE;
|
| 120 |
+
const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
|
| 121 |
+
grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
|
| 122 |
+
_group.add(grid);
|
| 123 |
+
_floor = grid;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// Pre-allocate a fixed pool of node meshes + edge/unexplored-branch lines sized to
|
| 127 |
+
// MAX_TRACE; we toggle visibility/position/color in-place as live data arrives
|
| 128 |
+
// (no per-poll geometry churn).
|
| 129 |
+
function _buildLattice() {
|
| 130 |
+
const THREE = _THREE;
|
| 131 |
+
|
| 132 |
+
// root->depth spine (visual reading guide only)
|
| 133 |
+
{
|
| 134 |
+
const pts = [new THREE.Vector3(0, 0, 0), new THREE.Vector3(DEPTH_LEN * MAX_DEPTH, 0, 0)];
|
| 135 |
+
const geo = new THREE.BufferGeometry().setFromPoints(pts);
|
| 136 |
+
const mat = new THREE.LineBasicMaterial({ color: C_TREE, transparent: true, opacity: 0.35 });
|
| 137 |
+
_spine = new THREE.Line(geo, mat);
|
| 138 |
+
_group.add(_spine);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
const nodeGeo = new THREE.IcosahedronGeometry(0.16, 0);
|
| 142 |
+
for (let i = 0; i < MAX_TRACE; i++) {
|
| 143 |
+
const mesh = new THREE.Mesh(
|
| 144 |
+
nodeGeo,
|
| 145 |
+
new THREE.MeshStandardMaterial({ color: C_NODE, emissive: C_NODE, emissiveIntensity: 0.35, wireframe: true, transparent: true, opacity: 0.0 }),
|
| 146 |
+
);
|
| 147 |
+
mesh.visible = false;
|
| 148 |
+
_group.add(mesh);
|
| 149 |
+
_nodeMesh.push(mesh);
|
| 150 |
+
|
| 151 |
+
// explored-edge line (parent -> this node), lattice-blue wireframe-style
|
| 152 |
+
const edgeGeo = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, 0)]);
|
| 153 |
+
const edgeMat = new THREE.LineBasicMaterial({ color: C_TREE, transparent: true, opacity: 0.0 });
|
| 154 |
+
const edge = new THREE.Line(edgeGeo, edgeMat);
|
| 155 |
+
edge.visible = false;
|
| 156 |
+
_group.add(edge);
|
| 157 |
+
_edgeLines.push(edge);
|
| 158 |
+
|
| 159 |
+
// unexplored/pruned-branch stub: short grey dashed line hinting at a
|
| 160 |
+
// branch beyond what the bounded search_trace sample shows
|
| 161 |
+
const unGeo = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, 0)]);
|
| 162 |
+
const unMat = new THREE.LineDashedMaterial({ color: C_UNEXPL, transparent: true, opacity: 0.0, dashSize: 0.12, gapSize: 0.09 });
|
| 163 |
+
const un = new THREE.Line(unGeo, unMat);
|
| 164 |
+
un.computeLineDistances();
|
| 165 |
+
un.visible = false;
|
| 166 |
+
_group.add(un);
|
| 167 |
+
_unexplLines.push(un);
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
function _buildMarker() {
|
| 172 |
+
const THREE = _THREE;
|
| 173 |
+
_marker = new THREE.Mesh(
|
| 174 |
+
new THREE.OctahedronGeometry(0.24, 0),
|
| 175 |
+
new THREE.MeshStandardMaterial({ color: C_NODE, emissive: C_NODE, emissiveIntensity: 0.5, wireframe: true, transparent: true, opacity: 0.85 }),
|
| 176 |
+
);
|
| 177 |
+
_marker.position.set(0, 1.4, 0);
|
| 178 |
+
_group.add(_marker);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
// =============================================================================
|
| 182 |
+
// live data handler
|
| 183 |
+
// =============================================================================
|
| 184 |
+
function _onFormalmath(j) {
|
| 185 |
+
// read honesty label VERBATIM — never upgrade
|
| 186 |
+
S.label = (j.label || "MODELED").toUpperCase();
|
| 187 |
+
S.goal = typeof j.goal === "string" ? j.goal : null;
|
| 188 |
+
S.corpusSize = typeof j.corpus_size === "number" ? j.corpus_size : null;
|
| 189 |
+
S.k = typeof j.k === "number" ? j.k : null;
|
| 190 |
+
S.topPremises = Array.isArray(j.top_k_premises) ? j.top_k_premises : null;
|
| 191 |
+
S.simScores = (j.similarity_scores && typeof j.similarity_scores === "object") ? j.similarity_scores : null;
|
| 192 |
+
S.treeDepth = typeof j.simulated_proof_tree_depth === "number" ? j.simulated_proof_tree_depth : null;
|
| 193 |
+
S.nodesExpand = typeof j.nodes_expanded === "number" ? j.nodes_expanded : null;
|
| 194 |
+
S.trace = Array.isArray(j.search_trace) ? j.search_trace : null;
|
| 195 |
+
|
| 196 |
+
_updateLattice();
|
| 197 |
+
_paintOverlay();
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
// =============================================================================
|
| 201 |
+
// geometry updater — drives the branching lattice from live search_trace[]
|
| 202 |
+
// =============================================================================
|
| 203 |
+
// Layout: each trace entry gets a lane index within its depth level (stable
|
| 204 |
+
// hash of node_id keeps lanes reproducible across polls), positioned at
|
| 205 |
+
// x = depth * DEPTH_LEN, y = (lane - laneCount/2) * LANE_GAP.
|
| 206 |
+
function _laneFor(nodeId, depth, seenAtDepth) {
|
| 207 |
+
const n = seenAtDepth.get(depth) || 0;
|
| 208 |
+
seenAtDepth.set(depth, n + 1);
|
| 209 |
+
return n;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
function _updateLattice() {
|
| 213 |
+
const THREE = _THREE;
|
| 214 |
+
const live = S.state === "live";
|
| 215 |
+
const trace = live && S.trace && S.trace.length ? S.trace.slice(0, MAX_TRACE) : [];
|
| 216 |
+
|
| 217 |
+
// find max similarity among top_k_premises for node-size/color normalization
|
| 218 |
+
let maxSim = 0.0;
|
| 219 |
+
if (live && S.topPremises && S.topPremises.length) {
|
| 220 |
+
maxSim = S.topPremises.reduce((m, p) => Math.max(m, p.similarity || 0), 0);
|
| 221 |
+
}
|
| 222 |
+
const simByName = {};
|
| 223 |
+
if (live && S.topPremises) S.topPremises.forEach((p) => { simByName[p.name] = p.similarity; });
|
| 224 |
+
|
| 225 |
+
const seenAtDepth = new Map();
|
| 226 |
+
const posByNodeId = new Map();
|
| 227 |
+
|
| 228 |
+
for (let i = 0; i < MAX_TRACE; i++) {
|
| 229 |
+
const mesh = _nodeMesh[i];
|
| 230 |
+
const edge = _edgeLines[i];
|
| 231 |
+
const un = _unexplLines[i];
|
| 232 |
+
|
| 233 |
+
if (i >= trace.length || !live) {
|
| 234 |
+
mesh.visible = false;
|
| 235 |
+
edge.visible = false;
|
| 236 |
+
un.visible = false;
|
| 237 |
+
continue;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
const row = trace[i];
|
| 241 |
+
const depth = Math.min(MAX_DEPTH, row.depth || 0);
|
| 242 |
+
const lane = _laneFor(row.node_id, depth, seenAtDepth);
|
| 243 |
+
const laneCountEstimate = Math.max(1, Math.pow(BRANCH, depth));
|
| 244 |
+
const x = depth * DEPTH_LEN;
|
| 245 |
+
const y = (lane - laneCountEstimate / 2) * LANE_GAP * (1 / Math.max(1, Math.log2(laneCountEstimate + 1)));
|
| 246 |
+
posByNodeId.set(row.node_id, { x, y, depth });
|
| 247 |
+
|
| 248 |
+
// node size/color driven by this branch's premise_bias similarity
|
| 249 |
+
const biasSim = row.premise_bias != null ? (simByName[row.premise_bias] || 0) : 0;
|
| 250 |
+
const norm = maxSim > 0 ? Math.min(1, biasSim / maxSim) : 0;
|
| 251 |
+
const scale = 0.7 + 1.6 * norm; // proof-teal nodes grow with retrieval similarity
|
| 252 |
+
|
| 253 |
+
mesh.position.set(x, y, 0);
|
| 254 |
+
mesh.scale.setScalar(scale);
|
| 255 |
+
mesh.visible = true;
|
| 256 |
+
mesh.material.opacity = 0.55 + 0.4 * norm;
|
| 257 |
+
mesh.material.color.setHex(C_NODE);
|
| 258 |
+
mesh.material.emissive.setHex(C_NODE);
|
| 259 |
+
mesh.material.emissiveIntensity = 0.25 + 0.4 * norm;
|
| 260 |
+
|
| 261 |
+
// explored edge: from root (depth 0 anchor) or a coarse parent-depth
|
| 262 |
+
// anchor back to this node (bounded trace has no explicit parent id, so
|
| 263 |
+
// we draw a lattice-blue edge from the previous depth-level's centroid X
|
| 264 |
+
// for a clean branching-lattice read, per the wireframe brief).
|
| 265 |
+
const parentX = Math.max(0, x - DEPTH_LEN);
|
| 266 |
+
edge.geometry.setFromPoints([new THREE.Vector3(parentX, 0, 0), new THREE.Vector3(x, y, 0)]);
|
| 267 |
+
edge.geometry.attributes.position.needsUpdate = true;
|
| 268 |
+
edge.material.color.setHex(C_TREE);
|
| 269 |
+
edge.material.opacity = 0.5;
|
| 270 |
+
edge.visible = true;
|
| 271 |
+
|
| 272 |
+
// unexplored-branch stub: a short grey dashed line fanning out beyond this
|
| 273 |
+
// node, hinting at sibling branches beyond the bounded trace sample
|
| 274 |
+
const stubX = x + DEPTH_LEN * 0.55;
|
| 275 |
+
const stubY = y + LANE_GAP * 0.4;
|
| 276 |
+
un.geometry.setFromPoints([new THREE.Vector3(x, y, 0), new THREE.Vector3(stubX, stubY, 0)]);
|
| 277 |
+
un.geometry.attributes.position.needsUpdate = true;
|
| 278 |
+
un.computeLineDistances();
|
| 279 |
+
un.material.color.setHex(C_UNEXPL);
|
| 280 |
+
un.material.opacity = depth < MAX_DEPTH ? 0.35 : 0.0;
|
| 281 |
+
un.visible = depth < MAX_DEPTH;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
_spine.material.color.setHex(live ? C_TREE : C_DIM);
|
| 285 |
+
_spine.material.opacity = live ? 0.35 : 0.12;
|
| 286 |
+
|
| 287 |
+
// HUD marker: sits above the deepest/most-similar node, pulses proof-teal
|
| 288 |
+
if (_marker) {
|
| 289 |
+
if (live && trace.length) {
|
| 290 |
+
const best = trace.reduce((a, b) => ((b.priority || 0) > (a.priority || 0) ? b : a), trace[0]);
|
| 291 |
+
const pos = posByNodeId.get(best.node_id) || { x: 0, y: 1.4 };
|
| 292 |
+
_marker.position.set(pos.x, (pos.y || 0) + 0.8, 0);
|
| 293 |
+
_marker.material.color.setHex(C_NODE);
|
| 294 |
+
_marker.material.emissive.setHex(C_NODE);
|
| 295 |
+
_marker.material.opacity = 0.85;
|
| 296 |
+
} else {
|
| 297 |
+
_marker.material.color.setHex(C_DIM);
|
| 298 |
+
_marker.material.emissive.setHex(C_DIM);
|
| 299 |
+
_marker.material.opacity = 0.3;
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
// =============================================================================
|
| 305 |
+
// per-frame animation
|
| 306 |
+
// =============================================================================
|
| 307 |
+
function _onFrame() {
|
| 308 |
+
const t = performance.now();
|
| 309 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.10;
|
| 310 |
+
if (_marker) {
|
| 311 |
+
_marker.rotation.y += 0.022;
|
| 312 |
+
_marker.rotation.x += 0.011;
|
| 313 |
+
const pulse = 1.0 + 0.15 * Math.sin(t * 0.004);
|
| 314 |
+
_marker.scale.setScalar(pulse);
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
// =============================================================================
|
| 319 |
+
// overlay
|
| 320 |
+
// =============================================================================
|
| 321 |
+
function _buildOverlay() {
|
| 322 |
+
const ctx = _ctx;
|
| 323 |
+
_overlay = document.createElement("div");
|
| 324 |
+
Object.assign(_overlay.style, {
|
| 325 |
+
position: "absolute", left: "14px", top: "14px", zIndex: "6",
|
| 326 |
+
display: "flex", flexDirection: "column", gap: "8px",
|
| 327 |
+
maxWidth: "min(94%,440px)",
|
| 328 |
+
font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
|
| 329 |
+
color: "#eef3f6",
|
| 330 |
+
});
|
| 331 |
+
|
| 332 |
+
const h = document.createElement("div");
|
| 333 |
+
h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
|
| 334 |
+
h.textContent = TITLE;
|
| 335 |
+
_overlay.appendChild(h);
|
| 336 |
+
|
| 337 |
+
const sub = document.createElement("div");
|
| 338 |
+
sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
|
| 339 |
+
sub.innerHTML =
|
| 340 |
+
'Retrieves the most relevant <b>premises</b> for a goal by <b>cosine similarity</b> over ' +
|
| 341 |
+
'hand-rolled bag-of-tokens vectors (no embeddings), then runs a deterministic ' +
|
| 342 |
+
'<b>best-first search</b> over a synthetic tactic tree, biased by the retrieved premises ' +
|
| 343 |
+
'\u2014 the LeanDojo/ReProver premise-selection concept. Honesty label <b>MODELED</b> ' +
|
| 344 |
+
'(NOT connected to Lean 4 or Mathlib). 0 runtime CDN.';
|
| 345 |
+
_overlay.appendChild(sub);
|
| 346 |
+
|
| 347 |
+
const brow = document.createElement("div");
|
| 348 |
+
brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
|
| 349 |
+
if (_badge && _badge.el) brow.appendChild(_badge.el);
|
| 350 |
+
_overlay.appendChild(brow);
|
| 351 |
+
|
| 352 |
+
const card = document.createElement("div");
|
| 353 |
+
card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
|
| 354 |
+
|
| 355 |
+
const chead = document.createElement("div");
|
| 356 |
+
chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
|
| 357 |
+
const dot = document.createElement("span");
|
| 358 |
+
dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#3af4c8;box-shadow:0 0 7px #3af4c8";
|
| 359 |
+
const nm = document.createElement("b");
|
| 360 |
+
nm.style.cssText = "font-size:12px;color:#3af4c8;letter-spacing:.3px";
|
| 361 |
+
nm.textContent = "formal-math retrieval + tactic search";
|
| 362 |
+
chead.appendChild(dot); chead.appendChild(nm);
|
| 363 |
+
card.appendChild(chead);
|
| 364 |
+
|
| 365 |
+
const grid = document.createElement("div");
|
| 366 |
+
grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
|
| 367 |
+
|
| 368 |
+
function kpiRow(id, label) {
|
| 369 |
+
const r = document.createElement("div");
|
| 370 |
+
r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
|
| 371 |
+
const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
|
| 372 |
+
const v = document.createElement("b");
|
| 373 |
+
v.id = id;
|
| 374 |
+
v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
|
| 375 |
+
v.textContent = "\u2014";
|
| 376 |
+
_el[id] = v;
|
| 377 |
+
r.appendChild(l); r.appendChild(v); return r;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
grid.appendChild(kpiRow("fm-goal", "goal"));
|
| 381 |
+
grid.appendChild(kpiRow("fm-corpus", "corpus_size"));
|
| 382 |
+
grid.appendChild(kpiRow("fm-k", "k (top-k retrieved)"));
|
| 383 |
+
grid.appendChild(kpiRow("fm-top", "top premise \u2014 MODELED"));
|
| 384 |
+
grid.appendChild(kpiRow("fm-sim", "top similarity"));
|
| 385 |
+
grid.appendChild(kpiRow("fm-depth", "proof-tree depth"));
|
| 386 |
+
grid.appendChild(kpiRow("fm-nodes", "nodes expanded"));
|
| 387 |
+
grid.appendChild(kpiRow("fm-label", "honesty label"));
|
| 388 |
+
card.appendChild(grid);
|
| 389 |
+
|
| 390 |
+
const fn = document.createElement("div");
|
| 391 |
+
fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
|
| 392 |
+
fn.textContent = "LeanDojo github.com/lean-dojo/LeanDojo \u00b7 ReProver github.com/lean-dojo/ReProver \u00b7 DeepSeek-Prover-V2 arXiv:2504.21801. MODELED \u00b7 not claimed-as.";
|
| 393 |
+
card.appendChild(fn);
|
| 394 |
+
_overlay.appendChild(card);
|
| 395 |
+
|
| 396 |
+
const pl = document.createElement("button");
|
| 397 |
+
pl.textContent = "\u25d1 what this means";
|
| 398 |
+
pl.title = "Toggle plain-language explanation for investors & consumers.";
|
| 399 |
+
pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
|
| 400 |
+
pl.addEventListener("click", () => {
|
| 401 |
+
_plain = !_plain;
|
| 402 |
+
pl.style.background = _plain ? "#0f2a20" : "#08140f";
|
| 403 |
+
_applyPlain();
|
| 404 |
+
});
|
| 405 |
+
_overlay.appendChild(pl);
|
| 406 |
+
|
| 407 |
+
const pd = document.createElement("div");
|
| 408 |
+
pd.id = "fm-plain";
|
| 409 |
+
pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
|
| 410 |
+
_el["plain"] = pd;
|
| 411 |
+
_overlay.appendChild(pd);
|
| 412 |
+
|
| 413 |
+
(ctx.container || document.body).appendChild(_overlay);
|
| 414 |
+
_paintOverlay();
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
function _applyPlain() {
|
| 418 |
+
const pd = _el["plain"];
|
| 419 |
+
if (!pd) return;
|
| 420 |
+
pd.style.display = _plain ? "block" : "none";
|
| 421 |
+
if (!_plain) return;
|
| 422 |
+
const top = (S.topPremises && S.topPremises[0]) ? S.topPremises[0].name : "loading\u2026";
|
| 423 |
+
const simPct = (S.topPremises && S.topPremises[0]) ? (S.topPremises[0].similarity * 100).toFixed(1) + "%" : "loading\u2026";
|
| 424 |
+
const depth = S.treeDepth != null ? String(S.treeDepth) : "loading\u2026";
|
| 425 |
+
pd.innerHTML =
|
| 426 |
+
"<b>What this means:</b> Proving a math theorem in a system like Lean often needs the " +
|
| 427 |
+
"<i>right supporting fact</i> (a \u201cpremise\u201d) from a huge library. Instead of " +
|
| 428 |
+
"searching blindly, this organ scores every candidate premise by how many words it shares " +
|
| 429 |
+
"with the goal (<b>" + top + "</b> scored highest here, at <b>" + simPct + "</b> similarity), " +
|
| 430 |
+
"then explores a tree of possible next proof steps, trying the most promising branches " +
|
| 431 |
+
"first \u2014 reaching a simulated depth of <b>" + depth + "</b> steps. Plain: find the most " +
|
| 432 |
+
"relevant facts first, then search smart instead of exhaustively. This is a <b>MODELED</b> " +
|
| 433 |
+
"toy simulation of the LeanDojo/ReProver idea \u2014 it is not connected to real Lean 4 or " +
|
| 434 |
+
"Mathlib, and is not DeepSeek-Prover or ReProver output.";
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
function _tok(s) {
|
| 438 |
+
if (s === "live") return null;
|
| 439 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 440 |
+
if (s === "degraded") return "DEGRADED";
|
| 441 |
+
if (s === "error") return "OFFLINE";
|
| 442 |
+
return "\u2026";
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
|
| 446 |
+
function pct(v, d) { return typeof v === "number" ? (v * 100).toFixed(d) + "%" : "\u2014"; }
|
| 447 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 448 |
+
|
| 449 |
+
function _paintOverlay() {
|
| 450 |
+
const t = _tok(S.state);
|
| 451 |
+
const top = S.topPremises && S.topPremises[0] ? S.topPremises[0] : null;
|
| 452 |
+
_set("fm-goal", t || (S.goal ? (S.goal.length > 34 ? S.goal.slice(0, 34) + "\u2026" : S.goal) : "\u2014"));
|
| 453 |
+
_set("fm-corpus", t || (S.corpusSize != null ? String(S.corpusSize) : "\u2014"));
|
| 454 |
+
_set("fm-k", t || (S.k != null ? String(S.k) : "\u2014"));
|
| 455 |
+
_set("fm-top", t || (top ? top.name : "\u2014"));
|
| 456 |
+
_set("fm-sim", t || (top ? pct(top.similarity, 2) : "\u2014"));
|
| 457 |
+
_set("fm-depth", t || (S.treeDepth != null ? String(S.treeDepth) : "\u2014"));
|
| 458 |
+
_set("fm-nodes", t || (S.nodesExpand != null ? String(S.nodesExpand) : "\u2014"));
|
| 459 |
+
// honesty label verbatim — never upgraded
|
| 460 |
+
_set("fm-label", t || (S.label || "MODELED"));
|
| 461 |
+
if (_plain) _applyPlain();
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
// =============================================================================
|
| 465 |
+
// unmount — clean up everything; must not affect other organs
|
| 466 |
+
// =============================================================================
|
| 467 |
+
export function unmount() {
|
| 468 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 469 |
+
try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
|
| 470 |
+
try {
|
| 471 |
+
if (_group && _stage) {
|
| 472 |
+
_group.traverse((o) => {
|
| 473 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 474 |
+
if (o.material) {
|
| 475 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 476 |
+
ms.forEach((m) => { if (m.dispose) m.dispose(); });
|
| 477 |
+
}
|
| 478 |
+
});
|
| 479 |
+
_stage.scene.remove(_group);
|
| 480 |
+
}
|
| 481 |
+
} catch (_) {}
|
| 482 |
+
_group = _overlay = null;
|
| 483 |
+
_floor = null; _spine = null; _nodeMesh = []; _edgeLines = []; _unexplLines = []; _marker = null;
|
| 484 |
+
_el = {}; _badge = null; _plain = false; _frameReg = false;
|
| 485 |
+
_stage = _THREE = _ctx = null;
|
| 486 |
+
S.label = S.goal = S.corpusSize = S.k = S.topPremises = S.simScores = null;
|
| 487 |
+
S.treeDepth = S.nodesExpand = S.trace = null;
|
| 488 |
+
S.state = "init";
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|
static/3d/surfaces/moe.js
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/moe.js — MoE SPARSE-UPCYCLING ROUTER SIMULATOR organ for the holographic
|
| 5 |
+
// frontier ring.
|
| 6 |
+
//
|
| 7 |
+
// Renders a 3D expert-load HEAT-SURFACE driven by a live snapshot from
|
| 8 |
+
// /api/killinchu/v1/moe/route:
|
| 9 |
+
// X axis = expert index (0..experts-1)
|
| 10 |
+
// Y axis = cumulative load (bar height) for that expert, up to a "routing round"
|
| 11 |
+
// Z axis = routing round (the routing_table sample is bucketed into rounds so the
|
| 12 |
+
// surface shows load ACCUMULATING over rounds, not just a final snapshot)
|
| 13 |
+
// Under-loaded experts (below the mean) render as lattice-blue peaks; balanced /
|
| 14 |
+
// at-or-above-mean experts render as proof-teal peaks — so the load_balance_cv HUD
|
| 15 |
+
// number has a directly visible shape (a flat teal skyline = balanced; spiky blue/teal
|
| 16 |
+
// contrast = imbalanced / "hot expert" routing). Honesty label "MODELED" is read
|
| 17 |
+
// VERBATIM from the JSON and displayed as-is; it is never upgraded.
|
| 18 |
+
//
|
| 19 |
+
// Surface export shape (mirrors ssm.js / testtime.js exactly):
|
| 20 |
+
// export default { id, title, endpoints, mount(ctx), unmount() }
|
| 21 |
+
// ctx = { stage, container, live, label, THREE, szl3d }
|
| 22 |
+
//
|
| 23 |
+
// DATA SHOWN (all from live endpoint):
|
| 24 |
+
// tokens, experts, topk
|
| 25 |
+
// routing_table (sample) — bucketed into rounds to build the heat-surface
|
| 26 |
+
// expert_load_counts[] — final per-expert load counts
|
| 27 |
+
// load_balance_cv — coefficient of variation of expert_load_counts
|
| 28 |
+
//
|
| 29 |
+
// LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
|
| 30 |
+
// Sparse Upcycling — Komatsuzaki et al. (2023) "Sparse Upcycling: Training
|
| 31 |
+
// Mixture-of-Experts from Dense Checkpoints". arXiv:2212.05055.
|
| 32 |
+
// https://arxiv.org/abs/2212.05055
|
| 33 |
+
// DeepSeekMoE — Dai et al. (2024) "DeepSeekMoE: Towards Ultimate Expert
|
| 34 |
+
// Specialization in Mixture-of-Experts Language Models". arXiv:2401.06066.
|
| 35 |
+
// https://arxiv.org/abs/2401.06066
|
| 36 |
+
// Expert Upcycling (amazon-science, code):
|
| 37 |
+
// https://github.com/amazon-science/expert-upcycling
|
| 38 |
+
//
|
| 39 |
+
// HONESTY LABELS: MODELED (deterministic top-K softmax router simulation illustrating
|
| 40 |
+
// sparse-upcycling load balance; NOT a trained MoE; NEVER-CLAIMED-AS DeepSeekMoE/
|
| 41 |
+
// Gemma-MoE/any production router). Read verbatim from JSON; never upgraded here.
|
| 42 |
+
// COLOURS: grey base grid, lattice-blue 0x5b8dee (under-loaded peaks), proof-teal
|
| 43 |
+
// 0x3af4c8 (balanced/at-or-above-mean peaks). Violet-blue 0x8a6bff reserved for HUD
|
| 44 |
+
// accent only. Purple BANNED as UI/background.
|
| 45 |
+
// 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
|
| 46 |
+
// DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
|
| 47 |
+
// Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
|
| 48 |
+
|
| 49 |
+
const ID = "moe";
|
| 50 |
+
const TITLE = "MoE Sparse-Upcycling Router Simulator (live)";
|
| 51 |
+
|
| 52 |
+
// Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
|
| 53 |
+
// cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
|
| 54 |
+
// This keeps the MoE-router organ's rebuilds/faults isolated from the flagship.
|
| 55 |
+
const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/moe/route?seed=42&tokens=64&experts=8&topk=2";
|
| 56 |
+
|
| 57 |
+
// data-viz hues — purple BANNED
|
| 58 |
+
const C_UNDER = 0x5b8dee; // lattice-blue (under-loaded expert peaks)
|
| 59 |
+
const C_BALANCE = 0x3af4c8; // proof-teal (balanced / at-or-above-mean expert peaks)
|
| 60 |
+
const C_ACCENT = 0x8a6bff; // violet-blue (HUD accent only — not used as a bar colour)
|
| 61 |
+
const C_DIM = 0x42505d; // grey (degraded / no-live-data)
|
| 62 |
+
const C_GRID = 0x1b3a44; // floor / link colour
|
| 63 |
+
|
| 64 |
+
const N_ROUNDS_MAX = 8; // number of "routing rounds" the sample is bucketed into
|
| 65 |
+
const CELL_X = 1.1; // world-units per expert column
|
| 66 |
+
const CELL_Z = 1.3; // world-units per routing round row
|
| 67 |
+
const MAX_BAR_H = 5.0; // world-units of max bar height (cumulative load axis)
|
| 68 |
+
|
| 69 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
|
| 70 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null;
|
| 71 |
+
let _plain = false;
|
| 72 |
+
|
| 73 |
+
// geometry handles
|
| 74 |
+
let _floor = null;
|
| 75 |
+
let _bars = []; // Array<THREE.Mesh> — heat-surface bars, index = round*experts + expertIdx
|
| 76 |
+
let _barGeo = null; // shared unit-box geometry (scaled per-bar)
|
| 77 |
+
let _labelGroup = null; // small per-expert axis tick markers
|
| 78 |
+
|
| 79 |
+
// live state
|
| 80 |
+
const S = {
|
| 81 |
+
label: null,
|
| 82 |
+
tokens: null,
|
| 83 |
+
experts: null,
|
| 84 |
+
topk: null,
|
| 85 |
+
routingTable: null, // Array<{token, chosen_experts, weights}>
|
| 86 |
+
loadCounts: null, // Array<number> — final per-expert load counts
|
| 87 |
+
loadCV: null, // load_balance_cv
|
| 88 |
+
state: "init",
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
// =============================================================================
|
| 92 |
+
// mount(ctx)
|
| 93 |
+
// =============================================================================
|
| 94 |
+
export function mount(ctx) {
|
| 95 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 96 |
+
_group = new _THREE.Group();
|
| 97 |
+
_stage.scene.add(_group);
|
| 98 |
+
_stage.camera.position.set(4, 9, 20);
|
| 99 |
+
try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(3, 1.5, 2); _stage.controls.update(); } } catch (_) {}
|
| 100 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 101 |
+
|
| 102 |
+
_buildFloor();
|
| 103 |
+
_buildHeatSurface();
|
| 104 |
+
|
| 105 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 106 |
+
|
| 107 |
+
_badge = ctx.live.createBadge();
|
| 108 |
+
_polls.push(ctx.live.poll(EP, 5000, _onRoute, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
|
| 109 |
+
|
| 110 |
+
_buildOverlay();
|
| 111 |
+
return { id: ID, started: true };
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// =============================================================================
|
| 115 |
+
// builders
|
| 116 |
+
// =============================================================================
|
| 117 |
+
function _buildFloor() {
|
| 118 |
+
const THREE = _THREE;
|
| 119 |
+
const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
|
| 120 |
+
grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
|
| 121 |
+
_group.add(grid);
|
| 122 |
+
_floor = grid;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
// Pre-allocate a fixed max grid of bar meshes (N_ROUNDS_MAX x MAX experts we ever
|
| 126 |
+
// expect, generously capped); we scale/recolor/position in-place as live data
|
| 127 |
+
// arrives (no per-poll geometry churn beyond count changes on shape change).
|
| 128 |
+
const _MAX_EXPERTS_GRID = 32;
|
| 129 |
+
|
| 130 |
+
function _buildHeatSurface() {
|
| 131 |
+
const THREE = _THREE;
|
| 132 |
+
_barGeo = new THREE.BoxGeometry(0.8, 1, 0.8); // unit height; scaled per-bar in Y
|
| 133 |
+
_bars = [];
|
| 134 |
+
for (let r = 0; r < N_ROUNDS_MAX; r++) {
|
| 135 |
+
for (let e = 0; e < _MAX_EXPERTS_GRID; e++) {
|
| 136 |
+
const mat = new THREE.MeshStandardMaterial({
|
| 137 |
+
color: C_DIM, emissive: C_DIM, emissiveIntensity: 0.25, transparent: true, opacity: 0.85,
|
| 138 |
+
});
|
| 139 |
+
const m = new THREE.Mesh(_barGeo, mat);
|
| 140 |
+
m.visible = false;
|
| 141 |
+
m.position.set(e * CELL_X, 0, r * CELL_Z);
|
| 142 |
+
_group.add(m);
|
| 143 |
+
_bars.push(m);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
// baseline axes (expert axis + round axis), grey, data-viz only
|
| 148 |
+
const axisPts = [
|
| 149 |
+
new THREE.Vector3(-0.6, 0, -0.6), new THREE.Vector3(-0.6, 0, N_ROUNDS_MAX * CELL_Z), // round axis
|
| 150 |
+
new THREE.Vector3(-0.6, 0, -0.6), new THREE.Vector3(_MAX_EXPERTS_GRID * CELL_X, 0, -0.6), // expert axis
|
| 151 |
+
];
|
| 152 |
+
const axisGeo = new THREE.BufferGeometry().setFromPoints(axisPts);
|
| 153 |
+
const axisLine = new THREE.LineSegments(axisGeo, new THREE.LineBasicMaterial({ color: C_GRID, transparent: true, opacity: 0.4 }));
|
| 154 |
+
_group.add(axisLine);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
function _bar(round, expertIdx) {
|
| 158 |
+
const idx = round * _MAX_EXPERTS_GRID + expertIdx;
|
| 159 |
+
return (idx >= 0 && idx < _bars.length) ? _bars[idx] : null;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// =============================================================================
|
| 163 |
+
// live data handler
|
| 164 |
+
// =============================================================================
|
| 165 |
+
function _onRoute(j) {
|
| 166 |
+
// read honesty label VERBATIM — never upgrade
|
| 167 |
+
S.label = (j.label || "MODELED").toUpperCase();
|
| 168 |
+
S.tokens = typeof j.tokens === "number" ? j.tokens : null;
|
| 169 |
+
S.experts = typeof j.experts === "number" ? j.experts : null;
|
| 170 |
+
S.topk = typeof j.topk === "number" ? j.topk : null;
|
| 171 |
+
S.routingTable = Array.isArray(j.routing_table) ? j.routing_table : null;
|
| 172 |
+
S.loadCounts = Array.isArray(j.expert_load_counts) ? j.expert_load_counts : null;
|
| 173 |
+
S.loadCV = typeof j.load_balance_cv === "number" ? j.load_balance_cv : null;
|
| 174 |
+
|
| 175 |
+
_updateHeatSurface();
|
| 176 |
+
_paintOverlay();
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
// =============================================================================
|
| 180 |
+
// geometry updater — buckets the routing_table sample into rounds, accumulates
|
| 181 |
+
// per-expert load across rounds, and renders each (round, expert) cell as a bar
|
| 182 |
+
// whose height = cumulative load-so-far for that expert.
|
| 183 |
+
// =============================================================================
|
| 184 |
+
function _bucketIntoRounds(routingTable, nExperts) {
|
| 185 |
+
// split the sampled routing_table (already token-ordered) into up to
|
| 186 |
+
// N_ROUNDS_MAX contiguous chunks ("rounds"); accumulate per-expert counts
|
| 187 |
+
// round-over-round so height = CUMULATIVE load (Z axis = round).
|
| 188 |
+
const n = routingTable.length;
|
| 189 |
+
const nRounds = Math.max(1, Math.min(N_ROUNDS_MAX, n));
|
| 190 |
+
const chunkSize = Math.max(1, Math.ceil(n / nRounds));
|
| 191 |
+
|
| 192 |
+
const cumulative = new Array(nExperts).fill(0);
|
| 193 |
+
const rounds = []; // Array<Array<number>> — cumulative load per expert, per round
|
| 194 |
+
|
| 195 |
+
for (let r = 0; r < nRounds; r++) {
|
| 196 |
+
const start = r * chunkSize;
|
| 197 |
+
const end = Math.min(n, start + chunkSize);
|
| 198 |
+
for (let i = start; i < end; i++) {
|
| 199 |
+
const row = routingTable[i];
|
| 200 |
+
const chosen = Array.isArray(row.chosen_experts) ? row.chosen_experts : [];
|
| 201 |
+
for (const e of chosen) {
|
| 202 |
+
if (e >= 0 && e < nExperts) cumulative[e] += 1;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
rounds.push(cumulative.slice());
|
| 206 |
+
}
|
| 207 |
+
return rounds;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
function _updateHeatSurface() {
|
| 211 |
+
const live = S.state === "live";
|
| 212 |
+
|
| 213 |
+
// hide everything first; re-show only the cells this snapshot uses
|
| 214 |
+
for (const b of _bars) b.visible = false;
|
| 215 |
+
|
| 216 |
+
if (!live || !S.routingTable || !S.loadCounts || !S.experts) {
|
| 217 |
+
return;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
const nExperts = Math.min(S.experts, _MAX_EXPERTS_GRID);
|
| 221 |
+
const rounds = _bucketIntoRounds(S.routingTable, nExperts);
|
| 222 |
+
const nRounds = rounds.length;
|
| 223 |
+
|
| 224 |
+
// mean of the FINAL expert_load_counts (from the full endpoint result, not just
|
| 225 |
+
// the sample) — used as the balanced/under-loaded colour threshold.
|
| 226 |
+
const finalCounts = S.loadCounts.slice(0, nExperts);
|
| 227 |
+
const mean = finalCounts.reduce((a, c) => a + c, 0) / Math.max(1, finalCounts.length);
|
| 228 |
+
const maxCum = Math.max(1, ...rounds.map((row) => Math.max(1, ...row)));
|
| 229 |
+
|
| 230 |
+
for (let r = 0; r < nRounds; r++) {
|
| 231 |
+
const row = rounds[r];
|
| 232 |
+
for (let e = 0; e < nExperts; e++) {
|
| 233 |
+
const m = _bar(r, e);
|
| 234 |
+
if (!m) continue;
|
| 235 |
+
const cum = row[e] || 0;
|
| 236 |
+
const h = Math.max(0.05, (cum / maxCum) * MAX_BAR_H);
|
| 237 |
+
m.scale.y = h;
|
| 238 |
+
m.position.set(e * CELL_X, h / 2, r * CELL_Z);
|
| 239 |
+
// colour: under the FINAL mean -> lattice-blue (under-loaded); at/above -> proof-teal (balanced)
|
| 240 |
+
const col = (finalCounts[e] >= mean) ? C_BALANCE : C_UNDER;
|
| 241 |
+
m.material.color.setHex(col);
|
| 242 |
+
m.material.emissive.setHex(col);
|
| 243 |
+
m.material.emissiveIntensity = 0.35;
|
| 244 |
+
m.material.opacity = 0.88;
|
| 245 |
+
m.visible = true;
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
// =============================================================================
|
| 251 |
+
// per-frame animation
|
| 252 |
+
// =============================================================================
|
| 253 |
+
function _onFrame() {
|
| 254 |
+
const t = performance.now();
|
| 255 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.12;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// =============================================================================
|
| 259 |
+
// overlay
|
| 260 |
+
// =============================================================================
|
| 261 |
+
function _buildOverlay() {
|
| 262 |
+
const ctx = _ctx;
|
| 263 |
+
_overlay = document.createElement("div");
|
| 264 |
+
Object.assign(_overlay.style, {
|
| 265 |
+
position: "absolute", left: "14px", top: "14px", zIndex: "6",
|
| 266 |
+
display: "flex", flexDirection: "column", gap: "8px",
|
| 267 |
+
maxWidth: "min(94%,440px)",
|
| 268 |
+
font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
|
| 269 |
+
color: "#eef3f6",
|
| 270 |
+
});
|
| 271 |
+
|
| 272 |
+
const h = document.createElement("div");
|
| 273 |
+
h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
|
| 274 |
+
h.textContent = TITLE;
|
| 275 |
+
_overlay.appendChild(h);
|
| 276 |
+
|
| 277 |
+
const sub = document.createElement("div");
|
| 278 |
+
sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
|
| 279 |
+
sub.innerHTML =
|
| 280 |
+
'A <b>top-K softmax router</b> dispatches each synthetic token to its highest-weight ' +
|
| 281 |
+
'experts. The heat-surface shows <b>cumulative expert load</b> building up across ' +
|
| 282 |
+
'routing rounds (X = expert, Z = round, Y = cumulative load). <b style="color:#5b8dee">Blue</b> ' +
|
| 283 |
+
'peaks are <b>under-loaded</b> experts (below mean); <b style="color:#3af4c8">teal</b> peaks are ' +
|
| 284 |
+
'<b>balanced/at-or-above-mean</b>. Honesty label <b>MODELED</b> (deterministic router ' +
|
| 285 |
+
'simulation — no trained MoE, never claimed as DeepSeekMoE/Gemma-MoE/any production ' +
|
| 286 |
+
'router). 0 runtime CDN.';
|
| 287 |
+
_overlay.appendChild(sub);
|
| 288 |
+
|
| 289 |
+
const brow = document.createElement("div");
|
| 290 |
+
brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
|
| 291 |
+
if (_badge && _badge.el) brow.appendChild(_badge.el);
|
| 292 |
+
_overlay.appendChild(brow);
|
| 293 |
+
|
| 294 |
+
const card = document.createElement("div");
|
| 295 |
+
card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
|
| 296 |
+
|
| 297 |
+
const chead = document.createElement("div");
|
| 298 |
+
chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
|
| 299 |
+
const dot = document.createElement("span");
|
| 300 |
+
dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#5b8dee;box-shadow:0 0 7px #5b8dee";
|
| 301 |
+
const nm = document.createElement("b");
|
| 302 |
+
nm.style.cssText = "font-size:12px;color:#5b8dee;letter-spacing:.3px";
|
| 303 |
+
nm.textContent = "moe-router";
|
| 304 |
+
chead.appendChild(dot); chead.appendChild(nm);
|
| 305 |
+
card.appendChild(chead);
|
| 306 |
+
|
| 307 |
+
const grid = document.createElement("div");
|
| 308 |
+
grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
|
| 309 |
+
|
| 310 |
+
function kpiRow(id, label) {
|
| 311 |
+
const r = document.createElement("div");
|
| 312 |
+
r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
|
| 313 |
+
const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
|
| 314 |
+
const v = document.createElement("b");
|
| 315 |
+
v.id = id;
|
| 316 |
+
v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
|
| 317 |
+
v.textContent = "\u2014";
|
| 318 |
+
_el[id] = v;
|
| 319 |
+
r.appendChild(l); r.appendChild(v); return r;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
grid.appendChild(kpiRow("moe-tokens", "tokens routed"));
|
| 323 |
+
grid.appendChild(kpiRow("moe-experts", "experts N"));
|
| 324 |
+
grid.appendChild(kpiRow("moe-topk", "top-K per token"));
|
| 325 |
+
grid.appendChild(kpiRow("moe-cv", "load_balance_cv"));
|
| 326 |
+
grid.appendChild(kpiRow("moe-minmax", "min / max expert load"));
|
| 327 |
+
grid.appendChild(kpiRow("moe-label", "honesty label"));
|
| 328 |
+
card.appendChild(grid);
|
| 329 |
+
|
| 330 |
+
const fn = document.createElement("div");
|
| 331 |
+
fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
|
| 332 |
+
fn.textContent = "Komatsuzaki et al. arXiv:2212.05055 (Sparse Upcycling) \u00b7 Dai et al. arXiv:2401.06066 (DeepSeekMoE) \u00b7 github.com/amazon-science/expert-upcycling (Expert Upcycling). MODELED \u00b7 not claimed-as.";
|
| 333 |
+
card.appendChild(fn);
|
| 334 |
+
_overlay.appendChild(card);
|
| 335 |
+
|
| 336 |
+
const pl = document.createElement("button");
|
| 337 |
+
pl.textContent = "\u25d1 what this means";
|
| 338 |
+
pl.title = "Toggle plain-language explanation for investors & consumers.";
|
| 339 |
+
pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
|
| 340 |
+
pl.addEventListener("click", () => {
|
| 341 |
+
_plain = !_plain;
|
| 342 |
+
pl.style.background = _plain ? "#0f2a20" : "#08140f";
|
| 343 |
+
_applyPlain();
|
| 344 |
+
});
|
| 345 |
+
_overlay.appendChild(pl);
|
| 346 |
+
|
| 347 |
+
const pd = document.createElement("div");
|
| 348 |
+
pd.id = "moe-plain";
|
| 349 |
+
pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
|
| 350 |
+
_el["plain"] = pd;
|
| 351 |
+
_overlay.appendChild(pd);
|
| 352 |
+
|
| 353 |
+
(ctx.container || document.body).appendChild(_overlay);
|
| 354 |
+
_paintOverlay();
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
function _applyPlain() {
|
| 358 |
+
const pd = _el["plain"];
|
| 359 |
+
if (!pd) return;
|
| 360 |
+
pd.style.display = _plain ? "block" : "none";
|
| 361 |
+
if (!_plain) return;
|
| 362 |
+
const tokens = S.tokens != null ? String(S.tokens) : "loading\u2026";
|
| 363 |
+
const experts = S.experts != null ? String(S.experts) : "loading\u2026";
|
| 364 |
+
const topk = S.topk != null ? String(S.topk) : "loading\u2026";
|
| 365 |
+
const cv = S.loadCV != null ? S.loadCV.toFixed(3) : "loading\u2026";
|
| 366 |
+
pd.innerHTML =
|
| 367 |
+
"<b>What this means:</b> A Mixture-of-Experts (MoE) layer has many small \u2018expert\u2019 " +
|
| 368 |
+
"sub-networks, but only sends each token to a handful of them (here: top-<b>" + topk +
|
| 369 |
+
"</b> out of <b>" + experts + "</b> experts) \u2014 this is what makes MoE models cheap to " +
|
| 370 |
+
"run despite having huge total parameter counts. \u2018<b>Sparse upcycling</b>\u2019 is a real " +
|
| 371 |
+
"training trick where you take an already-trained dense model and convert it into an " +
|
| 372 |
+
"MoE by copying its layers into multiple experts and adding a fresh <b>router</b> " +
|
| 373 |
+
"that learns to pick which expert handles which token. The hard part is <b>load " +
|
| 374 |
+
"balance</b>: if the router always picks the same few experts, those experts get " +
|
| 375 |
+
"overtrained and the rest are wasted. Here we routed <b>" + tokens + "</b> synthetic " +
|
| 376 |
+
"tokens and measured <b>load_balance_cv = " + cv + "</b> (0 = perfectly even, higher " +
|
| 377 |
+
"= some experts are getting hammered while others sit idle). " +
|
| 378 |
+
"Plain: this is a toy, fully-deterministic stand-in for the router-fairness problem " +
|
| 379 |
+
"real MoE systems have to solve \u2014 it is a <b>MODELED</b> simulation, not a trained " +
|
| 380 |
+
"MoE and not a benchmark of any named production model.";
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
function _tok(s) {
|
| 384 |
+
if (s === "live") return null;
|
| 385 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 386 |
+
if (s === "degraded") return "DEGRADED";
|
| 387 |
+
if (s === "error") return "OFFLINE";
|
| 388 |
+
return "\u2026";
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
|
| 392 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 393 |
+
|
| 394 |
+
function _paintOverlay() {
|
| 395 |
+
const t = _tok(S.state);
|
| 396 |
+
_set("moe-tokens", t || (S.tokens != null ? String(S.tokens) : "\u2014"));
|
| 397 |
+
_set("moe-experts", t || (S.experts != null ? String(S.experts) : "\u2014"));
|
| 398 |
+
_set("moe-topk", t || (S.topk != null ? String(S.topk) : "\u2014"));
|
| 399 |
+
_set("moe-cv", t || fx(S.loadCV, 4));
|
| 400 |
+
if (!t && Array.isArray(S.loadCounts) && S.loadCounts.length) {
|
| 401 |
+
_set("moe-minmax", `${Math.min(...S.loadCounts)} / ${Math.max(...S.loadCounts)}`);
|
| 402 |
+
} else {
|
| 403 |
+
_set("moe-minmax", t || "\u2014");
|
| 404 |
+
}
|
| 405 |
+
// honesty label verbatim — never upgraded
|
| 406 |
+
_set("moe-label", t || (S.label || "MODELED"));
|
| 407 |
+
if (_plain) _applyPlain();
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
// =============================================================================
|
| 411 |
+
// unmount — clean up everything; must not affect other organs
|
| 412 |
+
// =============================================================================
|
| 413 |
+
export function unmount() {
|
| 414 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 415 |
+
try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
|
| 416 |
+
try {
|
| 417 |
+
if (_group && _stage) {
|
| 418 |
+
_group.traverse((o) => {
|
| 419 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 420 |
+
if (o.material) {
|
| 421 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 422 |
+
ms.forEach((m) => { if (m.dispose) m.dispose(); });
|
| 423 |
+
}
|
| 424 |
+
});
|
| 425 |
+
_stage.scene.remove(_group);
|
| 426 |
+
}
|
| 427 |
+
} catch (_) {}
|
| 428 |
+
if (_barGeo && _barGeo.dispose) { try { _barGeo.dispose(); } catch (_) {} }
|
| 429 |
+
_group = _overlay = null;
|
| 430 |
+
_bars = []; _barGeo = null; _floor = null; _labelGroup = null;
|
| 431 |
+
_el = {}; _badge = null; _plain = false; _frameReg = false;
|
| 432 |
+
_stage = _THREE = _ctx = null;
|
| 433 |
+
S.label = S.tokens = S.experts = S.topk = null;
|
| 434 |
+
S.routingTable = S.loadCounts = S.loadCV = null;
|
| 435 |
+
S.state = "init";
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|
static/3d/surfaces/ringattn.js
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/ringattn.js — RING-ATTENTION LONG-CONTEXT BLOCKWISE SIMULATOR organ for
|
| 5 |
+
// the holographic frontier ring. Renders a 3D RING of `devices` device nodes with
|
| 6 |
+
// KV blocks rotating around it (num_rotation_steps == devices); a running online-
|
| 7 |
+
// softmax accumulator glows proof-teal as each KV block is absorbed. A HUD shows
|
| 8 |
+
// per_device_memory_ratio, exact_match, and max_context_supported from a live
|
| 9 |
+
// snapshot at /api/killinchu/v1/ringattn/simulate. Honesty label "MODELED" is read
|
| 10 |
+
// VERBATIM from the JSON and displayed as-is; it is never upgraded.
|
| 11 |
+
//
|
| 12 |
+
// Surface export shape (mirrors specdecode.js / testtime.js / interpretability.js
|
| 13 |
+
// exactly):
|
| 14 |
+
// export default { id, title, endpoints, mount(ctx), unmount() }
|
| 15 |
+
// ctx = { stage, container, live, label, THREE, szl3d }
|
| 16 |
+
//
|
| 17 |
+
// DATA SHOWN (all from live endpoint):
|
| 18 |
+
// seq_len, devices, block_size, num_rotation_steps, per_device_memory_ratio,
|
| 19 |
+
// exact_match, max_context_supported, rotation_trace[]
|
| 20 |
+
//
|
| 21 |
+
// LEADERS ADOPTED & CITED (clean-room; NOT claimed as SZL's own):
|
| 22 |
+
// Ring Attention with Blockwise Transformers for Near-Infinite Context:
|
| 23 |
+
// Liu, Zaharia & Abbeel 2023, arXiv:2310.01889
|
| 24 |
+
// https://arxiv.org/abs/2310.01889
|
| 25 |
+
// Blockwise Parallel Transformer (the online-softmax blockwise trick):
|
| 26 |
+
// Liu & Abbeel 2023, arXiv:2305.19370
|
| 27 |
+
// https://arxiv.org/abs/2305.19370
|
| 28 |
+
// Reference implementation: haoliuhl/ringattention
|
| 29 |
+
// https://github.com/haoliuhl/ringattention
|
| 30 |
+
//
|
| 31 |
+
// HONESTY LABELS: MODELED (deterministic blockwise online-softmax simulation of
|
| 32 |
+
// ring-attention's exact-attention accumulation; NOT a trained model or real
|
| 33 |
+
// multi-device kernel; NEVER-CLAIMED-AS a production ring-attention
|
| 34 |
+
// implementation). Read verbatim from JSON; never upgraded here.
|
| 35 |
+
// COLOURS: lattice-blue 0x5b8dee (device nodes / ring), violet-blue 0x8a6bff
|
| 36 |
+
// (rotating KV blocks), proof-teal 0x3af4c8 (online-softmax accumulator glow /
|
| 37 |
+
// HUD accent), greys (degraded / rejected state). Purple BANNED as UI/background.
|
| 38 |
+
// 0 RUNTIME CDN. Vendored three.js r170 via page importmap.
|
| 39 |
+
// DOCTRINE v11: degrades gracefully (grey) on 404/error; honesty label still shown.
|
| 40 |
+
// Nothing here is in the locked-8. Λ stays Conjecture 1. Trust never 100%.
|
| 41 |
+
|
| 42 |
+
const ID = "ringattn";
|
| 43 |
+
const TITLE = "Ring Attention · Long-Context Blockwise Simulator (live)";
|
| 44 |
+
|
| 45 |
+
// Endpoint is hosted on the dedicated killinchu Space (isolated compute), reached
|
| 46 |
+
// cross-origin (killinchu returns access-control-allow-origin: https://a-11-oy.com).
|
| 47 |
+
// This keeps the ring-attention organ's rebuilds/faults isolated from the flagship.
|
| 48 |
+
const EP = "https://szlholdings-killinchu.hf.space/api/killinchu/v1/ringattn/simulate?seed=42&seq_len=4096&devices=8";
|
| 49 |
+
|
| 50 |
+
// data-viz hues — purple BANNED
|
| 51 |
+
const C_DEVICE = 0x5b8dee; // lattice-blue (device nodes / ring spine)
|
| 52 |
+
const C_KVBLOCK = 0x8a6bff; // violet-blue (rotating KV block — data-viz only)
|
| 53 |
+
const C_ACCUM = 0x3af4c8; // proof-teal (online-softmax accumulator glow / HUD accent)
|
| 54 |
+
const C_DIM = 0x42505d; // grey (degraded / no-live-data)
|
| 55 |
+
const C_GRID = 0x1b3a44; // floor / link colour
|
| 56 |
+
|
| 57 |
+
// ring layout geometry
|
| 58 |
+
const RING_RADIUS = 6.0; // world-units, radius of the device ring
|
| 59 |
+
const NODE_SIZE = 0.34; // device node sphere radius
|
| 60 |
+
const MAX_DEVICES = 32; // pre-allocated device-node cap (perf)
|
| 61 |
+
const KV_ORBIT_R = RING_RADIUS + 1.1; // KV block travels slightly outside the ring
|
| 62 |
+
|
| 63 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _overlay = null;
|
| 64 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null;
|
| 65 |
+
let _plain = false;
|
| 66 |
+
|
| 67 |
+
// geometry handles
|
| 68 |
+
let _floor = null;
|
| 69 |
+
let _ringLine = null; // THREE.LineLoop — the ring spine
|
| 70 |
+
let _deviceMesh = []; // Array<THREE.Mesh> — device nodes around the ring
|
| 71 |
+
let _kvBlock = null; // THREE.Mesh — the rotating KV block marker
|
| 72 |
+
let _accumulator = null; // THREE.Mesh — running online-softmax accumulator (glows)
|
| 73 |
+
let _accumPulsePhase = 0;
|
| 74 |
+
|
| 75 |
+
// live state
|
| 76 |
+
const S = {
|
| 77 |
+
label: null,
|
| 78 |
+
seqLen: null, // seq_len
|
| 79 |
+
devices: null, // devices
|
| 80 |
+
blockSize: null, // block_size
|
| 81 |
+
rotSteps: null, // num_rotation_steps
|
| 82 |
+
memRatio: null, // per_device_memory_ratio
|
| 83 |
+
exactMatch: null, // exact_match (bool)
|
| 84 |
+
maxContext: null, // max_context_supported
|
| 85 |
+
trace: null, // rotation_trace[]
|
| 86 |
+
state: "init",
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
// =============================================================================
|
| 90 |
+
// mount(ctx)
|
| 91 |
+
// =============================================================================
|
| 92 |
+
export function mount(ctx) {
|
| 93 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 94 |
+
_group = new _THREE.Group();
|
| 95 |
+
_stage.scene.add(_group);
|
| 96 |
+
_stage.camera.position.set(0, 9, 16);
|
| 97 |
+
try { if (_stage.controls && _stage.controls.target) { _stage.controls.target.set(0, 1, 0); _stage.controls.update(); } } catch (_) {}
|
| 98 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 99 |
+
|
| 100 |
+
_buildFloor();
|
| 101 |
+
_buildRing();
|
| 102 |
+
_buildKvBlock();
|
| 103 |
+
_buildAccumulator();
|
| 104 |
+
|
| 105 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 106 |
+
|
| 107 |
+
_badge = ctx.live.createBadge();
|
| 108 |
+
_polls.push(ctx.live.poll(EP, 5000, _onRingAttn, { badge: _badge, onState: (m) => { S.state = m.state; _paintOverlay(); } }));
|
| 109 |
+
|
| 110 |
+
_buildOverlay();
|
| 111 |
+
return { id: ID, started: true };
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// =============================================================================
|
| 115 |
+
// builders
|
| 116 |
+
// =============================================================================
|
| 117 |
+
function _buildFloor() {
|
| 118 |
+
const THREE = _THREE;
|
| 119 |
+
const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
|
| 120 |
+
grid.material.opacity = 0.18; grid.material.transparent = true; grid.position.y = -0.01;
|
| 121 |
+
_group.add(grid);
|
| 122 |
+
_floor = grid;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function _ringPos(i, n, radius, y) {
|
| 126 |
+
const a = (i / Math.max(1, n)) * Math.PI * 2;
|
| 127 |
+
return [Math.cos(a) * radius, y, Math.sin(a) * radius];
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// Pre-allocate a fixed ring of device-node meshes (MAX_DEVICES); toggle
|
| 131 |
+
// visibility / color in-place as live data arrives (no per-poll geometry churn).
|
| 132 |
+
function _buildRing() {
|
| 133 |
+
const THREE = _THREE;
|
| 134 |
+
|
| 135 |
+
// ring spine (visual guide at y=0)
|
| 136 |
+
{
|
| 137 |
+
const pts = [];
|
| 138 |
+
const SEG = 96;
|
| 139 |
+
for (let i = 0; i <= SEG; i++) {
|
| 140 |
+
const a = (i / SEG) * Math.PI * 2;
|
| 141 |
+
pts.push(new THREE.Vector3(Math.cos(a) * RING_RADIUS, 0, Math.sin(a) * RING_RADIUS));
|
| 142 |
+
}
|
| 143 |
+
const geo = new THREE.BufferGeometry().setFromPoints(pts);
|
| 144 |
+
const mat = new THREE.LineBasicMaterial({ color: C_DEVICE, transparent: true, opacity: 0.35 });
|
| 145 |
+
_ringLine = new THREE.Line(geo, mat);
|
| 146 |
+
_group.add(_ringLine);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
const nodeGeo = new THREE.IcosahedronGeometry(NODE_SIZE, 0);
|
| 150 |
+
for (let i = 0; i < MAX_DEVICES; i++) {
|
| 151 |
+
const mesh = new THREE.Mesh(
|
| 152 |
+
nodeGeo,
|
| 153 |
+
new THREE.MeshStandardMaterial({ color: C_DEVICE, emissive: C_DEVICE, emissiveIntensity: 0.35, transparent: true, opacity: 0.0 }),
|
| 154 |
+
);
|
| 155 |
+
mesh.visible = false;
|
| 156 |
+
_group.add(mesh);
|
| 157 |
+
_deviceMesh.push(mesh);
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function _buildKvBlock() {
|
| 162 |
+
const THREE = _THREE;
|
| 163 |
+
_kvBlock = new THREE.Mesh(
|
| 164 |
+
new THREE.BoxGeometry(0.5, 0.5, 0.5),
|
| 165 |
+
new THREE.MeshStandardMaterial({ color: C_KVBLOCK, emissive: C_KVBLOCK, emissiveIntensity: 0.45, transparent: true, opacity: 0.9 }),
|
| 166 |
+
);
|
| 167 |
+
_kvBlock.position.set(KV_ORBIT_R, 0.6, 0);
|
| 168 |
+
_kvBlock.visible = false;
|
| 169 |
+
_group.add(_kvBlock);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
function _buildAccumulator() {
|
| 173 |
+
const THREE = _THREE;
|
| 174 |
+
// The running online-softmax accumulator sits at the ring's center and
|
| 175 |
+
// glows proof-teal as blocks are absorbed (running_sum growth cue).
|
| 176 |
+
_accumulator = new THREE.Mesh(
|
| 177 |
+
new THREE.SphereGeometry(0.55, 20, 16),
|
| 178 |
+
new THREE.MeshStandardMaterial({
|
| 179 |
+
color: C_ACCUM, emissive: C_ACCUM, emissiveIntensity: 0.4,
|
| 180 |
+
wireframe: true, transparent: true, opacity: 0.75,
|
| 181 |
+
}),
|
| 182 |
+
);
|
| 183 |
+
_accumulator.position.set(0, 1.4, 0);
|
| 184 |
+
_group.add(_accumulator);
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// =============================================================================
|
| 188 |
+
// live data handler
|
| 189 |
+
// =============================================================================
|
| 190 |
+
function _onRingAttn(j) {
|
| 191 |
+
// read honesty label VERBATIM — never upgrade
|
| 192 |
+
S.label = (j.label || "MODELED").toUpperCase();
|
| 193 |
+
S.seqLen = typeof j.seq_len === "number" ? j.seq_len : null;
|
| 194 |
+
S.devices = typeof j.devices === "number" ? j.devices : null;
|
| 195 |
+
S.blockSize = typeof j.block_size === "number" ? j.block_size : null;
|
| 196 |
+
S.rotSteps = typeof j.num_rotation_steps === "number" ? j.num_rotation_steps : null;
|
| 197 |
+
S.memRatio = typeof j.per_device_memory_ratio === "number" ? j.per_device_memory_ratio : null;
|
| 198 |
+
S.exactMatch = typeof j.exact_match === "boolean" ? j.exact_match : null;
|
| 199 |
+
S.maxContext = typeof j.max_context_supported === "number" ? j.max_context_supported : null;
|
| 200 |
+
S.trace = Array.isArray(j.rotation_trace) ? j.rotation_trace : null;
|
| 201 |
+
|
| 202 |
+
_updateRing();
|
| 203 |
+
_paintOverlay();
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
// =============================================================================
|
| 207 |
+
// geometry updater — drives the ring + rotating KV block + accumulator
|
| 208 |
+
// =============================================================================
|
| 209 |
+
function _updateRing() {
|
| 210 |
+
const live = S.state === "live";
|
| 211 |
+
const n = live && S.devices ? Math.min(S.devices, MAX_DEVICES) : 0;
|
| 212 |
+
|
| 213 |
+
for (let i = 0; i < MAX_DEVICES; i++) {
|
| 214 |
+
const mesh = _deviceMesh[i];
|
| 215 |
+
if (i >= n) { mesh.visible = false; continue; }
|
| 216 |
+
mesh.visible = true;
|
| 217 |
+
const [x, y, z] = _ringPos(i, n, RING_RADIUS, 0.6);
|
| 218 |
+
mesh.position.set(x, y, z);
|
| 219 |
+
const color = live ? C_DEVICE : C_DIM;
|
| 220 |
+
mesh.material.color.setHex(color);
|
| 221 |
+
mesh.material.emissive.setHex(color);
|
| 222 |
+
mesh.material.opacity = live ? 0.9 : 0.25;
|
| 223 |
+
mesh.material.emissiveIntensity = live ? 0.35 : 0.08;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
_ringLine.material.color.setHex(live ? C_DEVICE : C_DIM);
|
| 227 |
+
_ringLine.material.opacity = live ? 0.35 : 0.12;
|
| 228 |
+
|
| 229 |
+
if (_kvBlock) {
|
| 230 |
+
_kvBlock.visible = live && n > 0;
|
| 231 |
+
_kvBlock.material.color.setHex(live ? C_KVBLOCK : C_DIM);
|
| 232 |
+
_kvBlock.material.emissive.setHex(live ? C_KVBLOCK : C_DIM);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
if (_accumulator) {
|
| 236 |
+
if (live && S.exactMatch != null) {
|
| 237 |
+
const color = S.exactMatch ? C_ACCUM : C_DIM; // exact -> teal; mismatch (never expected) -> grey, never red/purple
|
| 238 |
+
_accumulator.material.color.setHex(color);
|
| 239 |
+
_accumulator.material.emissive.setHex(color);
|
| 240 |
+
_accumulator.material.opacity = 0.8;
|
| 241 |
+
} else {
|
| 242 |
+
_accumulator.material.color.setHex(C_DIM);
|
| 243 |
+
_accumulator.material.emissive.setHex(C_DIM);
|
| 244 |
+
_accumulator.material.opacity = 0.25;
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
// =============================================================================
|
| 250 |
+
// per-frame animation — KV block rotates around the ring; accumulator pulses
|
| 251 |
+
// as each rotation step is "absorbed" (proof-teal glow intensifies)
|
| 252 |
+
// =============================================================================
|
| 253 |
+
function _onFrame() {
|
| 254 |
+
const t = performance.now();
|
| 255 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00008) * 0.10;
|
| 256 |
+
|
| 257 |
+
const live = S.state === "live";
|
| 258 |
+
const n = live && S.devices ? Math.min(S.devices, MAX_DEVICES) : 0;
|
| 259 |
+
|
| 260 |
+
if (_kvBlock && n > 0) {
|
| 261 |
+
// one full rotation every ~ (devices * 900ms), i.e. slower with more devices
|
| 262 |
+
// (visually implies num_rotation_steps == devices).
|
| 263 |
+
const periodMs = Math.max(2000, n * 900);
|
| 264 |
+
const phase = (t % periodMs) / periodMs; // 0..1
|
| 265 |
+
const a = phase * Math.PI * 2;
|
| 266 |
+
_kvBlock.position.set(Math.cos(a) * KV_ORBIT_R, 0.6 + 0.15 * Math.sin(t * 0.006), Math.sin(a) * KV_ORBIT_R);
|
| 267 |
+
_kvBlock.rotation.x += 0.03;
|
| 268 |
+
_kvBlock.rotation.y += 0.02;
|
| 269 |
+
|
| 270 |
+
// pulse the accumulator once per rotation step as a block is "absorbed"
|
| 271 |
+
const stepPhase = (phase * n) % 1.0;
|
| 272 |
+
_accumPulsePhase = stepPhase;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
if (_accumulator) {
|
| 276 |
+
_accumulator.rotation.y += 0.015;
|
| 277 |
+
const basePulse = 1.0 + 0.12 * Math.sin(t * 0.004);
|
| 278 |
+
const stepGlow = live ? 1.0 + 0.25 * Math.exp(-6.0 * _accumPulsePhase) : 1.0;
|
| 279 |
+
_accumulator.scale.setScalar(basePulse * stepGlow);
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// =============================================================================
|
| 284 |
+
// overlay
|
| 285 |
+
// =============================================================================
|
| 286 |
+
function _buildOverlay() {
|
| 287 |
+
const ctx = _ctx;
|
| 288 |
+
_overlay = document.createElement("div");
|
| 289 |
+
Object.assign(_overlay.style, {
|
| 290 |
+
position: "absolute", left: "14px", top: "14px", zIndex: "6",
|
| 291 |
+
display: "flex", flexDirection: "column", gap: "8px",
|
| 292 |
+
maxWidth: "min(94%,440px)",
|
| 293 |
+
font: "12px ui-sans-serif,system-ui,Segoe UI,Roboto,Arial",
|
| 294 |
+
color: "#eef3f6",
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
const h = document.createElement("div");
|
| 298 |
+
h.style.cssText = "font:600 13px ui-sans-serif,system-ui;letter-spacing:.4px";
|
| 299 |
+
h.textContent = TITLE;
|
| 300 |
+
_overlay.appendChild(h);
|
| 301 |
+
|
| 302 |
+
const sub = document.createElement("div");
|
| 303 |
+
sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
|
| 304 |
+
sub.innerHTML =
|
| 305 |
+
'Q/K/V are sharded across a logical <b>ring of devices</b>; KV blocks rotate around the ' +
|
| 306 |
+
'ring in <b>num_rotation_steps = devices</b> steps while a running <b>online-softmax</b> ' +
|
| 307 |
+
'accumulator (max/sum) absorbs each block. Result is provably <b>identical</b> to full ' +
|
| 308 |
+
'attention (<b>exact_match</b>) at <b>1/devices</b> memory per device. Honesty label ' +
|
| 309 |
+
'<b>MODELED</b> (deterministic blockwise simulation; NOT a real multi-device kernel). 0 runtime CDN.';
|
| 310 |
+
_overlay.appendChild(sub);
|
| 311 |
+
|
| 312 |
+
const brow = document.createElement("div");
|
| 313 |
+
brow.style.cssText = "display:flex;gap:8px;align-items:center;flex-wrap:wrap";
|
| 314 |
+
if (_badge && _badge.el) brow.appendChild(_badge.el);
|
| 315 |
+
_overlay.appendChild(brow);
|
| 316 |
+
|
| 317 |
+
const card = document.createElement("div");
|
| 318 |
+
card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
|
| 319 |
+
|
| 320 |
+
const chead = document.createElement("div");
|
| 321 |
+
chead.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap";
|
| 322 |
+
const dot = document.createElement("span");
|
| 323 |
+
dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:#3af4c8;box-shadow:0 0 7px #3af4c8";
|
| 324 |
+
const nm = document.createElement("b");
|
| 325 |
+
nm.style.cssText = "font-size:12px;color:#3af4c8;letter-spacing:.3px";
|
| 326 |
+
nm.textContent = "ring attention";
|
| 327 |
+
chead.appendChild(dot); chead.appendChild(nm);
|
| 328 |
+
card.appendChild(chead);
|
| 329 |
+
|
| 330 |
+
const grid = document.createElement("div");
|
| 331 |
+
grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
|
| 332 |
+
|
| 333 |
+
function kpiRow(id, label) {
|
| 334 |
+
const r = document.createElement("div");
|
| 335 |
+
r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
|
| 336 |
+
const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
|
| 337 |
+
const v = document.createElement("b");
|
| 338 |
+
v.id = id;
|
| 339 |
+
v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:58%";
|
| 340 |
+
v.textContent = "\u2014";
|
| 341 |
+
_el[id] = v;
|
| 342 |
+
r.appendChild(l); r.appendChild(v); return r;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
grid.appendChild(kpiRow("ra-seqlen", "seq_len (context tokens)"));
|
| 346 |
+
grid.appendChild(kpiRow("ra-devices", "devices (ring size)"));
|
| 347 |
+
grid.appendChild(kpiRow("ra-block", "block_size"));
|
| 348 |
+
grid.appendChild(kpiRow("ra-steps", "num_rotation_steps"));
|
| 349 |
+
grid.appendChild(kpiRow("ra-memratio","per_device_memory_ratio \u2014 MODELED"));
|
| 350 |
+
grid.appendChild(kpiRow("ra-exact", "exact_match (blockwise == full)"));
|
| 351 |
+
grid.appendChild(kpiRow("ra-maxctx", "max_context_supported"));
|
| 352 |
+
grid.appendChild(kpiRow("ra-label", "honesty label"));
|
| 353 |
+
card.appendChild(grid);
|
| 354 |
+
|
| 355 |
+
const fn = document.createElement("div");
|
| 356 |
+
fn.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.5";
|
| 357 |
+
fn.textContent = "Liu, Zaharia & Abbeel arXiv:2310.01889 (Ring Attention) \u00b7 Liu & Abbeel arXiv:2305.19370 (Blockwise Parallel Transformer) \u00b7 github.com/haoliuhl/ringattention. MODELED \u00b7 not claimed-as.";
|
| 358 |
+
card.appendChild(fn);
|
| 359 |
+
_overlay.appendChild(card);
|
| 360 |
+
|
| 361 |
+
const pl = document.createElement("button");
|
| 362 |
+
pl.textContent = "\u25d1 what this means";
|
| 363 |
+
pl.title = "Toggle plain-language explanation for investors & consumers.";
|
| 364 |
+
pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
|
| 365 |
+
pl.addEventListener("click", () => {
|
| 366 |
+
_plain = !_plain;
|
| 367 |
+
pl.style.background = _plain ? "#0f2a20" : "#08140f";
|
| 368 |
+
_applyPlain();
|
| 369 |
+
});
|
| 370 |
+
_overlay.appendChild(pl);
|
| 371 |
+
|
| 372 |
+
const pd = document.createElement("div");
|
| 373 |
+
pd.id = "ra-plain";
|
| 374 |
+
pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
|
| 375 |
+
_el["plain"] = pd;
|
| 376 |
+
_overlay.appendChild(pd);
|
| 377 |
+
|
| 378 |
+
(ctx.container || document.body).appendChild(_overlay);
|
| 379 |
+
_paintOverlay();
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
function _applyPlain() {
|
| 383 |
+
const pd = _el["plain"];
|
| 384 |
+
if (!pd) return;
|
| 385 |
+
pd.style.display = _plain ? "block" : "none";
|
| 386 |
+
if (!_plain) return;
|
| 387 |
+
const seqLen = S.seqLen != null ? S.seqLen.toLocaleString() : "loading\u2026";
|
| 388 |
+
const dev = S.devices != null ? String(S.devices) : "loading\u2026";
|
| 389 |
+
const ratio = S.memRatio!= null ? "1/" + Math.round(1 / S.memRatio) : "loading\u2026";
|
| 390 |
+
const exact = S.exactMatch === true ? "exactly the same" : S.exactMatch === false ? "different (unexpected)" : "loading\u2026";
|
| 391 |
+
pd.innerHTML =
|
| 392 |
+
"<b>What this means:</b> Long documents mean huge Q/K/V matrices that don't fit on one " +
|
| 393 |
+
"chip. Ring Attention splits the sequence (<b>" + seqLen + " tokens</b>) across a ring of " +
|
| 394 |
+
"<b>" + dev + " devices</b>: each device keeps only its own slice and passes its key/value " +
|
| 395 |
+
"block to the next device in the ring, one step at a time. A running \u201conline-softmax\u201d " +
|
| 396 |
+
"tally (a running maximum and running sum) is updated after each block arrives, so the " +
|
| 397 |
+
"final answer comes out <b>" + exact + "</b> as if one giant device had computed the whole " +
|
| 398 |
+
"thing at once \u2014 while each device only ever needs <b>" + ratio + "</b> of the memory a " +
|
| 399 |
+
"single device would need for the full sequence. Plain: same exact answer, spread across " +
|
| 400 |
+
"many machines, using far less memory each. This view is a <b>MODELED</b> deterministic " +
|
| 401 |
+
"simulation of that accumulation math, not a real multi-GPU run.";
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
function _tok(s) {
|
| 405 |
+
if (s === "live") return null;
|
| 406 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 407 |
+
if (s === "degraded") return "DEGRADED";
|
| 408 |
+
if (s === "error") return "OFFLINE";
|
| 409 |
+
return "\u2026";
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
function fx(v, d) { return typeof v === "number" ? v.toFixed(d) : "\u2014"; }
|
| 413 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 414 |
+
|
| 415 |
+
function _paintOverlay() {
|
| 416 |
+
const t = _tok(S.state);
|
| 417 |
+
_set("ra-seqlen", t || (S.seqLen != null ? S.seqLen.toLocaleString() : "\u2014"));
|
| 418 |
+
_set("ra-devices", t || (S.devices != null ? String(S.devices) : "\u2014"));
|
| 419 |
+
_set("ra-block", t || (S.blockSize != null ? String(S.blockSize) : "\u2014"));
|
| 420 |
+
_set("ra-steps", t || (S.rotSteps != null ? String(S.rotSteps) : "\u2014"));
|
| 421 |
+
_set("ra-memratio", t || (S.memRatio != null ? ("1/" + Math.round(1 / S.memRatio) + " (" + fx(S.memRatio, 4) + ")") : "\u2014"));
|
| 422 |
+
_set("ra-exact", t || (S.exactMatch === true ? "TRUE (exact)" : S.exactMatch === false ? "FALSE" : "\u2014"));
|
| 423 |
+
_set("ra-maxctx", t || (S.maxContext != null ? S.maxContext.toLocaleString() + " tokens" : "\u2014"));
|
| 424 |
+
// honesty label verbatim — never upgraded
|
| 425 |
+
_set("ra-label", t || (S.label || "MODELED"));
|
| 426 |
+
if (_plain) _applyPlain();
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
// =============================================================================
|
| 430 |
+
// unmount — clean up everything; must not affect other organs
|
| 431 |
+
// =============================================================================
|
| 432 |
+
export function unmount() {
|
| 433 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 434 |
+
try { if (_overlay && _overlay.parentNode) _overlay.parentNode.removeChild(_overlay); } catch (_) {}
|
| 435 |
+
try {
|
| 436 |
+
if (_group && _stage) {
|
| 437 |
+
_group.traverse((o) => {
|
| 438 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 439 |
+
if (o.material) {
|
| 440 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 441 |
+
ms.forEach((m) => { if (m.dispose) m.dispose(); });
|
| 442 |
+
}
|
| 443 |
+
});
|
| 444 |
+
_stage.scene.remove(_group);
|
| 445 |
+
}
|
| 446 |
+
} catch (_) {}
|
| 447 |
+
_group = _overlay = null;
|
| 448 |
+
_floor = null; _ringLine = null; _deviceMesh = []; _kvBlock = null; _accumulator = null;
|
| 449 |
+
_el = {}; _badge = null; _plain = false; _frameReg = false; _accumPulsePhase = 0;
|
| 450 |
+
_stage = _THREE = _ctx = null;
|
| 451 |
+
S.label = S.seqLen = S.devices = S.blockSize = S.rotSteps = null;
|
| 452 |
+
S.memRatio = S.exactMatch = S.maxContext = S.trace = null;
|
| 453 |
+
S.state = "init";
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|
szl3d_holographic.py
CHANGED
|
@@ -43,6 +43,10 @@ SURFACES: List[Dict[str, str]] = [
|
|
| 43 |
{"id": "specdecode", "title": "Speculative Decoding", "owner": "Dev0"},
|
| 44 |
{"id": "flowmatch", "title": "Flow Matching", "owner": "Dev0"},
|
| 45 |
{"id": "dllm", "title": "Diffusion LLM", "owner": "Dev0"},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
{"id": "energy", "title": "Energy", "owner": "Dev1"},
|
| 47 |
{"id": "fabric", "title": "Compute Fabric", "owner": "Dev2"},
|
| 48 |
{"id": "pnt", "title": "PNT", "owner": "Dev3"},
|
|
|
|
| 43 |
{"id": "specdecode", "title": "Speculative Decoding", "owner": "Dev0"},
|
| 44 |
{"id": "flowmatch", "title": "Flow Matching", "owner": "Dev0"},
|
| 45 |
{"id": "dllm", "title": "Diffusion LLM", "owner": "Dev0"},
|
| 46 |
+
{"id": "moe", "title": "MoE Router", "owner": "Dev0"},
|
| 47 |
+
{"id": "formalmath", "title": "Formal-Math Retrieval", "owner": "Dev0"},
|
| 48 |
+
{"id": "ccattest", "title": "Confidential-Compute Attest", "owner": "Dev0"},
|
| 49 |
+
{"id": "ringattn", "title": "Ring Attention", "owner": "Dev0"},
|
| 50 |
{"id": "energy", "title": "Energy", "owner": "Dev1"},
|
| 51 |
{"id": "fabric", "title": "Compute Fabric", "owner": "Dev2"},
|
| 52 |
{"id": "pnt", "title": "PNT", "owner": "Dev3"},
|