File size: 3,170 Bytes
5ce45af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# Deep mode on the evaluation subset: sampled attempts on RightNow Mini's engine (one GPU), then the selection.
#   GPU=0 PORT=9000 DEEP_STOP=1500 BATCHES="1 2;3 4" SELECT="2 4" bash tools/deep_run.sh        (run on the node in tmux)
# Attempts run two at a time (30 agent sessions each) so one GPU is not swamped. Each attempt is also scored alone:
# those are single-attempt scores at temperature 0.8, and the base the deep score must be read against.
set -u
R=/data/train/mini
GPU=${GPU:-0}; PORT=${PORT:-9000}; STOP=${DEEP_STOP:-1500}; NAME=mini-deep-g$GPU
export DOCKER=/usr/bin/docker
log() { echo "$(date -u +%FT%TZ) $*"; }
utc_now() { date -u +%H%M; }
count() { python3 -c "import json;print(len(json.load(open('$1'))))" 2>/dev/null || echo 0; }
cd $R/src
if [ -n "${WAIT_FOR:-}" ]; then
    log "deep: waiting for: $WAIT_FOR"
    until grep -q "$WAIT_FOR" ${WAIT_LOG:-$R/logs/speed_engine.log} 2>/dev/null; do sleep 15; done
fi
GPU=$GPU PORT=$PORT NAME=$NAME SERVED=inkling-2-mini MODEL_DIR=$R/models/Inkling-2-Mini DRAFTER_DIR=$R/models/Inkling-2-Mini-DFlash2 \
    PREPARED=$R/models/dflash2-prepared bash engine/serve.sh > $R/logs/serve-deep.log 2>&1 || { log "deep: THE ENGINE DID NOT START"; exit 1; }
log "deep: engine up on GPU $GPU"
DONE=""
IFS=";" read -r -a BATCH_LIST <<< "${BATCHES:-1 2;3 4;5 6;7 8}"
for batch in "${BATCH_LIST[@]}"; do
    [ "$(utc_now)" -ge "$STOP" ] && break
    log "deep: attempts $batch"
    TAG=deep POOL=$R/src/eval/subset.json DATA=verified SPLIT=test STEPS=100 MAXTOK=8192 WORKERS=30 ATTEMPTS="$batch" PORTS="$PORT" \
        bash train/gen.sh > $R/logs/deep-gen-$(echo $batch | tr ' ' '-').log 2>&1 &
    G=$!
    while kill -0 $G 2>/dev/null; do
        if [ "$(utc_now)" -ge "$STOP" ]; then
            log "deep: $STOP reached, stopping the attempts still running"
            for p in $(pgrep -f 'results/deep/[a]tt-'); do kill "$p" 2>/dev/null; done
            break
        fi
        sleep 20
    done
    wait $G 2>/dev/null
    for k in $batch; do [ "$(count $R/results/deep/att-$k/preds.json)" -ge 100 ] && DONE="$DONE $k"; done
    log "deep: complete attempts so far:$DONE"
done
n=0
for k in $DONE; do
    ( LABEL=deep-att-$k OUT=$R/results/deep/att-$k EW=8 bash eval/score.sh > $R/logs/deep-score-$k.log 2>&1 ) &
    n=$((n + 1)); [ $((n % 4)) = 0 ] && wait
done
wait
log "deep: single attempts (temperature 0.8) resolved: $(for k in $DONE; do python3 -c "import json;print(json.load(open('$R/results/deep/att-$k/summary.json'))['resolved'])" 2>/dev/null; done | tr '\n' ' ')"
for n in ${SELECT:-2 4 8}; do
    ok=1; for k in $(seq 1 $n); do [ "$(count $R/results/deep/att-$k/preds.json)" -ge 100 ] || ok=0; done
    [ "$ok" = 1 ] || { log "deep: N=$n: not all of attempts 1 to $n are complete"; continue; }
    $R/venv/bin/python deep/select.py --attempts $R/results/deep --n $n --url http://127.0.0.1:$PORT --model inkling-2-mini \
        --out $R/results/agent/deep-n$n > $R/logs/deep-select-$n.log 2>&1
    ( LABEL=deep-n$n EW=12 bash eval/score.sh >> $R/logs/deep-select-$n.log 2>&1 )
    log "deep: N=$n: $(tail -1 $R/logs/deep-select-$n.log | cut -c1-220)"
done
log "deep: done"