KBench / tools /dist_factory /validate2gpu.sh
ZMC2019's picture
Reorganise: group 313 tasks into 17 families under tasks/, generators under tools/ (part 10)
0f775e2 verified
Raw
History Blame Contribute Delete
1.92 kB
#!/bin/bash
# Hand validation for the 2-GPU dist-* tasks. `_factory/validate.sh` cannot be used: it assumes a
# single-process grader and builds its submission shim by importing reference.py, which for these tasks
# would call a torch.distributed collective that the grader BLOCKS inside a graded call.
#
# Instead, each task is graded twice in a real 2-rank container on GPUs 0 and 1:
# * the untouched stub -> must be reward 0
# * _dist_factory/refimpl/<task>.py, a hand-written -> must be reward > 0 with correct = 1.0
# reference-EQUIVALENT submission that moves the
# bytes itself (shared mapped host memory + flags)
#
# bash _dist_factory/validate2gpu.sh [task ...] # default: all six
set -u
LANE=/home/zhuominc/MLE-Bench/mle_tasks/kernel-generation/kernels
IMG=mle-v-dist-allreduce-rmsnorm # one image serves them all: same base + same pip_extra
TASKS=${@:-"dist-allreduce-rmsnorm dist-oneshot-allreduce dist-reduce-scatter-rmsnorm \
dist-allgather-gemm-overlap dist-moe-a2a-dispatch dist-tp-embedding-allreduce"}
for T in $TASKS; do
D=$LANE/$T
MOD=$(grep -oP '(?<=^COPY )\S+\.py(?= /app/)' "$D/environment/Dockerfile" | tail -1)
C=val-$T
docker rm -f $C >/dev/null 2>&1
docker run -d --name $C --gpus '"device=0,1"' --shm-size=8g --ipc=host --cap-add SYS_ADMIN \
--entrypoint sleep $IMG infinity >/dev/null
docker cp "$D/tests" $C:/tests >/dev/null
for f in reference.py measure.py "$MOD"; do docker cp "$D/environment/$f" $C:/app/$f >/dev/null; done
S=$(timeout 3000 docker exec $C bash /tests/test.sh 2>&1 | grep -E "^reward" | tail -1)
docker cp "$LANE/_dist_factory/refimpl/${T//-/_}.py" $C:/app/$MOD >/dev/null
R=$(timeout 3000 docker exec $C bash /tests/test.sh 2>&1 | grep -E "^reward" | tail -1)
docker rm -f $C >/dev/null 2>&1
printf "%-32s stub[%s] refimpl[%s]\n" "$T" "${S#reward: }" "${R#reward: }"
done