GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bandwidth A-Z: hash-only rescue, theta-only miner, lazy trace, H=512,… · CortexLM/hypertrain@1df4832

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • experiments/gpu_network_v2
    • orchestrate.py
  • scripts
    • launch_cuda_run.sh
    • ops
      • auditors.sh
      • backend_bootstrap.py
      • hf_seed.py
      • live_operator.py
      • manifest
        • od_large_manifest.py
      • prepare_record.py
      • prepare_runtime.py
      • probe_and_launch.py
      • rescue_dedup.py
      • rescue_parallel.py
      • task8-deps.py
      • task8-materialize-roots.py
  • src/hypertrain
    • auditor
      • island_bisect.py
    • challenge
      • store.py
    • datasets
      • build.py
      • registry.json
    • data
      • store.py
    • gpu_ops
      • network_qualification.py
    • miner
      • cli.py
      • core.py
      • island_launch.py
      • island_worker.py
    • protocol
      • messages_v2.py
    • trainer
      • island.py
  • tests
    • auditor
      • test_island_lazy_window.py
    • datasets
      • test_datasets.py
    • data
      • test_parts.py
    • gpu_ops
      • test_network_gpu_qualification.py
      • test_network_lifecycle.py
      • test_network_role_dispatch.py
    • miner
      • test_client_network_v2.py
      • test_island_launch_v2.py
    • protocol
      • test_network_v2.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎experiments/gpu_network_v2/orchestrate.py‎

Copy file name to clipboardExpand all lines: experiments/gpu_network_v2/orchestrate.py
+192-70Lines changed: 192 additions & 70 deletions
Large diffs are not rendered by default.
Collapse file

‎scripts/launch_cuda_run.sh‎

Copy file name to clipboardExpand all lines: scripts/launch_cuda_run.sh
+18-3Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ umask 077
1717

1818
TAG=${TAG:-v1}
1919
RD=${RD:-/data/role-dispatch}
20-
T=${TOOLS:-$RD/tools}
2120
E2E=${E2E:-/root/e2e-deploy-wt/hypertrain-e2e-b/.e2e}
2221
OUT=${OUT:-$RD/manifest/out-$TAG}
2322
JOB=${JOB:-$RD/manifest/job-$TAG}
@@ -29,6 +28,7 @@ PY=${PY:-$RD/runtime/venv/bin/python}
2928
MINER_SRC=${MINER_SRC:-/data/pydeps/hypertrain}
3029
REPO=${REPO:-$(cd "$(dirname "$0")/.." && pwd)}
3130
FIX_BASE=${FIX_BASE:-1a8f91e}
31+
T=${TOOLS:-$REPO/scripts/ops}
3232
MINER_SSH=${MINER_SSH:-}
3333
MINER_KEY=${MINER_KEY:-}
3434
# Signed floor: cutoff >= admitted + staging 1800 s + qualification 9600 s + hard margin 1800 s;
@@ -77,7 +77,8 @@ export PYTHONPATH=$HT_TREE/src:$HT_TREE/scripts:$HT_TREE:/data/pydeps:$RD/runtim
7777
mkdir -p "$STATE"
7878

7979
STAGE=preflight
80-
for f in "$T"/{prepare_record.py,task8-deps.py,rescue_parallel.py,task8-materialize-roots.py} \
80+
for f in "$T"/{prepare_record.py,task8-deps.py,hf_seed.py,rescue_parallel.py,rescue_dedup.py} \
81+
"$T"/{task8-materialize-roots.py,prepare_runtime.py} \
8182
"$T"/{backend_bootstrap.py,live_operator.py,auditors.sh} \
8283
"$E2E/beacon/pusher.py" "$E2E/relays/build_relay_configs.py" "$E2E/relays/deploy_relay.sh" \
8384
"$OUT/manifest-envelope.json" "$OUT/manifest.json" "$OUT/profile.json" "$JOB/job.json" \
@@ -120,14 +121,28 @@ case $rc in 0) BACKEND=unregistered ;; 3) BACKEND=cuda ;; 4) die "run ${RID:0:8}
120121
BUNDLE=$STATE/bundle
121122
rm -rf "$BUNDLE" && mkdir -p "$BUNDLE" && cp -a "$MINER_SRC" "$BUNDLE/hypertrain"
122123
find "$BUNDLE" -name __pycache__ -prune -exec rm -rf {} +
124+
# Diff FIX_BASE against the working tree (not HEAD): uncommitted miner changes ship too.
123125
if ! grep -q '_retrying("PUT object' "$BUNDLE/hypertrain/miner/core.py"; then
124-
git -C "$REPO" diff "$FIX_BASE" HEAD -- src/hypertrain/miner/core.py src/hypertrain/data/store.py \
126+
git -C "$REPO" diff "$FIX_BASE" -- src/hypertrain/miner/core.py src/hypertrain/data/store.py \
125127
| patch -p3 --forward --quiet -d "$BUNDLE/hypertrain" || die "transport fixes do not apply onto $MINER_SRC"
126128
fi
127129
grep -q '_retrying("PUT object' "$BUNDLE/hypertrain/miner/core.py" || die "bundle lacks the PUT retry fix"
128130
grep -q 'def _parts' "$BUNDLE/hypertrain/data/store.py" || die "bundle lacks the parallel part fetch"
131+
grep -q '^UPLOAD_WORKERS = ' "$BUNDLE/hypertrain/miner/core.py" || die "bundle lacks the parallel part PUT"
132+
grep -q 'def _local_input' "$BUNDLE/hypertrain/miner/core.py" || die "bundle lacks the theta-only input reuse"
133+
# store.py has no master-side divergence: the bundle copy must be the working tree's bytes.
134+
cmp -s "$REPO/src/hypertrain/data/store.py" "$BUNDLE/hypertrain/data/store.py" \
135+
|| die "bundle data/store.py differs from the working tree"
129136
log "PREFLIGHT_OK run=$RID image=$IMAGE job_deadline=$JD backend=$BACKEND miner=${MINER_SSH:-unset}"
130137
if [ "$MODE" = --dry-run ]; then log "DRY_RUN_DONE no provider call, nothing spent"; exit 0; fi
138+
# Runtime uid 65532 and the master container (sees /data only) cannot read a /root checkout:
139+
# run a frozen copy of the tools from /data.
140+
if [ "${T#"$RD"/}" = "$T" ]; then
141+
TS=$RD/ops-$TAG
142+
install -d -o 65532 -g 65532 -m 0700 "$TS"
143+
for f in "$T"/*.py "$T"/*.sh; do install -o 65532 -g 65532 -m 0700 "$f" "$TS/"; done
144+
T=$TS
145+
fi
131146

132147
if [ ! -e "$STATE/window" ]; then
133148
A=$(date +%s); CUT=$((A + WINDOW)); [ "$CUT" -le "$JD" ] || CUT=$JD
Collapse file

‎scripts/ops/auditors.sh‎

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
# Two independent contract-2 auditor clients (auditor-0 -> manifest slot 0, auditor-1 -> slot 1).
3+
# CUDA replay runs master-side (store.execute_audit_v2 -> _role_launch "audit" -> owned host).
4+
# Usage: auditors.sh stage | check RUN_ID | once RUN_ID | start RUN_ID | stop | cleanup
5+
set -euo pipefail
6+
IMG=${HT_IMAGE:-ghcr.io/cortexlm/hypertrain@sha256:58e2b42713a9065758796408e7aea4fb3260ccfaa5ad7bad4859fd87320c93d6}
7+
API=${HT_API:-http://cortex-challenge-hypertrain:8000}
8+
NET=${HT_NET:-cortex-challenges}
9+
SRC=${HT_AUDITOR_SEEDS:-/root/.config/cortex-secrets/od-large-e2e}
10+
BASE=/data/role-dispatch/auditors
11+
NAMES=(hypertrain-auditor-0 hypertrain-auditor-1)
12+
cmd=${1:?stage|check|once|start|stop|cleanup}; RID=${2:-}
13+
need_rid() { [[ $RID =~ ^[0-9a-f]{64}$ ]] || { echo "RUN_ID (64 hex) required" >&2; exit 2; }; }
14+
flags() { echo --network "$NET" --read-only --user 65532:65532 --cap-drop ALL --security-opt no-new-privileges \
15+
--tmpfs /tmp:size=64m -e PYTHONPATH=/data/pydeps -e HOME=/tmp -v /data/pydeps:/data/pydeps:ro \
16+
-v "$BASE/auditor-$1":/state:ro --entrypoint sh; }
17+
cli() { echo "python -m hypertrain.auditor --api $API --run-id $RID --contract 2 --keyfile /state/auditor.seed"; }
18+
present() { # exact task-owned containers that exist now; docker failure propagates
19+
local all n; all=$(docker ps -a --format '{{.Names}}') || exit 1
20+
for n in "${NAMES[@]}"; do grep -qxF "$n" <<<"$all" && echo "$n"; done; return 0; }
21+
remove_owned() {
22+
local live; live=$(present) || exit 1
23+
[[ -z $live ]] || docker rm -f $live || exit 1
24+
live=$(present) || exit 1
25+
[[ -z $live ]] || { echo "auditor containers still present: $live" >&2; exit 1; }
26+
echo "auditor containers absent"; }
27+
case $cmd in
28+
stage) install -d -o root -g root -m 0755 $BASE
29+
for i in 0 1; do install -d -o 65532 -g 65532 -m 0700 $BASE/auditor-$i
30+
install -o 65532 -g 65532 -m 0600 $SRC/auditor-$i.seed $BASE/auditor-$i/auditor.seed; done
31+
stat -c '%a %u:%g %n' $BASE/auditor-*/auditor.seed ;;
32+
check) need_rid # GET only: contract 2 and this identity at its exact manifest slot
33+
for i in 0 1; do docker run --rm $(flags $i) "$IMG" -c "python - <<'EOF'
34+
import hypertrain.trainer, httpx
35+
from pathlib import Path
36+
from hypertrain.miner.core import load_keyfile
37+
k=load_keyfile(Path('/state/auditor.seed')); r=httpx.get('$API/v2/runs/$RID',timeout=30); r.raise_for_status(); j=r.json()
38+
aud=j['manifest_envelope']['body']['training']['auditors']
39+
assert j['contract']==2, j.get('contract')
40+
assert len(aud)>$i and aud[$i]==k.ss58, ('slot $i', k.ss58, aud)
41+
print('READY auditor-$i', k.ss58, 'slot $i')
42+
EOF"; done ;;
43+
once) need_rid # proof: each identity must settle one job with result MATCH; empty queue fails
44+
for i in 0 1; do out=$(docker run --rm $(flags $i) "$IMG" -c "$(cli) --once"); echo "$out"
45+
grep -q '"result": "MATCH"' <<<"$out" || { echo "auditor-$i: no MATCH verdict" >&2; exit 1; }
46+
echo "auditor-$i MATCH"; done ;;
47+
start) need_rid # production loop: re-poll every 20s in-container; a failed poll (transient 5xx while the
48+
# master is busy) is logged with its exit code and retried, never a container restart
49+
for i in 0 1; do docker run -d --name ${NAMES[$i]} --restart always --label io.cortex.task=auditors \
50+
--log-opt max-size=20m $(flags $i) "$IMG" -c "while :; do $(cli) || echo AUDITOR_POLL_EXIT=\$?; sleep 20; done"; done ;;
51+
stop) remove_owned ;;
52+
cleanup) remove_owned
53+
rm -f $BASE/auditor-0/auditor.seed $BASE/auditor-1/auditor.seed
54+
rmdir $BASE/auditor-0 $BASE/auditor-1 $BASE
55+
test ! -e $BASE && echo "auditors cleanup: seeds+state absent" ;;
56+
*) echo "unknown $cmd" >&2; exit 2 ;;
57+
esac
Collapse file

‎scripts/ops/backend_bootstrap.py‎

Copy file name to clipboard
+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python3
2+
"""Bootstrap the live CUDA backend from verified two-host qualification, before run POST."""
3+
4+
import argparse
5+
import hashlib
6+
import json
7+
import sys
8+
from pathlib import Path
9+
10+
import hypertrain.trainer # noqa: F401 determinism setup before any torch import
11+
from hypertrain.beacon import parse_round
12+
from hypertrain.challenge.app import Config, load_coord_key
13+
from hypertrain.challenge.store import ChallengeStore
14+
from hypertrain.data.store import LocalFSStore
15+
from hypertrain.gpu_ops import network_qualification as engine
16+
from hypertrain.gpu_ops.journal import fsha
17+
from hypertrain.miner.core import load_keyfile
18+
from hypertrain.protocol import envelope_v2
19+
from hypertrain.protocol.jcs import canonicalize
20+
from hypertrain.protocol.messages_v2 import RunManifestV2
21+
22+
p = argparse.ArgumentParser(description=__doc__)
23+
p.add_argument("--manifest-envelope", type=Path, required=True)
24+
p.add_argument("--owner-seed", type=Path, required=True)
25+
p.add_argument("--config", type=Path, nargs=2, required=True, help="h0 h1: <output>/config.json")
26+
p.add_argument("--result", type=Path, nargs=2, required=True, help="h0 h1: <output>/result.json")
27+
a = p.parse_args()
28+
29+
raw = a.manifest_envelope.read_bytes()
30+
env = envelope_v2.parse_envelope(raw)
31+
if env.type != "RunManifestV2" or not envelope_v2.verify_envelope(raw):
32+
sys.exit("manifest envelope is not a verified RunManifestV2")
33+
manifest = RunManifestV2.model_validate(env.body)
34+
cfg = Config.from_env()
35+
owner = load_keyfile(a.owner_seed)
36+
if cfg.owner_hotkey is None or owner.ss58 != cfg.owner_hotkey or env.signer != cfg.owner_hotkey:
37+
sys.exit("owner seed / manifest signer is not HYPERTRAIN_OWNER_HOTKEY")
38+
39+
# The existing verifier runs before any Receipt is sealed or store opened.
40+
for config_path in a.config:
41+
job = engine.check_inputs(engine.Qualification.model_validate_json(config_path.read_bytes()))
42+
if job.manifest != manifest:
43+
sys.exit(f"{config_path}: qualification seed job binds another manifest")
44+
verdict = engine.compare(list(a.result), manifest)
45+
if verdict != {"two_host_bitwise_match": True, "workload_allowed": False}:
46+
sys.exit(f"two-host comparison did not match: {verdict}")
47+
48+
ref = manifest.training.reference_spec
49+
evidence = {
50+
"run_id": manifest.run_id(),
51+
"backend": "cuda",
52+
"reference_hash": hashlib.sha256(canonicalize(ref.model_dump(mode="json"))).hexdigest(),
53+
"layout_hash": ref.layout.model_dump_json(),
54+
"configs": [fsha(c) for c in a.config],
55+
"results": [fsha(r) for r in a.result],
56+
"summaries": [
57+
fsha(r.parent / f"round-{w}/published/rank-{k}/summary.json")
58+
for r in a.result
59+
for w in range(2)
60+
for k in range(ref.layout.n_gpus)
61+
],
62+
}
63+
authority = hashlib.sha256(canonicalize(evidence)).hexdigest()
64+
65+
store = ChallengeStore(
66+
cfg.state_dir,
67+
cfg.params,
68+
load_coord_key(cfg.coord_key_file),
69+
cfg.owner_hotkey,
70+
parse_round,
71+
LocalFSStore(cfg.state_dir / "objects"),
72+
)
73+
try:
74+
now = store._now(store._db)
75+
receipt = envelope_v2.seal(
76+
owner,
77+
"Receipt",
78+
manifest.run_id(),
79+
{"w": 0, "commit_hash": authority, "received_round": now},
80+
now + 100,
81+
)
82+
store._bootstrap_backend_v2(manifest, tuple(a.config), tuple(a.result), canonicalize(receipt))
83+
print(
84+
json.dumps(
85+
{"run_id": manifest.run_id(), "received_round": now, "authority_hash": authority}
86+
)
87+
)
88+
finally:
89+
store.close()
Collapse file

‎scripts/ops/hf_seed.py‎

Copy file name to clipboard
+104Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"""Rebuild seed objects on a host from the pinned HF genesis checkpoint instead of uploading them.
2+
3+
A seed object (start_state, ef_in) is a safetensors file whose tensors are either all zero or a
4+
`theta/<name>` copy of the genesis checkpoint's `<name>`. plan() derives that layout from the
5+
controller's local file; the host gets only the header (~100 KB) and a copy list, downloads the
6+
checkpoint with parallel range requests and writes header + zeros + theta. The caller proves the
7+
result with the usual size+sha256 check and falls back to uploading on any mismatch.
8+
"""
9+
10+
import json
11+
import shlex
12+
import struct
13+
from pathlib import Path
14+
15+
REPO_ID = "OpenType/neon-1.2-genesis"
16+
# Resolved 2026-10-15 via https://huggingface.co/api/models/OpenType/neon-1.2-genesis
17+
REVISION = "1aa51eb5561719044f206061ba63a0d8e94ab5b0"
18+
URL = f"https://huggingface.co/{REPO_ID}/resolve/{REVISION}/model.safetensors"
19+
SIZE = 1_415_480_056
20+
SHA256 = "c2b614d2353af47583d4f0604db006e04430a6e84f16066161e748e7fc0b6aa9"
21+
RANGES = 8
22+
CHUNK = 16 << 20
23+
24+
25+
def plan(local: Path) -> tuple[bytes, list[list]] | None:
26+
"""(header bytes, copy list) for `local`, or None when it is not header + zeros + theta."""
27+
with local.open("rb") as f:
28+
raw = f.read(8)
29+
head = raw + f.read(struct.unpack("<Q", raw)[0])
30+
tensors = json.loads(head[8:])
31+
tensors.pop("__metadata__", None)
32+
base = len(head)
33+
if base + max(t["data_offsets"][1] for t in tensors.values()) != local.stat().st_size:
34+
return None
35+
copy = []
36+
for name, t in sorted(tensors.items(), key=lambda kv: kv[1]["data_offsets"][0]):
37+
lo, hi = t["data_offsets"]
38+
f.seek(base + lo)
39+
left, zero = hi - lo, True
40+
while left and zero:
41+
b = f.read(min(left, CHUNK))
42+
zero = bool(b) and b.count(0) == len(b)
43+
left -= len(b)
44+
if zero:
45+
continue
46+
if not name.startswith("theta/"):
47+
return None
48+
copy.append([base + lo, name.removeprefix("theta/"), hi - lo, t["dtype"], t["shape"]])
49+
return head, copy
50+
51+
52+
def payload(head: bytes, copy: list[list], out: str, src: str, size: int) -> bytes:
53+
spec = json.dumps({"out": out, "src": src, "size": size, "copy": copy}).encode()
54+
return struct.pack("<Q", len(spec)) + spec + head
55+
56+
57+
# Host side: stdin = payload(); checks every copied tensor's dtype/shape/size against the
58+
# downloaded checkpoint header; zeros are a sparse truncate.
59+
BUILD = r"""
60+
import json, os, struct, sys
61+
data = sys.stdin.buffer.read()
62+
n = struct.unpack("<Q", data[:8])[0]
63+
spec, head = json.loads(data[8:8 + n]), data[8 + n:]
64+
part = spec["out"] + ".hf-part"
65+
with open(part, "wb") as f:
66+
f.write(head)
67+
f.truncate(spec["size"])
68+
if spec["copy"]:
69+
src = open(spec["src"], "rb")
70+
hl = struct.unpack("<Q", src.read(8))[0]
71+
hh = json.loads(src.read(hl))
72+
for dst, name, nbytes, dtype, shape in spec["copy"]:
73+
t = hh[name]
74+
lo, hi = t["data_offsets"]
75+
if (hi - lo, t["dtype"], t["shape"]) != (nbytes, dtype, shape):
76+
sys.exit("layout mismatch " + name)
77+
src.seek(8 + hl + lo)
78+
f.seek(dst)
79+
while nbytes:
80+
b = src.read(min(nbytes, 1 << 24))
81+
if not b:
82+
sys.exit("short checkpoint " + name)
83+
f.write(b)
84+
nbytes -= len(b)
85+
os.replace(part, spec["out"])
86+
print("HF_BUILT", spec["out"], spec["size"])
87+
"""
88+
89+
90+
def download_cmd(dst: str, ranges: int = RANGES) -> str:
91+
"""bash: fetch the pinned checkpoint to `dst` with `ranges` parallel curls; verify size+sha."""
92+
q, step = shlex.quote(dst), -(-SIZE // ranges)
93+
gets = "".join(
94+
f"curl -fsSL --retry 3 --connect-timeout 20 -r {i * step}-{min(SIZE, (i + 1) * step) - 1}"
95+
f' -o {q}.r{i} {URL} & p="$p $!"; '
96+
for i in range(ranges)
97+
)
98+
parts = " ".join(f"{q}.r{i}" for i in range(ranges))
99+
return (
100+
f'set -e; [ "$(sha256sum {q} 2>/dev/null | cut -c1-64)" = {SHA256} ] && exit 0; p=; '
101+
f"{gets}for x in $p; do wait $x; done; cat {parts} > {q}.part; rm -f {parts}; "
102+
f'[ "$(stat -c %s {q}.part)" = {SIZE} ]; '
103+
f'[ "$(sha256sum {q}.part | cut -c1-64)" = {SHA256} ]; mv {q}.part {q}'
104+
)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.