| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -euo pipefail |
| HERE="$(cd "$(dirname "$0")" && pwd)" |
| RANK="${1:?usage: ./run_study.sh <rank> [check|overnight|day2|day2-test|test|local|schedule.json]}" |
| SEL="${2:-full}" |
| RUN_TAG="standard" |
| STARTUP_SCHED="" |
| STARTUP_VERIFIER="" |
| case "$SEL" in |
| full) SCHED="$HERE/schedule_3node.json" ;; |
| 5node) SCHED="$HERE/schedule_5node.json" ;; |
| overnight) SCHED="$HERE/schedule_5node_overnight.json" ;; |
| day2) SCHED="$HERE/schedule_day2.json"; RUN_TAG="day2" |
| STARTUP_SCHED="$HERE/schedule_day2_test.json" |
| STARTUP_VERIFIER="$HERE/verify_day2.py" ;; |
| day2-test) SCHED="$HERE/schedule_day2_test.json"; RUN_TAG="day2-test" ;; |
| test) SCHED="$HERE/schedule_test.json" ;; |
| local) SCHED="$HERE/schedule_1node_4gpu.json" ;; |
| check) SCHED="" ;; |
| *) SCHED="$SEL" ;; |
| esac |
| [[ -f "$HERE/nodes.conf" ]] || { echo "nodes.conf missing (copy nodes.conf.example)"; exit 1; } |
| if [[ "$SEL" == "day2" ]]; then |
| [[ -f "$HERE/DAY2-CODE-SHA256SUMS" ]] \ |
| || { echo "DAY2-CODE-SHA256SUMS missing; refusing to run"; exit 2; } |
| ( |
| cd "$HERE" |
| sha256sum -c DAY2-CODE-SHA256SUMS >/dev/null |
| ) || { echo "day2 overlay integrity check failed; refusing to run"; exit 2; } |
| echo "== day2 code integrity check passed" |
| fi |
| |
| source "$HERE/venv/bin/activate" |
|
|
| if [[ "$RUN_TAG" == "standard" ]]; then |
| OUT="$HERE/out" |
| SCRATCH="$HERE/scratch" |
| else |
| RUN_INSTANCE="$(date -u +%Y%m%d-%H%M%S)" |
| OUT="$HERE/out-$RUN_TAG-$RUN_INSTANCE" |
| SCRATCH="$HERE/scratch-$RUN_TAG-$RUN_INSTANCE" |
| fi |
| mkdir -p "$OUT" "$SCRATCH" |
|
|
| |
| |
| |
| if [[ "$SEL" == "day2" ]]; then |
| echo "== one-start day2: startup validation is automatic" |
| elif [[ "${SKIP_NETCHECK:-0}" != "1" ]]; then |
| echo "== connectivity check (nothing is started until this passes)" |
| if ! python3 "$HERE/orchestrator.py" --connectivity-check \ |
| --rank "$RANK" --nodes "$HERE/nodes.conf" \ |
| 2>&1 | tee -a "$OUT/netcheck_rank$RANK.log"; then |
| echo |
| echo "== ABORTED: the nodes cannot talk to each other over the addresses" |
| echo " in nodes.conf. Nothing was started, nothing was disturbed." |
| exit 4 |
| fi |
| else |
| echo "== connectivity check skipped (SKIP_NETCHECK=1)" |
| fi |
| if [[ "$SEL" == "check" ]]; then |
| echo "== check only; not starting the study." |
| exit 0 |
| fi |
| [[ -f "$SCHED" ]] || { echo "schedule not found: $SCHED"; exit 1; } |
|
|
| echo "== starting passive collector" |
| TRACE_OUTDIR="$OUT" "$HERE/collector/trace.sh" start |
|
|
| echo "== running schedule $(basename "$SCHED") as rank $RANK" |
| ORCH_EXTRA=() |
| if [[ -n "$STARTUP_SCHED" ]]; then |
| ORCH_EXTRA+=( |
| --startup-schedule "$STARTUP_SCHED" |
| --startup-verifier "$STARTUP_VERIFIER" |
| ) |
| fi |
| set +e |
| python3 "$HERE/orchestrator.py" \ |
| --rank "$RANK" --nodes "$HERE/nodes.conf" --schedule "$SCHED" \ |
| "${ORCH_EXTRA[@]}" \ |
| ${TRACE_END_BY:+--end-by "$TRACE_END_BY"} \ |
| --out "$OUT" --scratch "$SCRATCH" 2>&1 | tee -a "$OUT/orchestrator_rank$RANK.log" |
| ORC_RC=${PIPESTATUS[0]} |
| set -e |
|
|
| if [[ "$SEL" == "day2-test" || "$SEL" == "day2" ]]; then |
| VERIFY_MODE="shakedown" |
| [[ "$SEL" == "day2" ]] && VERIFY_MODE="full" |
| echo "== verifying $VERIFY_MODE ground truth and job telemetry" |
| set +e |
| python3 "$HERE/verify_day2.py" \ |
| --out "$OUT" --rank "$RANK" --mode "$VERIFY_MODE" |
| VERIFY_RC=$? |
| set -e |
| if [[ "$VERIFY_RC" -ne 0 ]]; then |
| if [[ "$SEL" == "day2-test" ]]; then |
| echo "== shakedown verification failed (rc=$VERIFY_RC); do not start day2 yet" |
| else |
| echo "== full verification found a problem (rc=$VERIFY_RC); the data will still be packaged" |
| fi |
| [[ "$ORC_RC" -ne 0 ]] || ORC_RC=$VERIFY_RC |
| fi |
| fi |
|
|
| echo "== stopping collector and packaging results (orchestrator rc=$ORC_RC)" |
| TRACE_OUTDIR="$OUT" "$HERE/collector/trace.sh" stop |
|
|
| if [[ "$RUN_TAG" == "standard" ]]; then |
| TAR="$HERE/trace-study-result-$(hostname -s)-$(date -u +%Y%m%d-%H%M%S).tar.gz" |
| else |
| TAR="$HERE/trace-study-$RUN_TAG-result-$(hostname -s)-$(date -u +%Y%m%d-%H%M%S).tar.gz" |
| fi |
| mv "$HERE"/collector/trace-data-*.tar.gz "$TAR" 2>/dev/null \ |
| || tar -czf "$TAR" -C "$OUT" . |
| echo "== cleaning scratch (checkpoints / generated data stay on the node only during the run)" |
| rm -rf "$SCRATCH" |
|
|
| echo |
| echo "== DONE. Please return this one file per node:" |
| ls -lh "$TAR" |
| exit "$ORC_RC" |
|
|