Cccccz/HY
0
1#!/usr/bin/env bash2set -euo pipefail3 4repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"5python_bin="${PREDICTOR_PYTHON_BIN:-/mnt/local_nvme/cz/envs/hy_worldplay/bin/python3.10}"6dataset_root="${repo_root}/datasets/hyworldplay_predictor_vbench_val25_test50"7validation_root="${dataset_root}/validation"8base_model="${repo_root}/outputs/hf_snapshot_repaired_9b49404"9action_ckpt="/mnt/local_nvme/cz/checkpoints/hy_worldplay/huggingface/hub/models--tencent--HY-WorldPlay/snapshots/f4c29235647707b571479a69b569e4166f9f5bf8/ar_distilled_action_model/diffusion_pytorch_model.safetensors"10weights="${repo_root}/checkpoints/predictor_v4_prefeature_blocks1-52_fp32master_8gpu_flr1e-4_blr1e-5_schedsteps2000_swarmup100_bwarmup100_swanlab/predictor_step_02000.safetensors"11confidence_checkpoint="${repo_root}/confidence_validation/checkpoints/confidence_c1.pt"12 13tags=(r10 r25 r33 r50)14thresholds=(-3.523588657 -3.915276289 -4.329442501 -4.798926830)15gpu_groups=("0 1" "2 3" "4 5" "6 7")16 17export PYTHONPATH="${repo_root}"18export HY_PROFILE_TIMING=119 20launch_group() {21 local phase="$1"22 local group_index="$2"23 local tag="${tags[$group_index]}"24 local threshold="${thresholds[$group_index]}"25 local eval_name="eval_validation25_stage1-c1-threshold-${tag}_blocks1-52_fp32master_step2000"26 local eval_root="${dataset_root}/evaluations/${eval_name}"27 local log_dir="${eval_root}/logs"28 local -a gpus=(${gpu_groups[$group_index]})29 mkdir -p "${log_dir}"30 local worker_id gpu31 local -a pids=()32 for worker_id in "${!gpus[@]}"; do33 gpu="${gpus[$worker_id]}"34 if [[ "${phase}" == "generate" ]]; then35 CUDA_VISIBLE_DEVICES="${gpu}" "${python_bin}" -u \36 "${repo_root}/tools/generate_predictor_v4_train_case_eval.py" \37 --dataset_root "${validation_root}" \38 --output_root "${eval_root}" \39 --base_model "${base_model}" \40 --action_ckpt "${action_ckpt}" \41 --weights "${weights}" \42 --source_blocks 1,52 \43 --predictor_variant v4 \44 --previous_condition_mode same_step \45 --replace_steps 1,2,3 \46 --modes predictor \47 --confidence_checkpoint "${confidence_checkpoint}" \48 --confidence_threshold "${threshold}" \49 --worker_id "${worker_id}" \50 --num_workers "${#gpus[@]}" \51 >"${log_dir}/generate_worker_${worker_id}.log" 2>&1 &52 else53 CUDA_VISIBLE_DEVICES="${gpu}" "${python_bin}" -u \54 "${repo_root}/tools/compute_predictor_v4_train_case_metrics.py" \55 --dataset_root "${validation_root}" \56 --output_root "${eval_root}" \57 --num_cases 25 \58 --reference_subdir full \59 --modes predictor \60 --metric_batch_size 4 \61 --worker_id "${worker_id}" \62 --num_workers "${#gpus[@]}" \63 >"${log_dir}/metrics_worker_${worker_id}.log" 2>&1 &64 fi65 pids+=("$!")66 done67 local failed=0 pid68 for pid in "${pids[@]}"; do69 if ! wait "${pid}"; then failed=1; fi70 done71 if [[ "${failed}" -ne 0 ]]; then72 echo "${phase} failed for ${tag}; inspect ${log_dir}" >&273 return 174 fi75 if [[ "${phase}" == "generate" ]]; then76 [[ $(find "${eval_root}/predictor" -type f -name '*.mp4' | wc -l) -eq 100 ]]77 date -u +%FT%TZ >"${eval_root}/generation.completed"78 else79 "${python_bin}" "${repo_root}/tools/merge_predictor_v4_train_case_metrics.py" \80 --output_root "${eval_root}" \81 --num_workers "${#gpus[@]}" \82 --num_cases 25 \83 --modes predictor \84 --replace_steps 1,2,3 \85 --reference_label "Full-DiT validation videos" \86 >"${log_dir}/metrics_merge.log" 2>&187 date -u +%FT%TZ >"${eval_root}/metrics.completed"88 fi89}90 91run_phase() {92 local phase="$1"93 local -a group_pids=()94 local group_index95 for group_index in "${!tags[@]}"; do96 launch_group "${phase}" "${group_index}" &97 group_pids+=("$!")98 done99 local failed=0 pid100 for pid in "${group_pids[@]}"; do101 if ! wait "${pid}"; then failed=1; fi102 done103 [[ "${failed}" -eq 0 ]]104}105 106run_phase generate107run_phase metrics108"${python_bin}" "${repo_root}/tools/summarize_c1_threshold_validation25.py"109 110 