#!/usr/bin/env bash set -uo pipefail if [[ "${1:-}" == "--help" ]]; then cat <<'USAGE' Compare inverse-change masks using the deepest N NF blocks and their forward input/output states. The deepest output is shared z: a zero-response control. Environment overrides (lists are space separated): NF_MASK_OUTPUT_ROOT New root (default: result/nf_mask_layer_ablation) NF_MASK_NOISE_MODES clean / training_noise (default: training_noise) NF_MASK_DEPTHS Deepest N blocks (default: 1 2 3 4 5 6) NF_MASK_STATES input / output (default: input output) NF_MASK_THRESHOLDS Thresholds (default: 0.3) NF_ABLATION_CATEGORY, NF_ABLATION_MAX_SAMPLES, NF_ABLATION_SEED Defaults: 0_random_140, 4, 999 CUDA_VISIBLE_DEVICES GPU selection (default: 0) Example: NF_MASK_NOISE_MODES='clean training_noise' NF_MASK_THRESHOLDS='0.2 0.3 0.4' \ bash scripts/run_nf_mask_layer_ablation.sh USAGE exit 0 fi cd "$(dirname "$0")/.." experiment_root="${NF_MASK_OUTPUT_ROOT:-result/nf_mask_layer_ablation}" if [[ -e "$experiment_root" ]]; then printf 'Choose a new NF_MASK_OUTPUT_ROOT: %s\n' "$experiment_root" >&2 exit 1 fi source /mnt/bn/jiangzhongtao/miniconda3/etc/profile.d/conda.sh conda activate pvd export HF_HUB_CACHE="$PWD/ckpts/hf_cache" export HF_HUB_OFFLINE=1 export TRANSFORMERS_OFFLINE=1 export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}" read -r -a modes <<< "${NF_MASK_NOISE_MODES:-training_noise}" read -r -a depths <<< "${NF_MASK_DEPTHS:-1 2 3 4 5 6}" read -r -a states <<< "${NF_MASK_STATES:-input output}" read -r -a thresholds <<< "${NF_MASK_THRESHOLDS:-0.3}" common=(--category "${NF_ABLATION_CATEGORY:-0_random_140}" --max-samples "${NF_ABLATION_MAX_SAMPLES:-4}" --seed "${NF_ABLATION_SEED:-999}") mkdir -p "$experiment_root" for mode in "${modes[@]}"; do noise_args=() case "$mode" in clean) ;; training_noise) noise_args=(--training-noise) ;; *) printf 'Unknown noise mode: %s\n' "$mode" >&2; exit 1 ;; esac for state in "${states[@]}"; do for depth in "${depths[@]}"; do group="$experiment_root/$mode/${state}_depth${depth}" mkdir -p "$group" for threshold in "${thresholds[@]}"; do python -u scripts/nf_local_affine_guidance_editing.py "${common[@]}" "${noise_args[@]}" \ --vae-latent mean --mask-method inverse_change --guidance 3.6 \ --mask-depth "$depth" --mask-state "$state" --mask-threshold "$threshold" \ --output-dir "$group/threshold_$threshold" \ 2>&1 | tee "$group/threshold_$threshold.log" done done done done bash /mnt/bn/jiangzhongtao/lingmin/ml-starflow/scripts/zhanka.sh