Download source/project/scripts/run_new_generation_benchmark.sh from lupele/StatePlay-Reward-2280: direct link, hf CLI and curl.
- Browser
- Download file 7.91 kB
-
https://huggingface.co/datasets/lupele/StatePlay-Reward-2280/resolve/main/source/project/scripts/run_new_generation_benchmark.sh
- Command line
-
hf download hf://datasets/lupele/StatePlay-Reward-2280/source/project/scripts/run_new_generation_benchmark.sh
-
curl -L -o run_new_generation_benchmark.sh https://huggingface.co/datasets/lupele/StatePlay-Reward-2280/resolve/main/source/project/scripts/run_new_generation_benchmark.sh
7.91 kB
| set -Eeuo pipefail | |
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | |
| BENCH="$ROOT/evaluation/new_generation100" | |
| DATA="$ROOT/data/stateplay_selftest_100_ibuki_round1_new_generation" | |
| ARCHIVE="/private/StatePlay_selftest_100_Ibuki_Round1_NewGeneration_complete.zip" | |
| SELECT="$BENCH/selection.json" | |
| GENERATED="$BENCH/generated" | |
| LOGS="$BENCH/logs" | |
| OFFICIAL="$ROOT/examples/checkpoint/StatePlay.safetensors" | |
| TRAINED="$ROOT/outputs/latent_world/step-4572.safetensors" | |
| ORIGINAL_COMMIT="5da875b6addd4cd012fd9a2e76b3a0a9a9497cb2" | |
| ORIGINAL_SCRIPT_SHA="ab12fb817add992bd384061296bb8b5e8aa635edea9a6f42d8fed1cafb68e2a9" | |
| OFFICIAL_SHA="aba9747fcd3f0c0a3546941253cd99ecd5dbc2c69747d647b91de84ee41f722f" | |
| TRAINED_SHA="53eff9e5e59e92bb3cc7810e3ff36f9ee490be4a122a3a8ff96a4de0a03b4c5d" | |
| MAX_ATTEMPTS="${STATEPLAY_BENCHMARK_MAX_ATTEMPTS:-6}" | |
| STAGGER="${STATEPLAY_BENCHMARK_STAGGER_SECONDS:-60}" | |
| GPUS="${STATEPLAY_BENCHMARK_GPUS:-0,1,2,3,4,5,6}" | |
| IFS=',' read -r -a GPU_LIST <<< "$GPUS" | |
| mkdir -p "$LOGS" "$GENERATED" | |
| exec 9>"$LOGS/.run.lock" | |
| flock -n 9 || { echo "Benchmark is already running" >&2; exit 1; } | |
| SOURCE_DIR="" | |
| status() { | |
| printf '%s\t%s\n' "$(date -u +%FT%TZ)" "$1" | tee "$LOGS/status.txt" | |
| } | |
| finish() { | |
| code="$1" | |
| if [[ -n "$SOURCE_DIR" ]]; then rm -rf "$SOURCE_DIR"; fi | |
| if (( code == 0 )); then status complete; else status "failed exit=$code"; fi | |
| } | |
| trap 'finish "$?"' EXIT | |
| assert_sha() { | |
| local actual | |
| [[ -f "$1" ]] || { echo "Missing required file: $1" >&2; return 1; } | |
| actual="$(sha256sum "$1" | awk '{print $1}')" | |
| [[ "$actual" == "$2" ]] || { echo "SHA-256 mismatch: $1 ($actual)" >&2; return 1; } | |
| echo "SHA-256 verified: $1 ($actual)" | |
| } | |
| retry_command() { | |
| local name="$1"; shift | |
| local attempt | |
| for ((attempt=1; attempt<=MAX_ATTEMPTS; attempt++)); do | |
| status "$name attempt=$attempt/$MAX_ATTEMPTS" | |
| if "$@" >>"$LOGS/${name}.log" 2>&1; then return 0; fi | |
| echo "$name attempt $attempt failed; see $LOGS/${name}.log" >&2 | |
| if (( attempt < MAX_ATTEMPTS )); then sleep "$((attempt * 30))"; fi | |
| done | |
| return 1 | |
| } | |
| verify_run() { | |
| local run="$1"; shift | |
| python "$ROOT/scripts/verify_new_generation_outputs.py" \ | |
| --selection "$SELECT" --generated-root "$GENERATED" \ | |
| --run-name "$run" --remove-invalid "$@" | |
| } | |
| run_shards() { | |
| local kind="$1" run="$2" architecture="$3" | |
| local attempt shard gpu pid | |
| local -a pids=() pending=() next=() | |
| for shard in "${!GPU_LIST[@]}"; do pending+=("$shard"); done | |
| mkdir -p "$LOGS/$run" "$GENERATED/$run" | |
| for ((attempt=1; attempt<=MAX_ATTEMPTS; attempt++)); do | |
| status "${kind}_inference attempt=$attempt/$MAX_ATTEMPTS pending=${pending[*]}" | |
| pids=() | |
| for shard in "${pending[@]}"; do | |
| gpu="${GPU_LIST[$shard]}" | |
| ( | |
| sleep "$((shard * STAGGER))" | |
| export CUDA_VISIBLE_DEVICES="$gpu" TOKENIZERS_PARALLELISM=false | |
| if [[ "$kind" == official ]]; then | |
| unset PYTHONPATH | |
| python "$SOURCE_DIR/scripts/generate_examples.py" \ | |
| --manifest "$BENCH/official_inputs/manifest_$(printf '%02d' "$shard").csv" \ | |
| --output-dir "$GENERATED/$run" --base-model "$ROOT/base_model" \ | |
| --checkpoint "$OFFICIAL" --skip-existing | |
| else | |
| python "$ROOT/scripts/generate_proxy_benchmark.py" \ | |
| --manifest "$SELECT" --checkpoint "$TRAINED" \ | |
| --run-name "$run" --base-model "$ROOT/base_model" \ | |
| --output-root "$GENERATED" --shard-index "$shard" \ | |
| --num-shards "${#GPU_LIST[@]}" --skip-existing | |
| fi | |
| ) >"$LOGS/$run/shard_${shard}_attempt_${attempt}.log" 2>&1 & | |
| pids+=("$!") | |
| echo "$kind shard=$shard GPU=$gpu PID=${pids[-1]}" | |
| done | |
| next=() | |
| for index in "${!pending[@]}"; do | |
| shard="${pending[$index]}"; pid="${pids[$index]}" | |
| if ! wait "$pid"; then | |
| next+=("$shard") | |
| continue | |
| fi | |
| if ! rg -q -F "$architecture" "$LOGS/$run/shard_${shard}_attempt_${attempt}.log"; then | |
| echo "Unexpected model architecture on $kind shard $shard" >&2 | |
| next+=("$shard") | |
| fi | |
| done | |
| if (( ${#next[@]} == 0 )); then | |
| if verify_run "$run" "${VERIFY_ARGS[@]}" >>"$LOGS/$run/verify.log" 2>&1; then | |
| return 0 | |
| fi | |
| echo "$kind generated-video verification failed; retrying incomplete clips" >&2 | |
| for shard in "${!GPU_LIST[@]}"; do next+=("$shard"); done | |
| fi | |
| pending=("${next[@]}") | |
| if (( attempt < MAX_ATTEMPTS )); then sleep "$((attempt * 30))"; fi | |
| done | |
| echo "$kind inference did not produce 100 verified videos" >&2 | |
| return 1 | |
| } | |
| cd "$ROOT" | |
| status preflight | |
| [[ ${#GPU_LIST[@]} -eq 7 ]] || { echo "Expected seven GPU IDs, got: $GPUS" >&2; exit 2; } | |
| [[ -d "$DATA" && -f "$ARCHIVE" && -d "$ROOT/base_model/Wan-AI/Wan2.2-TI2V-5B" ]] || { | |
| echo "Dataset archive, extraction, or Wan base model is missing" >&2; exit 2; | |
| } | |
| : "${STATEPLAY_GPT_API_KEY:?Set STATEPLAY_GPT_API_KEY before launching}" | |
| : "${STATEPLAY_GEMINI_API_KEY:?Set STATEPLAY_GEMINI_API_KEY before launching}" | |
| assert_sha "$OFFICIAL" "$OFFICIAL_SHA" | |
| assert_sha "$TRAINED" "$TRAINED_SHA" | |
| git cat-file -e "${ORIGINAL_COMMIT}^{commit}" | |
| SOURCE_DIR="$(mktemp -d /tmp/stateplay-original-inference.XXXXXX)" | |
| git archive "$ORIGINAL_COMMIT" | tar -x -C "$SOURCE_DIR" | |
| assert_sha "$SOURCE_DIR/scripts/generate_examples.py" "$ORIGINAL_SCRIPT_SHA" | |
| printf '%s\n' \ | |
| "official_checkpoint=$OFFICIAL" "official_sha256=$OFFICIAL_SHA" \ | |
| "official_source_commit=$ORIGINAL_COMMIT" "official_inference_script_sha256=$ORIGINAL_SCRIPT_SHA" \ | |
| "trained_checkpoint=$TRAINED" "trained_sha256=$TRAINED_SHA" \ | |
| "trained_inference_script=$ROOT/scripts/generate_proxy_benchmark.py" \ | |
| >"$BENCH/model_source_identity.txt" | |
| retry_command prepare_selection python "$ROOT/scripts/prepare_new_generation_benchmark.py" \ | |
| --dataset "$DATA" --archive "$ARCHIVE" --output "$SELECT" | |
| retry_command prepare_original_inputs python "$ROOT/scripts/prepare_official_selftest_inputs.py" \ | |
| --selection "$SELECT" --output-dir "$BENCH/official_inputs" --shards "${#GPU_LIST[@]}" | |
| VERIFY_ARGS=(--require-state-text) | |
| run_shards official official_hf_origin_main \ | |
| 'architecture=StatePlay DiT loaded: 2129 keys (30 action_embedders, 14 state keys), missing=0, unexpected=0' | |
| retry_command finalize_official python "$ROOT/scripts/finalize_proxy_benchmark.py" \ | |
| --selection "$SELECT" --run-name official_hf_origin_main \ | |
| --checkpoint "$OFFICIAL" --generated-root "$GENERATED" | |
| VERIFY_ARGS=() | |
| run_shards trained trained_step4572 \ | |
| 'architecture=latent-state loaded: 1319 keys (30 action_embedders, 0 state keys), missing=0, unexpected=0' | |
| retry_command finalize_trained python "$ROOT/scripts/finalize_proxy_benchmark.py" \ | |
| --selection "$SELECT" --run-name trained_step4572 \ | |
| --checkpoint "$TRAINED" --generated-root "$GENERATED" | |
| export STATEPLAY_GPT_BASE_URL="https://newapi.dragon3api.com/v1" | |
| export STATEPLAY_GEMINI_BASE_URL="https://newapi.dragon3api.com/v1" | |
| export STATEPLAY_GPT_MODEL="gpt-5.5" | |
| export STATEPLAY_GEMINI_MODEL="gemini-3.1-pro-preview" | |
| export STATEPLAY_GEMINI_TRANSPORT="openai" | |
| export TOKENIZERS_PARALLELISM=false | |
| for run in official_hf_origin_main trained_step4572; do | |
| retry_command "visual_$run" python "$ROOT/stateplay_eval.py" \ | |
| --manifest "$BENCH/manifest_${run}_visual.csv" \ | |
| --output "$BENCH/results_${run}_visual.json" \ | |
| --visual-metrics ssim lpips --mechanics none \ | |
| --device cuda:0 --lpips-batch-size 8 | |
| retry_command "judges_$run" python "$ROOT/stateplay_eval.py" \ | |
| --manifest "$BENCH/manifest_${run}_mechanics.csv" \ | |
| --output "$BENCH/results_${run}_mechanics.json" \ | |
| --visual-metrics --mechanics both \ | |
| --mechanics-runs 3 --mechanics-workers 30 \ | |
| --gemini-frames 24 --gpt-frames 24 \ | |
| --judge-image-max-side 512 --judge-max-completion-tokens 4096 \ | |
| --api-retries 5 --judge-retries 3 | |
| done | |
| echo "Both models: 100 verified videos, SSIM/LPIPS, Gemini and GPT evaluations completed." | |