File size: 3,076 Bytes
86e3bb9 | 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="${PROJECT_DIR:-/workspace/KAWK50M}"
RECOVERY_CONFIG="${RECOVERY_CONFIG:-configs/pretrain_fixed_recovery_100m_5090.yaml}"
SCRATCH_CONFIG="${SCRATCH_CONFIG:-configs/pretrain_fixed_scratch_100m_5090.yaml}"
BROKEN_CHECKPOINT="${BROKEN_CHECKPOINT:-runs/kawk-1.5-50m-v2-cpt-3b-5090/checkpoint-00024415}"
RECOVERY_RUN="${RECOVERY_RUN:-runs/kawk50m-fixed-recovery-100m-5090}"
SCRATCH_RUN="${SCRATCH_RUN:-runs/kawk50m-fixed-scratch-100m-5090}"
REPORT_DIR="${REPORT_DIR:-reports/fixed-objective-100m-ab}"
VALIDATION_BIN="${VALIDATION_BIN:-data/tokenized-v2b-100m/validation.bin}"
CLEAN_DIR="${CLEAN_DIR:-data/clean-v2-full}"
cd "${PROJECT_DIR}"
source "${PROJECT_DIR}/.venv/bin/activate"
for path in "${RECOVERY_RUN}" "${SCRATCH_RUN}" "${REPORT_DIR}"; do
if [[ -e "${path}" ]]; then
echo "Refusing to overwrite existing A/B artifact: ${path}" >&2
exit 1
fi
done
if [[ ! -f "${BROKEN_CHECKPOINT}/model/model.safetensors" ]]; then
echo "Recovery source checkpoint is missing: ${BROKEN_CHECKPOINT}" >&2
exit 1
fi
python -m scripts.preflight --config "${RECOVERY_CONFIG}"
python -m scripts.preflight --config "${SCRATCH_CONFIG}"
mkdir -p "${REPORT_DIR}"
python -u -m scripts.pretrain \
--config "${RECOVERY_CONFIG}" \
--init-from "${BROKEN_CHECKPOINT}" \
2>&1 | tee "${REPORT_DIR}/recovery-train.log"
python -u -m scripts.pretrain \
--config "${SCRATCH_CONFIG}" \
2>&1 | tee "${REPORT_DIR}/scratch-train.log"
recovery_name="$(cat "${RECOVERY_RUN}/latest_checkpoint.txt")"
scratch_name="$(cat "${SCRATCH_RUN}/latest_checkpoint.txt")"
recovery_checkpoint="${RECOVERY_RUN}/${recovery_name}"
scratch_checkpoint="${SCRATCH_RUN}/${scratch_name}"
common_evaluation=(
--validation-bin "${VALIDATION_BIN}"
--sequence-length 1024
--batch-size 32
--eval-batches 20
--max-new-tokens 100
--temperature 0.7
--top-k 50
--top-p 0.9
--repetition-penalty 1.15
--seed 42
)
python -m scripts.evaluate \
--checkpoint "${BROKEN_CHECKPOINT}" \
"${common_evaluation[@]}" \
> "${REPORT_DIR}/broken-final-evaluation.json"
python -m scripts.evaluate \
--checkpoint "${recovery_checkpoint}" \
"${common_evaluation[@]}" \
> "${REPORT_DIR}/recovery-evaluation.json"
python -m scripts.evaluate \
--checkpoint "${scratch_checkpoint}" \
"${common_evaluation[@]}" \
> "${REPORT_DIR}/scratch-evaluation.json"
python -m scripts.evaluate_text \
--checkpoint "${recovery_checkpoint}" \
--input "${CLEAN_DIR}/validation-*.jsonl" \
--context-length 1024 \
--max-documents 200 \
> "${REPORT_DIR}/recovery-byte-evaluation.json"
python -m scripts.evaluate_text \
--checkpoint "${scratch_checkpoint}" \
--input "${CLEAN_DIR}/validation-*.jsonl" \
--context-length 1024 \
--max-documents 200 \
> "${REPORT_DIR}/scratch-byte-evaluation.json"
printf '%s\n' "${recovery_checkpoint}" > "${REPORT_DIR}/recovery-checkpoint.txt"
printf '%s\n' "${scratch_checkpoint}" > "${REPORT_DIR}/scratch-checkpoint.txt"
echo "Correct-objective 100M recovery/scratch A/B training and evaluation complete."
|