CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / evidence / amd-speed-20261114 / raw / spec-decode / card-s4 / dry_s4.sh
| 1 | #!/bin/bash |
| 2 | # spec-decode S4 rehearsal on the Spark CPU (never on the card). Usage: dry_s4.sh BUNDLE_DIR OUT_DIR |
| 3 | # 1. runs the cell's own check-and-unpack code with /workspace redirected to OUT_DIR/ws; |
| 4 | # 2. runs s4.sh with DRY=1 (real launchers under qemu must stop at exit 77 for every plan; fake_launch.py for the |
| 5 | # timed sequence; analysis and packaging as on the card); expects ANALYZE_RC=0 and every DRY-PLAN OK; |
| 6 | # 3. controls: a corrupted bundle is refused by the cell's sha256 assert; FAKE_MUTANT=1 (one wrong id in every |
| 7 | # OMPLAN02 run) makes the analysis fail. |
| 8 | set -u |
| 9 | B=$(cd "$1" && pwd); O=$2; rm -rf "$O"; mkdir -p "$O/ws"; O=$(cd "$O" && pwd) |
| 10 | S=$HOME/work/hive/uxl-brief-20261113/SpecDecode |
| 11 | export PATH=$HOME/work/hive/t_760d3a2e/venv-vllm/bin:$PATH |
| 12 | cell() { # WS: run the cell up to its background start, /workspace -> WS |
| 13 | python3 - "$1" "$B/cell-s4.py" <<'PY' |
| 14 | import sys; ws, cell = sys.argv[1], open(sys.argv[2]).read() |
| 15 | exec(compile(cell.split("subprocess.Popen")[0].replace("/workspace", ws), "cell", "exec"), {}); print("CELL UNPACK OK") |
| 16 | PY |
| 17 | } |
| 18 | cp "$B/s4-bundle.tar.xz" "$O/ws/"; cell "$O/ws" || { echo "DRY-S4 FAIL cell"; exit 1; } |
| 19 | export DRY=1 CUDAPP=$S/CUDApp AMDSERVE_WEIGHTS=$HOME/workspace/l182-final/aien-demo/weights/qwen3.8-27b-fp8 S4_DIR=$O/ws/s4 |
| 20 | sh "$O/ws/s4/s4.sh"; grep -h "DRY-PLAN\|EMIT \|PLAN \|ANALYZE_RC\|S4-DONE\|MISMATCH\|FAILED" "$O/ws/s4/s4.log" | cut -c1-160 |
| 21 | tail -n 3 "$O/ws/s4/analyze.log" |
| 22 | ok=1; grep -q "ANALYZE_RC=0" "$O/ws/s4/s4.log" || ok=0; grep -q "DRY-PLAN FAIL" "$O/ws/s4/s4.log" && ok=0 |
| 23 | # control: corrupted bundle |
| 24 | mkdir -p "$O/bad"; python3 -c "import sys;b=bytearray(open(sys.argv[1],'rb').read());b[1000]^=1;open(sys.argv[2],'wb').write(b)" "$B/s4-bundle.tar.xz" "$O/bad/s4-bundle.tar.xz" |
| 25 | if cell "$O/bad" 2>"$O/bad.err"; then echo "DRY-S4 CONTROL FAIL: corrupted bundle accepted"; ok=0 |
| 26 | else grep -q "bundle sha256 mismatch" "$O/bad.err" && echo "DRY-S4 CONTROL corrupted bundle refused" || { echo "DRY-S4 CONTROL FAIL: other error"; ok=0; }; fi |
| 27 | # control: one wrong id in OMPLAN02 runs must fail the analysis |
| 28 | ( cd "$O/ws/s4" && rm -rf runs && mkdir runs && FAKE_MUTANT=1 python3 fake_launch.py plans/lh-r2h/plan.plan > runs/r2h-1.txt && |
| 29 | python3 fake_launch.py plans/lh-plain/plan.plan > runs/plain-1.txt && |
| 30 | if python3 analyze_s4.py runs published-ids.json golden24.json mut.json > mut.log; then echo "DRY-S4 CONTROL FAIL: wrong id passed"; exit 1 |
| 31 | else echo "DRY-S4 CONTROL wrong id caught"; fi ) || ok=0 |
| 32 | [ $ok = 1 ] && echo "DRY-S4 OK" || echo "DRY-S4 FAIL" |