greyAll commited on
Commit
94e7b24
·
verified ·
1 Parent(s): 50faf87

Upload consolidate.sh

Browse files
Files changed (1) hide show
  1. consolidate.sh +46 -0
consolidate.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Offline HF safetensors consolidation helper.
5
+ # Defaults are conservative for login nodes and small CPU machines. For large
6
+ # checkpoints, run this on a CPU compute node and increase parallelism. Work is
7
+ # split across NPROC_PER_NODE worker processes, and each process uses NUM_THREADS
8
+ # writer threads; keep NPROC_PER_NODE * NUM_THREADS within your CPU allocation.
9
+ # Example for an 80-core CPU node:
10
+ # NPROC_PER_NODE=16 NUM_THREADS=5 bash "$0"
11
+ # Slurm example:
12
+ # sbatch --cpus-per-task=80 --wrap='NPROC_PER_NODE=16 NUM_THREADS=5 bash /path/to/consolidate.sh'
13
+ # Optional: set CAST_DTYPE=bf16 to request a floating-point dtype cast during export.
14
+ NPROC_PER_NODE="${NPROC_PER_NODE:-1}"
15
+ NUM_THREADS="${NUM_THREADS:-5}"
16
+ CAST_DTYPE="${CAST_DTYPE:-}"
17
+ PYTHON="${PYTHON:-python3}"
18
+ TORCHRUN="${TORCHRUN:-torchrun}"
19
+ CONSOLIDATION_TOOL="${CONSOLIDATION_TOOL:-tools/offline_hf_consolidation.py}"
20
+ CAST_DTYPE_ARGS=()
21
+ if [[ -n "${CAST_DTYPE}" ]]; then
22
+ CAST_DTYPE_ARGS=(--cast-dtype "${CAST_DTYPE}")
23
+ fi
24
+ if [[ ! -f "${CONSOLIDATION_TOOL}" ]]; then
25
+ echo "Could not find offline consolidation tool at ${CONSOLIDATION_TOOL}." >&2
26
+ echo "Run from the AutoModel repo root or set CONSOLIDATION_TOOL=/path/to/tools/offline_hf_consolidation.py." >&2
27
+ exit 1
28
+ fi
29
+
30
+ if [[ "${NPROC_PER_NODE}" -gt 1 ]]; then
31
+ "${TORCHRUN}" --nproc-per-node="${NPROC_PER_NODE}" "${CONSOLIDATION_TOOL}" \
32
+ --backend gloo \
33
+ --num-threads "${NUM_THREADS}" \
34
+ --model-name "/home/silver/teutonic_mining/models/teutonic-II-110B-A7B-5DALwjE4-81" \
35
+ --input-dir "../models/mimo_v25_pro_pretrain_b200_ep8/epoch_0_step_1874/model" \
36
+ --output-dir "../models/mimo_v25_pro_pretrain_b200_ep8/epoch_0_step_1874/model/consolidated" \
37
+ "${CAST_DTYPE_ARGS[@]}"
38
+ else
39
+ "${PYTHON}" "${CONSOLIDATION_TOOL}" \
40
+ --backend gloo \
41
+ --num-threads "${NUM_THREADS}" \
42
+ --model-name "/home/silver/teutonic_mining/models/teutonic-II-110B-A7B-5DALwjE4-81" \
43
+ --input-dir "../models/mimo_v25_pro_pretrain_b200_ep8/epoch_0_step_1874/model" \
44
+ --output-dir "../models/mimo_v25_pro_pretrain_b200_ep8/epoch_0_step_1874/model/consolidated" \
45
+ "${CAST_DTYPE_ARGS[@]}"
46
+ fi