#!/usr/bin/env bash # Watches the quantization pipeline and writes a mobile-friendly status file at # /home/stop_me.md. It states clearly whether to STOP the VM (a scheme failed or # the driver crashed) or KEEP RUNNING. Runs until the pipeline finishes or fails. set -u LOG="/home/quantize_32b.log" OUT="/home/stop_me.md" SCHEMES_TOTAL=4 while true; do now="$(date -u '+%Y-%m-%d %H:%M:%S UTC')" ok_count="$(grep -c '===== OK' "$LOG" 2>/dev/null)"; ok_count="${ok_count:-0}" failed="$(grep -E '!!!!! FAILED' "$LOG" 2>/dev/null | tail -1)" layer="$(grep -oE '\([0-9]+/65\)' "$LOG" 2>/dev/null | tail -1)" cur_scheme="$(grep -E '===== START' "$LOG" 2>/dev/null | tail -1 | awk '{print $3}')" all_done="$(grep -c 'ALL DONE' "$LOG" 2>/dev/null)"; all_done="${all_done:-0}" driver_up="$(pgrep -f run_quant_32b.sh >/dev/null && echo yes || echo no)" action="KEEP RUNNING — everything is fine" stop="NO" finished=0 if [ -n "$failed" ]; then action="STOP THE VM — a scheme FAILED" stop="YES" finished=1 elif [ "$all_done" -ge 1 ]; then if [ "$ok_count" -ge "$SCHEMES_TOTAL" ]; then action="DONE — all $SCHEMES_TOTAL schemes uploaded. Safe to stop the VM." else action="STOP THE VM — pipeline ended but only $ok_count/$SCHEMES_TOTAL succeeded" stop="YES" fi finished=1 elif [ "$driver_up" = "no" ]; then action="STOP THE VM — driver process is no longer running (crash/kill)" stop="YES" finished=1 fi { echo "# Quantization status" echo echo "## ACTION: ${action}" echo echo "- STOP THE VM? **${stop}**" echo "- Updated: ${now}" echo "- Schemes completed & uploaded: **${ok_count}/${SCHEMES_TOTAL}**" echo "- Current scheme: ${cur_scheme:-n/a}" echo "- Current layer: ${layer:-n/a} of 65" echo "- Driver running: ${driver_up}" if [ -n "$failed" ]; then echo echo "### Failure line" echo '```' echo "$failed" echo '```' fi echo echo "_Order: nvfp4 -> mxfp4 -> fp8 -> mxfp8. Repos: jaytonde05/Qwen3-32B--AWQ-wikitext2_" } > "$OUT" [ "$finished" -eq 1 ] && break sleep 30 done