daim / scripts /run_benchmark_pair.sh
yaro1214's picture
Upload dflash source snapshot
09af6cc verified
Raw History Blame Contribute Delete
2.28 kB
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo "usage: $0 DATASET NUM_SAMPLES" >&2
exit 2
fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
PROJECT_DIR=$(dirname "$SCRIPT_DIR")
DATASET=$1
NUM_SAMPLES=$2
TARGET_MODEL=${TARGET_MODEL:-Qwen/Qwen3-4B}
RELAY_DRAFT=${RELAY_DRAFT:-/mnt/cpfs/zyj/chat/code/SpecForge_suffix/outputs/qwen3-4b-target-hidden-v4-two-iter-perfectblend-1epoch-a100x16-20260815-100730/epoch_0_step_15000}
BASELINE_DRAFT=${BASELINE_DRAFT:-/mnt/cpfs/zyj/chat/code/SpecForge_suffix/outputs/qwen3-4b-dflash-baseline-perfectblend-1epoch-a100x16-20260817-110523/epoch_1_step_21868}
OUTPUT_ROOT=${OUTPUT_ROOT:-$PROJECT_DIR/outputs/target-hidden-v4-pfbd-final}
MAX_NEW_TOKENS=${MAX_NEW_TOKENS:-2048}
export HOME=${HOME:-/mnt/cpfs/zyj}
export HF_HOME=${HF_HOME:-/mnt/cpfs/zyj/.cache/huggingface}
export TRANSFORMERS_CACHE=${TRANSFORMERS_CACHE:-$HF_HOME}
export TOKENIZERS_PARALLELISM=false
export PYTHONPATH="$PROJECT_DIR:${PYTHONPATH:-}"
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-0}
source /mnt/cpfs/zyj/miniconda3/etc/profile.d/conda.sh
conda activate dflash
cd "$PROJECT_DIR"
DATASET_DIR="$OUTPUT_ROOT/$DATASET"
mkdir -p "$DATASET_DIR"
# Keep the requested order: relay first, then all-mask baseline DFLASH.
# if [[ ! -f "$DATASET_DIR/relay.DONE" ]]; then
# torchrun --standalone --nproc_per_node=1 -m dflash.benchmark \
# --backend transformers \
# --model "$TARGET_MODEL" \
# --draft-model "$RELAY_DRAFT" \
# --dataset "$DATASET" \
# --max-samples "$NUM_SAMPLES" \
# --max-new-tokens "$MAX_NEW_TOKENS" \
# --temperature 0 \
# --block-size 16 \
# --target-hidden-relay \
# >"$DATASET_DIR/relay.log" 2>&1
# touch "$DATASET_DIR/relay.DONE"
# fi
if [[ ! -f "$DATASET_DIR/dflash.DONE" ]]; then
torchrun --standalone --nproc_per_node=1 -m dflash.benchmark \
--backend transformers \
--model "$TARGET_MODEL" \
--draft-model "$BASELINE_DRAFT" \
--dataset "$DATASET" \
--max-samples "$NUM_SAMPLES" \
--max-new-tokens "$MAX_NEW_TOKENS" \
--temperature 0 \
--block-size 16 \
>"$DATASET_DIR/dflash.log" 2>&1
touch "$DATASET_DIR/dflash.DONE"
fi