Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- Dockerfile +1 -0
- README.md +1 -0
- energy.py +35 -0
- index.html +16 -1
- server.py +33 -3
- train.py +192 -0
Dockerfile
CHANGED
|
@@ -10,3 +10,4 @@ EXPOSE 7860
|
|
| 10 |
CMD ["python", "-u", "server.py"]
|
| 11 |
COPY energy.py ./energy.py
|
| 12 |
COPY kernel.py ./kernel.py
|
|
|
|
|
|
| 10 |
CMD ["python", "-u", "server.py"]
|
| 11 |
COPY energy.py ./energy.py
|
| 12 |
COPY kernel.py ./kernel.py
|
| 13 |
+
COPY train.py ./train.py
|
README.md
CHANGED
|
@@ -46,6 +46,7 @@ Stdlib HTTP on 7860. No npm.
|
|
| 46 |
| `GET /healthz` | energy channel LIVE, joule UNAVAILABLE without RAPL/NVML |
|
| 47 |
| `GET /api/energy` | RAPL/NVML package probe. Last wrap stored when present. Never a fabricated joule. |
|
| 48 |
| `GET /api/energy/inference` | Wrap a 1s SHA-256 storm. Inference joule is the board delta. |
|
|
|
|
| 49 |
| `GET /api/organs/integrity` | 5-organ kernel. `proven_trust` always false. |
|
| 50 |
| `GET /api/estate` | live recapture of 10 Hub surfaces |
|
| 51 |
| `HEAD /` | 200 |
|
|
|
|
| 46 |
| `GET /healthz` | energy channel LIVE, joule UNAVAILABLE without RAPL/NVML |
|
| 47 |
| `GET /api/energy` | RAPL/NVML package probe. Last wrap stored when present. Never a fabricated joule. |
|
| 48 |
| `GET /api/energy/inference` | Wrap a 1s SHA-256 storm. Inference joule is the board delta. |
|
| 49 |
+
| `GET /api/train` | GPU train gate. BLOCKED until CUDA + approved job. Never a fabricated train. |
|
| 50 |
| `GET /api/organs/integrity` | 5-organ kernel. `proven_trust` always false. |
|
| 51 |
| `GET /api/estate` | live recapture of 10 Hub surfaces |
|
| 52 |
| `HEAD /` | 200 |
|
energy.py
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
from __future__ import annotations
|
| 7 |
|
| 8 |
import json
|
|
|
|
| 9 |
import time
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any
|
|
@@ -63,10 +64,43 @@ def _nvml_mj() -> float | None:
|
|
| 63 |
return None
|
| 64 |
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
def hardware() -> dict[str, Any]:
|
| 67 |
"""Inventory only. Never a joule. RAPL/NVML readable ⇒ a later probe can MEASURE."""
|
| 68 |
rapl = _rapl_uj()
|
| 69 |
nv = _nvml_mj()
|
|
|
|
| 70 |
return {
|
| 71 |
"powercap_dir": POWERCAP.is_dir(),
|
| 72 |
"rapl_readable": rapl is not None,
|
|
@@ -74,6 +108,7 @@ def hardware() -> dict[str, Any]:
|
|
| 74 |
"pynvml_import": _pynvml_importable(),
|
| 75 |
"nvml_readable": nv is not None,
|
| 76 |
"nvml_mj": nv,
|
|
|
|
| 77 |
}
|
| 78 |
|
| 79 |
|
|
|
|
| 6 |
from __future__ import annotations
|
| 7 |
|
| 8 |
import json
|
| 9 |
+
import subprocess
|
| 10 |
import time
|
| 11 |
from pathlib import Path
|
| 12 |
from typing import Any
|
|
|
|
| 64 |
return None
|
| 65 |
|
| 66 |
|
| 67 |
+
def _cuda_inventory() -> dict[str, Any]:
|
| 68 |
+
"""Driver/runtime inventory. NVML readable ≠ CUDA trainable."""
|
| 69 |
+
torch_import = False
|
| 70 |
+
torch_version = None
|
| 71 |
+
cuda_available = False
|
| 72 |
+
cuda_device = None
|
| 73 |
+
nvidia_smi = None
|
| 74 |
+
try:
|
| 75 |
+
import torch # type: ignore
|
| 76 |
+
|
| 77 |
+
torch_import = True
|
| 78 |
+
torch_version = str(torch.__version__)
|
| 79 |
+
cuda_available = bool(torch.cuda.is_available())
|
| 80 |
+
if cuda_available:
|
| 81 |
+
cuda_device = str(torch.cuda.get_device_name(0))
|
| 82 |
+
except Exception:
|
| 83 |
+
pass
|
| 84 |
+
try:
|
| 85 |
+
proc = subprocess.run(["nvidia-smi", "-L"], capture_output=True, text=True, timeout=3)
|
| 86 |
+
if proc.returncode == 0 and proc.stdout.strip():
|
| 87 |
+
nvidia_smi = proc.stdout.strip().splitlines()[0][:200]
|
| 88 |
+
except Exception:
|
| 89 |
+
pass
|
| 90 |
+
return {
|
| 91 |
+
"torch_import": torch_import,
|
| 92 |
+
"torch_version": torch_version,
|
| 93 |
+
"cuda_available": cuda_available,
|
| 94 |
+
"cuda_device": cuda_device,
|
| 95 |
+
"nvidia_smi": nvidia_smi,
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
|
| 99 |
def hardware() -> dict[str, Any]:
|
| 100 |
"""Inventory only. Never a joule. RAPL/NVML readable ⇒ a later probe can MEASURE."""
|
| 101 |
rapl = _rapl_uj()
|
| 102 |
nv = _nvml_mj()
|
| 103 |
+
cuda = _cuda_inventory()
|
| 104 |
return {
|
| 105 |
"powercap_dir": POWERCAP.is_dir(),
|
| 106 |
"rapl_readable": rapl is not None,
|
|
|
|
| 108 |
"pynvml_import": _pynvml_importable(),
|
| 109 |
"nvml_readable": nv is not None,
|
| 110 |
"nvml_mj": nv,
|
| 111 |
+
**cuda,
|
| 112 |
}
|
| 113 |
|
| 114 |
|
index.html
CHANGED
|
@@ -37,7 +37,7 @@ a{color:var(--proof)}
|
|
| 37 |
<main>
|
| 38 |
<div class="eyebrow">SZL Holdings · Command lab · GitHub canonical · Hub operational</div>
|
| 39 |
<h1>Holographic command body. Fail closed.</h1>
|
| 40 |
-
<p class="lede">One kernel. Ten estate surfaces. Energy channel LIVE. Package joule MEASURED from RAPL/NVML. Inference joule MEASURED only when a kernel is wrapped. Never fabricated. Λ uniqueness is Conjecture 1 OPEN. Not a-11-oy.com. Not an ATO. Not an elevation.</p>
|
| 41 |
<div class="badges" id="badges"></div>
|
| 42 |
<div class="stage" id="stage"></div>
|
| 43 |
<div class="grid" id="metrics"></div>
|
|
@@ -47,6 +47,7 @@ a{color:var(--proof)}
|
|
| 47 |
<label><input type="checkbox" id="fabricate_joule"> Fabricate joule</label>
|
| 48 |
<button id="run">Run organ cycle</button>
|
| 49 |
<button id="wrap" type="button">Wrap kernel 1s</button>
|
|
|
|
| 50 |
</div>
|
| 51 |
<p class="eyebrow" style="margin-top:28px">Estate recapture</p>
|
| 52 |
<div class="surfaces" id="surfaces"></div>
|
|
@@ -105,8 +106,22 @@ async function wrap(){
|
|
| 105 |
['proven_trust','false'],
|
| 106 |
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 107 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
document.getElementById('run').onclick=cycle;
|
| 109 |
document.getElementById('wrap').onclick=wrap;
|
|
|
|
| 110 |
cycle();
|
| 111 |
estate();
|
| 112 |
</script>
|
|
|
|
| 37 |
<main>
|
| 38 |
<div class="eyebrow">SZL Holdings · Command lab · GitHub canonical · Hub operational</div>
|
| 39 |
<h1>Holographic command body. Fail closed.</h1>
|
| 40 |
+
<p class="lede">One kernel. Ten estate surfaces. Energy channel LIVE. Package joule MEASURED from RAPL/NVML. Inference joule MEASURED only when a kernel is wrapped. GPU train stays BLOCKED until CUDA and an approved job exist. Never fabricated. Λ uniqueness is Conjecture 1 OPEN. Not a-11-oy.com. Not an ATO. Not an elevation.</p>
|
| 41 |
<div class="badges" id="badges"></div>
|
| 42 |
<div class="stage" id="stage"></div>
|
| 43 |
<div class="grid" id="metrics"></div>
|
|
|
|
| 47 |
<label><input type="checkbox" id="fabricate_joule"> Fabricate joule</label>
|
| 48 |
<button id="run">Run organ cycle</button>
|
| 49 |
<button id="wrap" type="button">Wrap kernel 1s</button>
|
| 50 |
+
<button id="train" type="button">Train gate</button>
|
| 51 |
</div>
|
| 52 |
<p class="eyebrow" style="margin-top:28px">Estate recapture</p>
|
| 53 |
<div class="surfaces" id="surfaces"></div>
|
|
|
|
| 106 |
['proven_trust','false'],
|
| 107 |
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 108 |
}
|
| 109 |
+
async function trainGate(){
|
| 110 |
+
document.getElementById('out').textContent='train gate…';
|
| 111 |
+
const r=await fetch('/api/train');
|
| 112 |
+
const j=await r.json();
|
| 113 |
+
document.getElementById('out').textContent=JSON.stringify(j,null,2);
|
| 114 |
+
document.getElementById('badges').innerHTML=[
|
| 115 |
+
['train', j.decision||'BLOCKED'],
|
| 116 |
+
['cuda', String(!!(j.gpu&&j.gpu.cuda_available))],
|
| 117 |
+
['nvml', String(!!(j.gpu&&j.gpu.nvml_readable))],
|
| 118 |
+
['approved', String(j.approved===true)],
|
| 119 |
+
['proven_trust','false'],
|
| 120 |
+
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 121 |
+
}
|
| 122 |
document.getElementById('run').onclick=cycle;
|
| 123 |
document.getElementById('wrap').onclick=wrap;
|
| 124 |
+
document.getElementById('train').onclick=trainGate;
|
| 125 |
cycle();
|
| 126 |
estate();
|
| 127 |
</script>
|
server.py
CHANGED
|
@@ -22,6 +22,7 @@ sys.path.insert(0, str(HERE / "python"))
|
|
| 22 |
try:
|
| 23 |
from energy import hardware, measure_run, probe
|
| 24 |
from kernel import burn_kernel, clamp_duration, evaluate_anatomy, selftest
|
|
|
|
| 25 |
except ImportError:
|
| 26 |
# Immune flatten historically copied only server.py. Keep a local fallback.
|
| 27 |
import hashlib
|
|
@@ -372,7 +373,7 @@ a{color:var(--proof)}
|
|
| 372 |
<main>
|
| 373 |
<div class="eyebrow">SZL Holdings · Command lab · GitHub canonical · Hub operational</div>
|
| 374 |
<h1>Holographic command body. Fail closed.</h1>
|
| 375 |
-
<p class="lede">One kernel. Ten estate surfaces. Energy channel LIVE. Package joule MEASURED from RAPL/NVML. Inference joule MEASURED only when a kernel is wrapped. Never fabricated. Λ uniqueness is Conjecture 1 OPEN. Not a-11-oy.com. Not an ATO. Not an elevation.</p>
|
| 376 |
<div class="badges" id="badges"></div>
|
| 377 |
<div class="stage" id="stage"></div>
|
| 378 |
<div class="grid" id="metrics"></div>
|
|
@@ -382,6 +383,7 @@ a{color:var(--proof)}
|
|
| 382 |
<label><input type="checkbox" id="fabricate_joule"> Fabricate joule</label>
|
| 383 |
<button id="run">Run organ cycle</button>
|
| 384 |
<button id="wrap" type="button">Wrap kernel 1s</button>
|
|
|
|
| 385 |
</div>
|
| 386 |
<p class="eyebrow" style="margin-top:28px">Estate recapture</p>
|
| 387 |
<div class="surfaces" id="surfaces"></div>
|
|
@@ -440,8 +442,22 @@ async function wrap(){
|
|
| 440 |
['proven_trust','false'],
|
| 441 |
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 442 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
document.getElementById('run').onclick=cycle;
|
| 444 |
document.getElementById('wrap').onclick=wrap;
|
|
|
|
| 445 |
cycle();
|
| 446 |
estate();
|
| 447 |
</script>
|
|
@@ -450,8 +466,15 @@ estate();
|
|
| 450 |
"""
|
| 451 |
|
| 452 |
ENERGY_STATE = {"last_inference": None}
|
| 453 |
-
|
| 454 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
HTML_PATHS = {"/", "/index.html"}
|
| 456 |
|
| 457 |
|
|
@@ -514,6 +537,13 @@ class Handler(BaseHTTPRequestHandler):
|
|
| 514 |
if path == "/api/estate":
|
| 515 |
self._send(200, recapture_estate())
|
| 516 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
if path in {"/api/organs/integrity", "/v1/organs/integrity"}:
|
| 518 |
def run():
|
| 519 |
return evaluate_anatomy(
|
|
|
|
| 22 |
try:
|
| 23 |
from energy import hardware, measure_run, probe
|
| 24 |
from kernel import burn_kernel, clamp_duration, evaluate_anatomy, selftest
|
| 25 |
+
from train import gate as train_gate, toy as train_toy
|
| 26 |
except ImportError:
|
| 27 |
# Immune flatten historically copied only server.py. Keep a local fallback.
|
| 28 |
import hashlib
|
|
|
|
| 373 |
<main>
|
| 374 |
<div class="eyebrow">SZL Holdings · Command lab · GitHub canonical · Hub operational</div>
|
| 375 |
<h1>Holographic command body. Fail closed.</h1>
|
| 376 |
+
<p class="lede">One kernel. Ten estate surfaces. Energy channel LIVE. Package joule MEASURED from RAPL/NVML. Inference joule MEASURED only when a kernel is wrapped. GPU train stays BLOCKED until CUDA and an approved job exist. Never fabricated. Λ uniqueness is Conjecture 1 OPEN. Not a-11-oy.com. Not an ATO. Not an elevation.</p>
|
| 377 |
<div class="badges" id="badges"></div>
|
| 378 |
<div class="stage" id="stage"></div>
|
| 379 |
<div class="grid" id="metrics"></div>
|
|
|
|
| 383 |
<label><input type="checkbox" id="fabricate_joule"> Fabricate joule</label>
|
| 384 |
<button id="run">Run organ cycle</button>
|
| 385 |
<button id="wrap" type="button">Wrap kernel 1s</button>
|
| 386 |
+
<button id="train" type="button">Train gate</button>
|
| 387 |
</div>
|
| 388 |
<p class="eyebrow" style="margin-top:28px">Estate recapture</p>
|
| 389 |
<div class="surfaces" id="surfaces"></div>
|
|
|
|
| 442 |
['proven_trust','false'],
|
| 443 |
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 444 |
}
|
| 445 |
+
async function trainGate(){
|
| 446 |
+
document.getElementById('out').textContent='train gate…';
|
| 447 |
+
const r=await fetch('/api/train');
|
| 448 |
+
const j=await r.json();
|
| 449 |
+
document.getElementById('out').textContent=JSON.stringify(j,null,2);
|
| 450 |
+
document.getElementById('badges').innerHTML=[
|
| 451 |
+
['train', j.decision||'BLOCKED'],
|
| 452 |
+
['cuda', String(!!(j.gpu&&j.gpu.cuda_available))],
|
| 453 |
+
['nvml', String(!!(j.gpu&&j.gpu.nvml_readable))],
|
| 454 |
+
['approved', String(j.approved===true)],
|
| 455 |
+
['proven_trust','false'],
|
| 456 |
+
].map(([k,v])=>`<span class="badge">${k} <b>${v}</b></span>`).join('');
|
| 457 |
+
}
|
| 458 |
document.getElementById('run').onclick=cycle;
|
| 459 |
document.getElementById('wrap').onclick=wrap;
|
| 460 |
+
document.getElementById('train').onclick=trainGate;
|
| 461 |
cycle();
|
| 462 |
estate();
|
| 463 |
</script>
|
|
|
|
| 466 |
"""
|
| 467 |
|
| 468 |
ENERGY_STATE = {"last_inference": None}
|
| 469 |
+
try:
|
| 470 |
+
train_gate # noqa: B018
|
| 471 |
+
except NameError:
|
| 472 |
+
def train_gate(*, job=None):
|
| 473 |
+
return {"ok": False, "decision": "BLOCKED", "honesty": "UNAVAILABLE", "missing": ["TRAIN_MODULE_ABSENT"], "proven_trust": False, "note": "train.py missing on this flatten. Never a fabricated train."}
|
| 474 |
+
def train_toy(*, duration_s=1.0):
|
| 475 |
+
return train_gate()
|
| 476 |
+
|
| 477 |
+
JSON_PATHS = {"/healthz", "/readyz", "/api/energy", "/api/energy/hardware", "/api/energy/inference", "/api/train", "/api/train/toy", "/api/organs/integrity", "/v1/organs/integrity", "/api/estate"}
|
| 478 |
HTML_PATHS = {"/", "/index.html"}
|
| 479 |
|
| 480 |
|
|
|
|
| 537 |
if path == "/api/estate":
|
| 538 |
self._send(200, recapture_estate())
|
| 539 |
return
|
| 540 |
+
if path == "/api/train":
|
| 541 |
+
job = (qs.get("job") or [None])[0]
|
| 542 |
+
self._send(200, train_gate(job=job))
|
| 543 |
+
return
|
| 544 |
+
if path == "/api/train/toy":
|
| 545 |
+
self._send(200, train_toy())
|
| 546 |
+
return
|
| 547 |
if path in {"/api/organs/integrity", "/v1/organs/integrity"}:
|
| 548 |
def run():
|
| 549 |
return evaluate_anatomy(
|
train.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
# Copyright 2026 SZL Holdings
|
| 4 |
+
# Signed-off-by: Lutar, Stephen P. <stephenlutar2@gmail.com>
|
| 5 |
+
"""Train gate. Fail closed. GPU train is not a meter, and a meter is not a train.
|
| 6 |
+
|
| 7 |
+
T4 NVML can MEASURE board joules without a CUDA runtime in this hologram.
|
| 8 |
+
Unsloth QLoRA lives on owner metal (szl-forge via szl-gpu-bridge).
|
| 9 |
+
WILLAY / KHIPU-R3 / Waman stay NOT_APPROVED. Never a fabricated train.
|
| 10 |
+
"""
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import json
|
| 14 |
+
from typing import Any
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
from energy import hardware
|
| 18 |
+
except ImportError: # pragma: no cover - flatten fallback
|
| 19 |
+
def hardware() -> dict[str, Any]: # type: ignore
|
| 20 |
+
return {
|
| 21 |
+
"rapl_readable": False,
|
| 22 |
+
"nvml_readable": False,
|
| 23 |
+
"pynvml_import": False,
|
| 24 |
+
"torch_import": False,
|
| 25 |
+
"cuda_available": False,
|
| 26 |
+
"cuda_device": None,
|
| 27 |
+
"nvidia_smi": None,
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
REFUSED = {
|
| 32 |
+
"willay-v1": {
|
| 33 |
+
"artifact_class": "trained_model_or_adapter",
|
| 34 |
+
"priority": 1,
|
| 35 |
+
"state": "REJECTED_WITH_REASON",
|
| 36 |
+
"rights_status": "PENDING",
|
| 37 |
+
"blockers": [
|
| 38 |
+
"NOT_APPROVED",
|
| 39 |
+
"RIGHTS_NOT_CLEARED",
|
| 40 |
+
"BASE_REVISION_NOT_EXACT",
|
| 41 |
+
"DATASET_REVISION_NOT_EXACT",
|
| 42 |
+
"IMAGE_DIGEST_INVALID",
|
| 43 |
+
"COST_CAP_NOT_SET",
|
| 44 |
+
"JOB_COMMAND_NOT_BOUND",
|
| 45 |
+
],
|
| 46 |
+
},
|
| 47 |
+
"khipu-r3": {
|
| 48 |
+
"artifact_class": "trained_adapter",
|
| 49 |
+
"priority": 2,
|
| 50 |
+
"state": "REJECTED_WITH_REASON",
|
| 51 |
+
"rights_status": "PENDING",
|
| 52 |
+
"blockers": [
|
| 53 |
+
"NOT_APPROVED",
|
| 54 |
+
"RIGHTS_NOT_CLEARED",
|
| 55 |
+
"BASE_REVISION_NOT_EXACT",
|
| 56 |
+
"DATASET_REVISION_NOT_EXACT",
|
| 57 |
+
"IMAGE_DIGEST_INVALID",
|
| 58 |
+
"COST_CAP_NOT_SET",
|
| 59 |
+
"JOB_COMMAND_NOT_BOUND",
|
| 60 |
+
],
|
| 61 |
+
},
|
| 62 |
+
"waman-killinchu-eye": {
|
| 63 |
+
"artifact_class": "trained_object_detection_model",
|
| 64 |
+
"priority": 3,
|
| 65 |
+
"state": "REJECTED_WITH_REASON",
|
| 66 |
+
"rights_status": "REQUIRES_DATA_PRIVACY_EXPORT_DUAL_USE_REVIEW",
|
| 67 |
+
"blockers": [
|
| 68 |
+
"NOT_APPROVED",
|
| 69 |
+
"RIGHTS_NOT_CLEARED",
|
| 70 |
+
"BASE_REVISION_NOT_EXACT",
|
| 71 |
+
"DATASET_REVISION_NOT_EXACT",
|
| 72 |
+
"IMAGE_DIGEST_INVALID",
|
| 73 |
+
"COST_CAP_NOT_SET",
|
| 74 |
+
"JOB_COMMAND_NOT_BOUND",
|
| 75 |
+
],
|
| 76 |
+
},
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
HOLOGRAM_GAPS = (
|
| 80 |
+
"CUDA_RUNTIME_ABSENT",
|
| 81 |
+
"TORCH_ABSENT",
|
| 82 |
+
"UNSLOTH_ABSENT",
|
| 83 |
+
"HOLOGRAM_IS_PYTHON_SLIM",
|
| 84 |
+
)
|
| 85 |
+
REGISTRY_GAPS = (
|
| 86 |
+
"NOT_APPROVED",
|
| 87 |
+
"RIGHTS_NOT_CLEARED",
|
| 88 |
+
"BASE_REVISION_NOT_EXACT",
|
| 89 |
+
"DATASET_REVISION_NOT_EXACT",
|
| 90 |
+
"IMAGE_DIGEST_INVALID",
|
| 91 |
+
"COST_CAP_NOT_SET",
|
| 92 |
+
"JOB_COMMAND_NOT_BOUND",
|
| 93 |
+
"GPU_BRIDGE_NEVER_DISPATCH",
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def _missing(hw: dict[str, Any]) -> list[str]:
|
| 98 |
+
missing: list[str] = []
|
| 99 |
+
if not hw.get("cuda_available"):
|
| 100 |
+
missing.append("CUDA_RUNTIME_ABSENT")
|
| 101 |
+
if not hw.get("torch_import"):
|
| 102 |
+
missing.append("TORCH_ABSENT")
|
| 103 |
+
if not hw.get("nvidia_smi"):
|
| 104 |
+
missing.append("NVIDIA_SMI_ABSENT")
|
| 105 |
+
missing.extend(REGISTRY_GAPS)
|
| 106 |
+
return missing
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def gate(*, job: str | None = None) -> dict[str, Any]:
|
| 110 |
+
"""Always BLOCKED until CUDA exists AND a registry job is approved.
|
| 111 |
+
|
| 112 |
+
NVML readable ≠ CUDA trainable. Do not elevate. Do not train willay.
|
| 113 |
+
"""
|
| 114 |
+
hw = hardware()
|
| 115 |
+
missing = _missing(hw)
|
| 116 |
+
wanted = (job or "").strip().lower() or None
|
| 117 |
+
refused = None
|
| 118 |
+
if wanted:
|
| 119 |
+
for key, row in REFUSED.items():
|
| 120 |
+
if wanted in {key, key.replace("-", ""), key.split("-")[0]}:
|
| 121 |
+
refused = {"id": key, **row}
|
| 122 |
+
break
|
| 123 |
+
if refused is None:
|
| 124 |
+
refused = {
|
| 125 |
+
"id": wanted,
|
| 126 |
+
"state": "REJECTED_WITH_REASON",
|
| 127 |
+
"blockers": ["UNKNOWN_JOB", "NOT_APPROVED"],
|
| 128 |
+
}
|
| 129 |
+
cuda = bool(hw.get("cuda_available"))
|
| 130 |
+
return {
|
| 131 |
+
"ok": False,
|
| 132 |
+
"decision": "BLOCKED",
|
| 133 |
+
"honesty": "UNAVAILABLE",
|
| 134 |
+
"channel": "LIVE",
|
| 135 |
+
"submit_this_run": False,
|
| 136 |
+
"approved": False,
|
| 137 |
+
"proven_trust": False,
|
| 138 |
+
"conjecture_1": "OPEN",
|
| 139 |
+
"job": refused,
|
| 140 |
+
"missing": missing,
|
| 141 |
+
"hologram_gaps": [g for g in HOLOGRAM_GAPS if g in missing or g == "HOLOGRAM_IS_PYTHON_SLIM" or g == "UNSLOTH_ABSENT"],
|
| 142 |
+
"registry_gaps": list(REGISTRY_GAPS),
|
| 143 |
+
"gpu": {
|
| 144 |
+
"nvml_readable": bool(hw.get("nvml_readable")),
|
| 145 |
+
"pynvml_import": bool(hw.get("pynvml_import")),
|
| 146 |
+
"torch_import": bool(hw.get("torch_import")),
|
| 147 |
+
"torch_version": hw.get("torch_version"),
|
| 148 |
+
"cuda_available": cuda,
|
| 149 |
+
"cuda_device": hw.get("cuda_device"),
|
| 150 |
+
"nvidia_smi": hw.get("nvidia_smi"),
|
| 151 |
+
},
|
| 152 |
+
"owner_metal": {
|
| 153 |
+
"kit": "szl-holdings/szl-forge",
|
| 154 |
+
"bridge": "szl-holdings/szl-gpu-bridge",
|
| 155 |
+
"note": "Unsloth QLoRA is owner-metal. gpu-bridge attempts 1–9 are NEVER_DISPATCH evidence. Not this T4 hologram.",
|
| 156 |
+
},
|
| 157 |
+
"existing_adapters": [
|
| 158 |
+
"SZLHOLDINGS/chaski",
|
| 159 |
+
"SZLHOLDINGS/chaski-5050",
|
| 160 |
+
"SZLHOLDINGS/KHIPU-R2",
|
| 161 |
+
"SZLHOLDINGS/SZL-Khipu-1.5B",
|
| 162 |
+
"SZLHOLDINGS/SZL-Forge-1.5B-ReceiptAgent",
|
| 163 |
+
"SZLHOLDINGS/szl-receiptagent-qwen35-0.8b-v2",
|
| 164 |
+
],
|
| 165 |
+
"note": (
|
| 166 |
+
"T4 is mounted. NVML can MEASURE board joules. This hologram is "
|
| 167 |
+
"python:3.12-slim — no CUDA runtime, no Unsloth, no approved job. "
|
| 168 |
+
"Existing Hub adapters are prior trains, not a new GPU train. "
|
| 169 |
+
"WILLAY / KHIPU-R3 / Waman stay REJECTED_WITH_REASON. Never a fabricated train."
|
| 170 |
+
),
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def toy(*, duration_s: float = 1.0) -> dict[str, Any]:
|
| 175 |
+
"""Tiny CUDA fit. Refused when CUDA is absent. Never a CPU stand-in billed as GPU train."""
|
| 176 |
+
del duration_s # reserved for a future CUDA wrap
|
| 177 |
+
g = gate()
|
| 178 |
+
g["kind"] = "toy_cuda_fit"
|
| 179 |
+
g["trained"] = False
|
| 180 |
+
g["weights"] = None
|
| 181 |
+
g["reason"] = "CUDA_RUNTIME_ABSENT. Toy GPU fit refused. A CPU fit is not a GPU train."
|
| 182 |
+
if g["gpu"]["cuda_available"]:
|
| 183 |
+
# Reachable only after a CUDA hologram exists. Still refuse registry jobs.
|
| 184 |
+
g["reason"] = (
|
| 185 |
+
"CUDA is up. Registry still NOT_APPROVED. Toy fit is not willay, "
|
| 186 |
+
"not khipu-r3, not Waman, not Unsloth. Compiler stays BLOCKED."
|
| 187 |
+
)
|
| 188 |
+
return g
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
if __name__ == "__main__":
|
| 192 |
+
print(json.dumps({"gate": gate(), "toy": toy()}, indent=2))
|