Mentors4EDU commited on
Commit
4b08de9
·
verified ·
1 Parent(s): db3982a

Remove push_to_hub.py; generalise cloud scripts (no account-specific defaults)

Browse files
README.md CHANGED
@@ -832,23 +832,19 @@ and saves the controller with a JSON summary. With `--init-from`, the
832
  previous rung's gates are carried onto the grown model and fresh gates are
833
  scored only for the new layers and channels.
834
 
835
- **`scripts/push_to_hub.py`.** Copies the two remote-code files into the
836
- checkpoint folder with absolute imports, writes an `auto_map` into
837
- `config.json`, removes internal marker files, and uploads the checkpoint
838
- (resumable for large folders), the controller and its summary, and with
839
- `--with-card` this README and the license.
840
-
841
  **`cloud/bootstrap.sh`.** The unattended node script used for stages 2 to
842
  6. Creates a virtual environment, installs the ROCm or CUDA PyTorch build
843
- to match the node, pulls the staged data and stage 1 checkpoint from a
844
- private Hub dataset, runs a short 8-rank FSDP smoke test on a tiny model,
845
- then for each rung grows, pretrains and fits the controller, skipping any
846
- rung whose `.rung_done` marker exists. Per-rung training flags are read
847
- from `pretrain_extra_<stage>.txt` under `RIEMANN_ROOT` so settings can be
848
- tuned between rungs without editing the script. Finishes by pushing the
849
- final checkpoint and all controllers to the model repository.
850
-
851
- **`cloud/launch_node.ps1`.** Creates the GPU droplet with `doctl`, waits
 
 
852
  for SSH, ships the code bundle and the Hugging Face token file, and
853
  starts `bootstrap.sh` under `nohup` so it survives disconnects.
854
 
@@ -859,9 +855,10 @@ fetches one stage file by file with per-file SHA-256 verification and
859
  retry, which is the more reliable path for checkpoints above 20 GB.
860
 
861
  **`cloud/verify_before_destroy.ps1`.** Checks that the node reports
862
- completion, every rung and controller is mirrored and verified locally,
863
- and the Hub holds every stage 6 shard at the expected size, and prints a
864
- single safe-or-not verdict before the droplet is destroyed.
 
865
 
866
  **`cloud/make_tiny_stage.py`.** Writes a two-layer, 64-wide checkpoint in
867
  the stage 2 slot for the FSDP smoke test.
 
832
  previous rung's gates are carried onto the grown model and fresh gates are
833
  scored only for the new layers and channels.
834
 
 
 
 
 
 
 
835
  **`cloud/bootstrap.sh`.** The unattended node script used for stages 2 to
836
  6. Creates a virtual environment, installs the ROCm or CUDA PyTorch build
837
+ to match the node, pulls the staged data and stage 1 checkpoint from the
838
+ private Hub dataset named in `STAGING_REPO`, runs a short 8-rank FSDP
839
+ smoke test on a tiny model, then for each rung grows, pretrains and fits
840
+ the controller, skipping any rung whose `.rung_done` marker exists.
841
+ Per-rung training flags are read from `pretrain_extra_<stage>.txt` under
842
+ `RIEMANN_ROOT` so settings can be tuned between rungs without editing the
843
+ script. Leaves the final checkpoint and controllers on the node for
844
+ archiving.
845
+
846
+ **`cloud/launch_node.ps1`.** Creates the GPU droplet with `doctl` using
847
+ the SSH key name and staging repository given on the command line, waits
848
  for SSH, ships the code bundle and the Hugging Face token file, and
849
  starts `bootstrap.sh` under `nohup` so it survives disconnects.
850
 
 
855
  retry, which is the more reliable path for checkpoints above 20 GB.
856
 
857
  **`cloud/verify_before_destroy.ps1`.** Checks that the node reports
858
+ completion and that every rung and controller is mirrored and verified
859
+ locally, optionally also comparing shard sizes against a Hub repository
860
+ when `-ModelRepo` is given, and prints a single safe-or-not verdict
861
+ before the droplet is destroyed.
862
 
863
  **`cloud/make_tiny_stage.py`.** Writes a two-layer, 64-wide checkpoint in
864
  the stage 2 slot for the FSDP smoke test.
training/cloud/bootstrap.sh CHANGED
@@ -1,133 +1,124 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- export RIEMANN_ROOT="${RIEMANN_ROOT:-/workspace/RiemannModel}"
5
- export HF_HUB_ENABLE_HF_TRANSFER=1
6
- export TOKENIZERS_PARALLELISM=false
7
- export NCCL_DEBUG=WARN
8
- export PYTHONUNBUFFERED=1
9
- PROJECT="${PROJECT:-/workspace/riemann}"
10
- STAGING_REPO="OpenPeerAI/riemann-staging"
11
- MODEL_REPO="OpenPeerAI/My-Name-is-Riemann-Prerelease"
12
- LOGDIR="$RIEMANN_ROOT/logs"
13
- mkdir -p "$RIEMANN_ROOT"/{data,checkpoints,ntk_controllers,hf_cache,staging} "$LOGDIR"
14
- cd "$PROJECT"
15
-
16
- log() { echo "$(date '+%F %T') [bootstrap] $*"; }
17
- gate() { echo; echo "================ GATE: $* ================"; echo; }
18
-
19
- gate "preflight"
20
- log "host: $(hostname) kernel: $(uname -r)"
21
- df -h "$RIEMANN_ROOT" | tail -1
22
- nproc; free -g | head -2
23
- if command -v rocm-smi >/dev/null 2>&1; then rocm-smi --showproductname | grep -i "card series" | head -8 || true; fi
24
- if command -v nvidia-smi >/dev/null 2>&1; then nvidia-smi -L || true; fi
25
-
26
- gate "python environment"
27
- VENV="/workspace/venv"
28
- if [ ! -x "$VENV/bin/python" ]; then
29
- log "installing python3-venv/pip and creating venv"
30
- export DEBIAN_FRONTEND=noninteractive
31
- apt-get update -qq && apt-get install -y -qq python3-venv python3-pip git >/dev/null
32
- python3 -m venv "$VENV"
33
- fi
34
- export PATH="$VENV/bin:$PATH"
35
- PY="$VENV/bin/python"
36
- $PY -m pip install -q --upgrade pip
37
- if [ "$($PY -c 'import torch;print(torch.cuda.is_available())' 2>/dev/null)" != "True" ]; then
38
- log "installing torch GPU build"
39
- if command -v rocm-smi >/dev/null 2>&1 || command -v amd-smi >/dev/null 2>&1; then
40
- $PY -m pip install -q torch --index-url "${TORCH_INDEX:-https://download.pytorch.org/whl/rocm6.4}"
41
- else
42
- $PY -m pip install -q torch --index-url https://download.pytorch.org/whl/cu124
43
- fi
44
- fi
45
- $PY -m pip install -q "transformers>=4.56,<5" "safetensors>=0.4" "huggingface_hub>=0.24" hf_transfer "numpy>=1.26" "pandas>=2.0" "pyarrow>=15" "datasets>=2.20" "accelerate>=0.33" "git+https://github.com/leochlon/ntkmirror.git"
46
- $PY - <<'EOF'
47
- import torch, transformers
48
- print("torch", torch.__version__, "| hip:", getattr(torch.version, "hip", None), "| cuda:", torch.version.cuda)
49
- n = torch.cuda.device_count()
50
- print("gpu count:", n)
51
- for i in range(n):
52
- p = torch.cuda.get_device_properties(i)
53
- print(f" [{i}] {p.name} {p.total_memory/2**30:.0f} GiB")
54
- assert n == 8, f"expected 8 GPUs, found {n}"
55
- print("transformers", transformers.__version__)
56
- import ntkmirror; print("ntkmirror ok")
57
- EOF
58
-
59
- gate "pull staging data"
60
- if [ ! -f "$RIEMANN_ROOT/data/pretrain_corpus.txt" ]; then
61
- hf download "$STAGING_REPO" --repo-type dataset --local-dir "$RIEMANN_ROOT/staging"
62
- log "decompressing corpus"
63
- gunzip -c "$RIEMANN_ROOT/staging/pretrain_corpus.txt.gz" > "$RIEMANN_ROOT/data/pretrain_corpus.txt"
64
- gunzip -c "$RIEMANN_ROOT/staging/ntk_finetune.jsonl.gz" > "$RIEMANN_ROOT/data/ntk_finetune.jsonl"
65
- cp -r "$RIEMANN_ROOT/staging/checkpoints/stage1_279m" "$RIEMANN_ROOT/checkpoints/"
66
- cp "$RIEMANN_ROOT/staging/ntk_controllers/"* "$RIEMANN_ROOT/ntk_controllers/"
67
- fi
68
- wc -l "$RIEMANN_ROOT/data/pretrain_corpus.txt" "$RIEMANN_ROOT/data/ntk_finetune.jsonl"
69
- ls -la "$RIEMANN_ROOT/checkpoints/stage1_279m" "$RIEMANN_ROOT/ntk_controllers"
70
-
71
- if [ "${SKIP_SMOKE:-0}" != "1" ]; then
72
- gate "FSDP smoke test (tiny model, 8 ranks, ~2 min)"
73
- $PY cloud/make_tiny_stage.py "$RIEMANN_ROOT/_smoke/checkpoints"
74
- torchrun --nproc_per_node 8 scripts/pretrain_cuda.py --stage stage2_538m \
75
- --checkpoint-root "$RIEMANN_ROOT/_smoke/checkpoints" \
76
- --max-steps 6 --batch-size 2 --grad-accum 2 --seq-len 128 --log-every 2 --save-every 3 --num-workers 0 \
77
- 2>&1 | tee "$LOGDIR/smoke.log" | grep -E "INFO|Error|Traceback" | tail -20
78
- $PY -c "import sys; sys.path.insert(0,'.'); from riemann.modeling_riemann import RiemannForCausalLM; RiemannForCausalLM.from_pretrained('$RIEMANN_ROOT/_smoke/checkpoints/stage2_538m'); print('smoke checkpoint reloads OK')"
79
- rm -rf "$RIEMANN_ROOT/_smoke"
80
- fi
81
-
82
- run_rung() {
83
- local from="$1" to="$2" epochs="$3"
84
- local marker="$RIEMANN_ROOT/checkpoints/$to/.rung_done"
85
- if [ -f "$marker" ]; then
86
- log "rung $to already complete, skipping"
87
- return 0
88
- fi
89
- gate "rung $from -> $to (epochs=$epochs)"
90
- local t0; t0=$(date +%s)
91
- if [ ! -f "$RIEMANN_ROOT/checkpoints/$to/config.json" ]; then
92
- $PY scripts/grow_and_continue.py --from-stage "$from" --to-stage "$to" 2>&1 | tee "$LOGDIR/grow_$to.log" | grep -E "INFO|Error" | tail -5
93
- fi
94
- local extra=""
95
- if [ -f "$RIEMANN_ROOT/pretrain_extra_$to.txt" ]; then
96
- extra="$(cat "$RIEMANN_ROOT/pretrain_extra_$to.txt")"
97
- elif [ -f "$RIEMANN_ROOT/pretrain_extra.txt" ]; then
98
- extra="$(cat "$RIEMANN_ROOT/pretrain_extra.txt")"
99
- fi
100
- log "pretrain extra flags for $to: ${extra:-<none>}"
101
- torchrun --nproc_per_node 8 scripts/pretrain_cuda.py --stage "$to" --epochs "$epochs" \
102
- --num-workers 6 --log-every 20 --save-every 250 $extra \
103
- 2>&1 | tee "$LOGDIR/pretrain_$to.log" | grep -E "INFO \[rank 0\]|Error|Traceback"
104
- $PY scripts/fit_ntk.py --stage "$to" --init-from "$from" --gates 8192 --batch-size 8 --max-length 512 \
105
- 2>&1 | tee "$LOGDIR/ntk_$to.log" | grep -E "INFO|Error|Traceback"
106
- touch "$marker"
107
- local t1; t1=$(date +%s)
108
- log "rung $to finished in $(( (t1 - t0) / 60 )) min"
109
- }
110
-
111
- gate "stage 2 alone (throughput check)"
112
- run_rung stage1_279m stage2_538m 1
113
- log "stage 2 done. Inspect $LOGDIR/pretrain_stage2_538m.log tok/s before continuing."
114
- if [ "${STOP_AFTER_STAGE2:-0}" = "1" ]; then
115
- log "STOP_AFTER_STAGE2=1, exiting for review"
116
- exit 0
117
- fi
118
-
119
- run_rung stage2_538m stage3_1.19b 1
120
- run_rung stage3_1.19b stage4_2.65b 1
121
- run_rung stage4_2.65b stage5_6.66b 1
122
- run_rung stage5_6.66b stage6_12.85b 2
123
-
124
- gate "push weights and controllers to private model repo (no card)"
125
- $PY scripts/push_to_hub.py --stage stage6_12.85b --repo-id "$MODEL_REPO" --private 2>&1 | tee "$LOGDIR/push.log" | grep -E "INFO|Error"
126
- for s in stage2_538m stage3_1.19b stage4_2.65b stage5_6.66b; do
127
- hf upload "$MODEL_REPO" "$RIEMANN_ROOT/ntk_controllers/$s.pt" "ntk_controller/$s.pt" --private || true
128
- hf upload "$MODEL_REPO" "$RIEMANN_ROOT/ntk_controllers/$s.json" "ntk_controller/$s.json" --private || true
129
- done
130
- hf upload "$MODEL_REPO" "$LOGDIR" "training_logs" --private || true
131
-
132
- gate "ALL DONE"
133
- log "Prerelease weights are in $MODEL_REPO (private). Safe to destroy this node after confirming the upload."
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ export RIEMANN_ROOT="${RIEMANN_ROOT:-/workspace/RiemannModel}"
5
+ export HF_HUB_ENABLE_HF_TRANSFER=1
6
+ export TOKENIZERS_PARALLELISM=false
7
+ export NCCL_DEBUG=WARN
8
+ export PYTHONUNBUFFERED=1
9
+ PROJECT="${PROJECT:-/workspace/riemann}"
10
+ STAGING_REPO="${STAGING_REPO:?set STAGING_REPO to the private Hub dataset holding data/, the stage 1 checkpoint and controller}"
11
+ LOGDIR="$RIEMANN_ROOT/logs"
12
+ mkdir -p "$RIEMANN_ROOT"/{data,checkpoints,ntk_controllers,hf_cache,staging} "$LOGDIR"
13
+ cd "$PROJECT"
14
+
15
+ log() { echo "$(date '+%F %T') [bootstrap] $*"; }
16
+ gate() { echo; echo "================ GATE: $* ================"; echo; }
17
+
18
+ gate "preflight"
19
+ log "host: $(hostname) kernel: $(uname -r)"
20
+ df -h "$RIEMANN_ROOT" | tail -1
21
+ nproc; free -g | head -2
22
+ if command -v rocm-smi >/dev/null 2>&1; then rocm-smi --showproductname | grep -i "card series" | head -8 || true; fi
23
+ if command -v nvidia-smi >/dev/null 2>&1; then nvidia-smi -L || true; fi
24
+
25
+ gate "python environment"
26
+ VENV="/workspace/venv"
27
+ if [ ! -x "$VENV/bin/python" ]; then
28
+ log "installing python3-venv/pip and creating venv"
29
+ export DEBIAN_FRONTEND=noninteractive
30
+ apt-get update -qq && apt-get install -y -qq python3-venv python3-pip git >/dev/null
31
+ python3 -m venv "$VENV"
32
+ fi
33
+ export PATH="$VENV/bin:$PATH"
34
+ PY="$VENV/bin/python"
35
+ $PY -m pip install -q --upgrade pip
36
+ if [ "$($PY -c 'import torch;print(torch.cuda.is_available())' 2>/dev/null)" != "True" ]; then
37
+ log "installing torch GPU build"
38
+ if command -v rocm-smi >/dev/null 2>&1 || command -v amd-smi >/dev/null 2>&1; then
39
+ $PY -m pip install -q torch --index-url "${TORCH_INDEX:-https://download.pytorch.org/whl/rocm6.4}"
40
+ else
41
+ $PY -m pip install -q torch --index-url https://download.pytorch.org/whl/cu124
42
+ fi
43
+ fi
44
+ $PY -m pip install -q "transformers>=4.56,<5" "safetensors>=0.4" "huggingface_hub>=0.24" hf_transfer "numpy>=1.26" "pandas>=2.0" "pyarrow>=15" "datasets>=2.20" "accelerate>=0.33" "git+https://github.com/leochlon/ntkmirror.git"
45
+ $PY - <<'EOF'
46
+ import torch, transformers
47
+ print("torch", torch.__version__, "| hip:", getattr(torch.version, "hip", None), "| cuda:", torch.version.cuda)
48
+ n = torch.cuda.device_count()
49
+ print("gpu count:", n)
50
+ for i in range(n):
51
+ p = torch.cuda.get_device_properties(i)
52
+ print(f" [{i}] {p.name} {p.total_memory/2**30:.0f} GiB")
53
+ assert n == 8, f"expected 8 GPUs, found {n}"
54
+ print("transformers", transformers.__version__)
55
+ import ntkmirror; print("ntkmirror ok")
56
+ EOF
57
+
58
+ gate "pull staging data"
59
+ if [ ! -f "$RIEMANN_ROOT/data/pretrain_corpus.txt" ]; then
60
+ hf download "$STAGING_REPO" --repo-type dataset --local-dir "$RIEMANN_ROOT/staging"
61
+ log "decompressing corpus"
62
+ gunzip -c "$RIEMANN_ROOT/staging/pretrain_corpus.txt.gz" > "$RIEMANN_ROOT/data/pretrain_corpus.txt"
63
+ gunzip -c "$RIEMANN_ROOT/staging/ntk_finetune.jsonl.gz" > "$RIEMANN_ROOT/data/ntk_finetune.jsonl"
64
+ cp -r "$RIEMANN_ROOT/staging/checkpoints/stage1_279m" "$RIEMANN_ROOT/checkpoints/"
65
+ cp "$RIEMANN_ROOT/staging/ntk_controllers/"* "$RIEMANN_ROOT/ntk_controllers/"
66
+ fi
67
+ wc -l "$RIEMANN_ROOT/data/pretrain_corpus.txt" "$RIEMANN_ROOT/data/ntk_finetune.jsonl"
68
+ ls -la "$RIEMANN_ROOT/checkpoints/stage1_279m" "$RIEMANN_ROOT/ntk_controllers"
69
+
70
+ if [ "${SKIP_SMOKE:-0}" != "1" ]; then
71
+ gate "FSDP smoke test (tiny model, 8 ranks, ~2 min)"
72
+ $PY cloud/make_tiny_stage.py "$RIEMANN_ROOT/_smoke/checkpoints"
73
+ torchrun --nproc_per_node 8 scripts/pretrain_cuda.py --stage stage2_538m \
74
+ --checkpoint-root "$RIEMANN_ROOT/_smoke/checkpoints" \
75
+ --max-steps 6 --batch-size 2 --grad-accum 2 --seq-len 128 --log-every 2 --save-every 3 --num-workers 0 \
76
+ 2>&1 | tee "$LOGDIR/smoke.log" | grep -E "INFO|Error|Traceback" | tail -20
77
+ $PY -c "import sys; sys.path.insert(0,'.'); from riemann.modeling_riemann import RiemannForCausalLM; RiemannForCausalLM.from_pretrained('$RIEMANN_ROOT/_smoke/checkpoints/stage2_538m'); print('smoke checkpoint reloads OK')"
78
+ rm -rf "$RIEMANN_ROOT/_smoke"
79
+ fi
80
+
81
+ run_rung() {
82
+ local from="$1" to="$2" epochs="$3"
83
+ local marker="$RIEMANN_ROOT/checkpoints/$to/.rung_done"
84
+ if [ -f "$marker" ]; then
85
+ log "rung $to already complete, skipping"
86
+ return 0
87
+ fi
88
+ gate "rung $from -> $to (epochs=$epochs)"
89
+ local t0; t0=$(date +%s)
90
+ if [ ! -f "$RIEMANN_ROOT/checkpoints/$to/config.json" ]; then
91
+ $PY scripts/grow_and_continue.py --from-stage "$from" --to-stage "$to" 2>&1 | tee "$LOGDIR/grow_$to.log" | grep -E "INFO|Error" | tail -5
92
+ fi
93
+ local extra=""
94
+ if [ -f "$RIEMANN_ROOT/pretrain_extra_$to.txt" ]; then
95
+ extra="$(cat "$RIEMANN_ROOT/pretrain_extra_$to.txt")"
96
+ elif [ -f "$RIEMANN_ROOT/pretrain_extra.txt" ]; then
97
+ extra="$(cat "$RIEMANN_ROOT/pretrain_extra.txt")"
98
+ fi
99
+ log "pretrain extra flags for $to: ${extra:-<none>}"
100
+ torchrun --nproc_per_node 8 scripts/pretrain_cuda.py --stage "$to" --epochs "$epochs" \
101
+ --num-workers 6 --log-every 20 --save-every 250 $extra \
102
+ 2>&1 | tee "$LOGDIR/pretrain_$to.log" | grep -E "INFO \[rank 0\]|Error|Traceback"
103
+ $PY scripts/fit_ntk.py --stage "$to" --init-from "$from" --gates 8192 --batch-size 8 --max-length 512 \
104
+ 2>&1 | tee "$LOGDIR/ntk_$to.log" | grep -E "INFO|Error|Traceback"
105
+ touch "$marker"
106
+ local t1; t1=$(date +%s)
107
+ log "rung $to finished in $(( (t1 - t0) / 60 )) min"
108
+ }
109
+
110
+ gate "stage 2 alone (throughput check)"
111
+ run_rung stage1_279m stage2_538m 1
112
+ log "stage 2 done. Inspect $LOGDIR/pretrain_stage2_538m.log tok/s before continuing."
113
+ if [ "${STOP_AFTER_STAGE2:-0}" = "1" ]; then
114
+ log "STOP_AFTER_STAGE2=1, exiting for review"
115
+ exit 0
116
+ fi
117
+
118
+ run_rung stage2_538m stage3_1.19b 1
119
+ run_rung stage3_1.19b stage4_2.65b 1
120
+ run_rung stage4_2.65b stage5_6.66b 1
121
+ run_rung stage5_6.66b stage6_12.85b 2
122
+
123
+ gate "ALL DONE"
124
+ log "Final checkpoint: $RIEMANN_ROOT/checkpoints/stage6_12.85b. Controllers: $RIEMANN_ROOT/ntk_controllers. Archive these before destroying the node."
 
 
 
 
 
 
 
 
 
training/cloud/launch_node.ps1 CHANGED
@@ -2,8 +2,9 @@ param(
2
  [string]$Region = "nyc2",
3
  [string]$Size = "gpu-mi325x8-2048gb",
4
  [string]$Image = "gpu-amd-base",
5
- [string]$Name = "riemann-climb",
6
- [string]$SshKeyName = "github-mass-merger-key",
 
7
  [switch]$StopAfterStage2
8
  )
9
  $ErrorActionPreference = "Stop"
@@ -48,7 +49,7 @@ ssh root@$ip "cd /workspace/riemann && tar -xzf /workspace/riemann_bundle.tar.gz
48
 
49
  $stopFlag = if ($StopAfterStage2) { "STOP_AFTER_STAGE2=1" } else { "STOP_AFTER_STAGE2=0" }
50
  Write-Host "Starting bootstrap under nohup ($stopFlag) ..."
51
- ssh root@$ip "cd /workspace/riemann && mkdir -p /workspace/RiemannModel/logs && $stopFlag nohup bash cloud/bootstrap.sh > /workspace/RiemannModel/logs/bootstrap.log 2>&1 &"
52
  Start-Sleep 5
53
  ssh root@$ip "tail -5 /workspace/RiemannModel/logs/bootstrap.log"
54
  Write-Host ""
 
2
  [string]$Region = "nyc2",
3
  [string]$Size = "gpu-mi325x8-2048gb",
4
  [string]$Image = "gpu-amd-base",
5
+ [string]$Name = "riemann-node",
6
+ [Parameter(Mandatory = $true)][string]$SshKeyName,
7
+ [Parameter(Mandatory = $true)][string]$StagingRepo,
8
  [switch]$StopAfterStage2
9
  )
10
  $ErrorActionPreference = "Stop"
 
49
 
50
  $stopFlag = if ($StopAfterStage2) { "STOP_AFTER_STAGE2=1" } else { "STOP_AFTER_STAGE2=0" }
51
  Write-Host "Starting bootstrap under nohup ($stopFlag) ..."
52
+ ssh root@$ip "cd /workspace/riemann && mkdir -p /workspace/RiemannModel/logs && STAGING_REPO=$StagingRepo $stopFlag nohup bash cloud/bootstrap.sh > /workspace/RiemannModel/logs/bootstrap.log 2>&1 &"
53
  Start-Sleep 5
54
  ssh root@$ip "tail -5 /workspace/RiemannModel/logs/bootstrap.log"
55
  Write-Host ""
training/cloud/mirror_node.ps1 CHANGED
@@ -1,6 +1,6 @@
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
- [string]$LocalRoot = "C:\RiemannModel",
4
  [string]$RemoteRoot = "/workspace/RiemannModel",
5
  [int]$PollSeconds = 300
6
  )
 
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
+ [string]$LocalRoot = $env:RIEMANN_ROOT,
4
  [string]$RemoteRoot = "/workspace/RiemannModel",
5
  [int]$PollSeconds = 300
6
  )
training/cloud/pull_stage.ps1 CHANGED
@@ -1,7 +1,7 @@
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
  [string]$Stage = "stage6_12.85b",
4
- [string]$LocalRoot = "C:\RiemannModel",
5
  [string]$RemoteRoot = "/workspace/RiemannModel"
6
  )
7
  $ErrorActionPreference = "Continue"
 
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
  [string]$Stage = "stage6_12.85b",
4
+ [string]$LocalRoot = $env:RIEMANN_ROOT,
5
  [string]$RemoteRoot = "/workspace/RiemannModel"
6
  )
7
  $ErrorActionPreference = "Continue"
training/cloud/verify_before_destroy.ps1 CHANGED
@@ -1,7 +1,7 @@
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
- [string]$LocalRoot = "C:\RiemannModel",
4
- [string]$ModelRepo = "OpenPeerAI/My-Name-is-Riemann-Prerelease"
5
  )
6
  $ErrorActionPreference = "Continue"
7
  $ok = $true
@@ -15,19 +15,21 @@ foreach ($s in "stage2_538m", "stage3_1.19b", "stage4_2.65b", "stage5_6.66b", "s
15
  }
16
  Check "local training logs present" ((Get-ChildItem "$LocalRoot\cloud_logs" -Filter "pretrain_stage6*.log" -ErrorAction SilentlyContinue).Count -ge 1)
17
 
18
- $remoteList = ssh "root@$NodeIp" "cd /workspace/RiemannModel/checkpoints/stage6_12.85b && ls -l model-*.safetensors | awk '{print `$5, `$9}'"
19
- $hub = python -c "
 
20
  from huggingface_hub import HfApi
21
  for f in HfApi().list_repo_tree('$ModelRepo', recursive=True):
22
  s=getattr(f,'size',None)
23
  if s and f.path.endswith('.safetensors'): print(s, f.path.split('/')[-1])
24
  "
25
- $remoteMap = @{}; foreach ($l in $remoteList) { if ($l -match '^(\d+)\s+(\S+)$') { $remoteMap[$matches[2]] = [long]$matches[1] } }
26
- $hubMap = @{}; foreach ($l in $hub) { if ($l -match '^(\d+)\s+(\S+)$') { $hubMap[$matches[2]] = [long]$matches[1] } }
27
- $shardsMatch = ($remoteMap.Count -gt 0) -and ($remoteMap.Count -eq $hubMap.Count)
28
- foreach ($k in $remoteMap.Keys) { if ($hubMap[$k] -ne $remoteMap[$k]) { $shardsMatch = $false } }
29
- Check "Hub has all $($remoteMap.Count) stage6 shards with matching sizes" $shardsMatch
30
- Check "Hub has stage6 controller" (($hub = python -c "from huggingface_hub import HfApi; print(any(f.path=='ntk_controller/stage6_12.85b.pt' for f in HfApi().list_repo_tree('$ModelRepo', recursive=True)))") -eq "True")
 
31
 
32
  ""
33
- if ($ok) { "SAFE TO DESTROY: all archive and Hub checks passed." } else { "DO NOT DESTROY: one or more checks failed." }
 
1
  param(
2
  [string]$NodeIp = (Get-Content "$env:RIEMANN_ROOT\cloud_state\node_ip.txt").Trim(),
3
+ [string]$LocalRoot = $env:RIEMANN_ROOT,
4
+ [string]$ModelRepo = ""
5
  )
6
  $ErrorActionPreference = "Continue"
7
  $ok = $true
 
15
  }
16
  Check "local training logs present" ((Get-ChildItem "$LocalRoot\cloud_logs" -Filter "pretrain_stage6*.log" -ErrorAction SilentlyContinue).Count -ge 1)
17
 
18
+ if ($ModelRepo) {
19
+ $remoteList = ssh "root@$NodeIp" "cd /workspace/RiemannModel/checkpoints/stage6_12.85b && ls -l model-*.safetensors | awk '{print `$5, `$9}'"
20
+ $hub = python -c "
21
  from huggingface_hub import HfApi
22
  for f in HfApi().list_repo_tree('$ModelRepo', recursive=True):
23
  s=getattr(f,'size',None)
24
  if s and f.path.endswith('.safetensors'): print(s, f.path.split('/')[-1])
25
  "
26
+ $remoteMap = @{}; foreach ($l in $remoteList) { if ($l -match '^(\d+)\s+(\S+)$') { $remoteMap[$matches[2]] = [long]$matches[1] } }
27
+ $hubMap = @{}; foreach ($l in $hub) { if ($l -match '^(\d+)\s+(\S+)$') { $hubMap[$matches[2]] = [long]$matches[1] } }
28
+ $shardsMatch = ($remoteMap.Count -gt 0) -and ($remoteMap.Count -eq $hubMap.Count)
29
+ foreach ($k in $remoteMap.Keys) { if ($hubMap[$k] -ne $remoteMap[$k]) { $shardsMatch = $false } }
30
+ Check "Hub has all $($remoteMap.Count) stage6 shards with matching sizes" $shardsMatch
31
+ Check "Hub has stage6 controller" ((python -c "from huggingface_hub import HfApi; print(any(f.path=='ntk_controller/stage6_12.85b.pt' for f in HfApi().list_repo_tree('$ModelRepo', recursive=True)))") -eq "True")
32
+ }
33
 
34
  ""
35
+ if ($ok) { "SAFE TO DESTROY: all archive checks passed." } else { "DO NOT DESTROY: one or more checks failed." }
training/scripts/push_to_hub.py DELETED
@@ -1,138 +0,0 @@
1
- from __future__ import annotations
2
- import argparse
3
- import json
4
- import logging
5
- import shutil
6
- import sys
7
- from pathlib import Path
8
-
9
- sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
10
- from huggingface_hub import HfApi, create_repo, whoami
11
- from riemann.growth_ladder import get_stage
12
- from riemann.paths import CHECKPOINT_ROOT, CONTROLLER_ROOT
13
-
14
- logger = logging.getLogger("riemann.push_to_hub")
15
- PROJECT_ROOT = Path(__file__).resolve().parent.parent
16
- REMOTE_CODE_FILES = ("configuration_riemann.py", "modeling_riemann.py")
17
-
18
-
19
- def stage_remote_code(checkpoint_dir: Path) -> None:
20
- for name in REMOTE_CODE_FILES:
21
- src = (PROJECT_ROOT / "riemann" / name).read_text(encoding="utf-8")
22
- src = src.replace(
23
- "from .configuration_riemann import", "from configuration_riemann import"
24
- )
25
- (checkpoint_dir / name).write_text(src, encoding="utf-8")
26
- for stray in (".rung_done", ".mirrored"):
27
- p = checkpoint_dir / stray
28
- if p.exists():
29
- p.unlink()
30
- config_path = checkpoint_dir / "config.json"
31
- config = json.loads(config_path.read_text(encoding="utf-8"))
32
- config["auto_map"] = {
33
- "AutoConfig": "configuration_riemann.RiemannConfig",
34
- "AutoModelForCausalLM": "modeling_riemann.RiemannForCausalLM",
35
- }
36
- config_path.write_text(json.dumps(config, indent=2), encoding="utf-8")
37
-
38
-
39
- def main() -> None:
40
- logging.basicConfig(
41
- level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s"
42
- )
43
- parser = argparse.ArgumentParser(
44
- description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
45
- )
46
- parser.add_argument(
47
- "--stage", default="stage0_124m", help="which checkpoint to push"
48
- )
49
- parser.add_argument(
50
- "--repo-id", required=True, help="e.g. your-username/my-name-is-riemann"
51
- )
52
- parser.add_argument(
53
- "--private", action="store_true", help="create/push as a private repo"
54
- )
55
- parser.add_argument(
56
- "--with-card",
57
- action="store_true",
58
- help="also upload README.md and LICENSE (off by default so the card is only pushed after review)",
59
- )
60
- parser.add_argument("--checkpoint-root", default=str(CHECKPOINT_ROOT))
61
- parser.add_argument("--controller-root", default=str(CONTROLLER_ROOT))
62
- args = parser.parse_args()
63
- try:
64
- who = whoami()
65
- logger.info("Logged in to Hugging Face as %s", who.get("name"))
66
- except Exception as exc:
67
- raise RuntimeError(
68
- "Not logged in to Hugging Face. Run `huggingface-cli login` or set the HF_TOKEN environment variable first."
69
- ) from exc
70
- stage = get_stage(args.stage)
71
- checkpoint_dir = Path(args.checkpoint_root) / stage.name
72
- if not (checkpoint_dir / "config.json").exists():
73
- raise FileNotFoundError(f"No checkpoint found at {checkpoint_dir}")
74
- create_repo(args.repo_id, private=args.private, exist_ok=True)
75
- api = HfApi()
76
- stage_remote_code(checkpoint_dir)
77
- logger.info("Uploading checkpoint folder %s -> %s", checkpoint_dir, args.repo_id)
78
- total_bytes = sum(
79
- p.stat().st_size for p in checkpoint_dir.rglob("*") if p.is_file()
80
- )
81
- if total_bytes > 10 * 1024**3:
82
- api.upload_large_folder(
83
- folder_path=str(checkpoint_dir),
84
- repo_id=args.repo_id,
85
- repo_type="model",
86
- )
87
- else:
88
- api.upload_folder(
89
- folder_path=str(checkpoint_dir),
90
- repo_id=args.repo_id,
91
- commit_message=f"Upload My Name is Riemann checkpoint ({stage.name})",
92
- )
93
- controller_path = Path(args.controller_root) / f"{stage.name}.pt"
94
- if controller_path.exists():
95
- logger.info("Also uploading NTK gate controller %s", controller_path)
96
- api.upload_file(
97
- path_or_fileobj=str(controller_path),
98
- path_in_repo=f"ntk_controller/{stage.name}.pt",
99
- repo_id=args.repo_id,
100
- commit_message=f"Upload NTK gate controller ({stage.name})",
101
- )
102
- summary_path = controller_path.with_suffix(".json")
103
- if summary_path.exists():
104
- api.upload_file(
105
- path_or_fileobj=str(summary_path),
106
- path_in_repo=f"ntk_controller/{stage.name}.json",
107
- repo_id=args.repo_id,
108
- commit_message=f"Upload NTK controller summary ({stage.name})",
109
- )
110
- else:
111
- logger.info(
112
- "No NTK gate controller found at %s yet, skipping that part.",
113
- controller_path,
114
- )
115
- if args.with_card:
116
- readme_path = PROJECT_ROOT / "README.md"
117
- if readme_path.exists():
118
- api.upload_file(
119
- path_or_fileobj=str(readme_path),
120
- path_in_repo="README.md",
121
- repo_id=args.repo_id,
122
- commit_message="Upload README",
123
- )
124
- license_path = PROJECT_ROOT / "LICENSE"
125
- if license_path.exists():
126
- api.upload_file(
127
- path_or_fileobj=str(license_path),
128
- path_in_repo="LICENSE",
129
- repo_id=args.repo_id,
130
- commit_message="Upload LICENSE",
131
- )
132
- else:
133
- logger.info("Skipping README.md and LICENSE (pass --with-card to upload them).")
134
- logger.info("Done. https://huggingface.co/%s", args.repo_id)
135
-
136
-
137
- if __name__ == "__main__":
138
- main()