T-Stitch / CDF_EXPERIMENTS.md
Ouzhang's picture
Add files using upload-large-folder tool
e5371e6 verified
|
Raw
History Blame Contribute Delete
47.7 kB
# CDF / CST Experiment Protocol
This document defines the experiments for Curricular Diffusion Finetuning (CDF) on top of the existing T-Stitch codebase.
Run commands from the repository root unless a command explicitly changes directory.
Large runs require the original checkpoints, ImageNet or COCO data, ADM-style reference `.npz` files, and GPUs.
Paths in angle brackets are user-provided paths.
## 0. Experiment Runbook
This section is the execution checklist. Each experiment has a short code name that is used as the tmux session name, log directory, output directory, and table method key.
### 0.1 Experiment Table
| Code | Stage | Meaning | Train? | Primary output |
|---|---|---|---|---|
| `smoke_cst_fa` | sanity | 20-step LDM CST+FA smoke test; verifies data, LR scaling, boundary routing, and checkpoint writing. | yes | `logs/cdf/ldm/smoke_cst_fa` |
| `nft` | baseline / tuning reference | No-training LDM T-Stitch baseline on ImageNet for ratios `0.0,0.1,...,1.0`; gives the FID/IS reference before any tuning. | no | `outputs/cdf/ldm/nft` |
| `lr_sweep_cst_cosine` | tuning | Sweep CST cosine learning rate over `3e-6,1e-5,3e-5,1e-4` for 20k steps. | yes | `logs/cdf/ldm/lr_sweep_cst_cosine` |
| `lr_sweep_cst_cosine_eval` | tuning eval | Evaluate LR sweep on key ratios with 1000 samples. | no | `outputs/cdf/ldm/lr_sweep_cst_cosine` |
| `fa_sweep_cst_cosine` | tuning | Sweep FA weights after selecting `BEST_LR`. | yes | `logs/cdf/ldm/fa_sweep_cst_cosine` |
| `fa_sweep_cst_cosine_eval` | tuning eval | Evaluate FA sweep on key ratios with 1000 samples. | no | `outputs/cdf/ldm/fa_sweep_cst_cosine` |
| `schedule_ablation` | tuning / ablation | Compare curriculum schedules after selecting `BEST_LR`. | yes | `logs/cdf/ldm/schedule_ablation` |
| `schedule_ablation_eval` | tuning eval | Evaluate schedule ablation on key ratios or full ratios. | no | `outputs/cdf/ldm/schedule_ablation` |
| `cst_cosine` | main LDM | Full 200k-step CST with cosine curriculum, no FA. | yes | `logs/cdf/ldm/cst_cosine` |
| `cst_cosine_eval` | main eval | Evaluate `cst_cosine` on all ratios with 5000 samples. | no | `outputs/cdf/ldm/cst_cosine` |
| `cst_cosine_fa` | main LDM | Full 200k-step CST + FA with best FA weight. | yes | `logs/cdf/ldm/cst_cosine_fa` |
| `cst_cosine_fa_eval` | main eval | Evaluate `cst_cosine_fa` on all ratios with 5000 samples. | no | `outputs/cdf/ldm/cst_cosine_fa` |
| `frft` | baseline | Fixed-ratio fine-tuning, one junior checkpoint per ratio. | yes | `logs/cdf/ldm/frft` |
| `frft_eval` | baseline eval | Cross-ratio evaluation of all FRFT checkpoints. | no | `outputs/cdf/ldm/frft` |
| `senior_only` | baseline | Freeze junior and train senior only. | yes | `logs/cdf/ldm/senior_only` |
| `senior_only_eval` | baseline eval | Evaluate senior-only checkpoints. | no | `outputs/cdf/ldm/senior_only` |
| `fmgt` | baseline | Full model group training; jointly tune junior and senior. | yes | `logs/cdf/ldm/fmgt` |
| `fmgt_eval` | baseline eval | Evaluate FMGT checkpoints. | no | `outputs/cdf/ldm/fmgt` |
| `dit_nft` | DiT | DiT-S/2 + DiT-XL/2 no-finetuning T-Stitch baseline. | no | `outputs/cdf/dit/dit_nft` |
| `dit_cst_cosine` | DiT | DiT CST training with cosine curriculum. | yes | `logs/cdf/dit/dit_cst_cosine` |
| `dit_cst_cosine_eval` | DiT eval | Evaluate DiT CST on all ratios. | no | `outputs/cdf/dit/dit_cst_cosine` |
| `dit_cst_cosine_fa` | DiT | DiT CST + FA training. | yes | `logs/cdf/dit/dit_cst_cosine_fa` |
| `dit_cst_cosine_fa_eval` | DiT eval | Evaluate DiT CST+FA on all ratios. | no | `outputs/cdf/dit/dit_cst_cosine_fa` |
| `dit_sampler_ablation` | DiT ablation | Evaluate DiT CST under DDPM, DDIM, and DPM-Solver++. | no | `outputs/cdf/dit/dit_sampler_ablation_*` |
| `sd_nft` | SD / COCO | SD v1.4 + BK-SDM Tiny no-training T-Stitch on COCO. | no | `outputs/cdf/sd/nft_fixed` |
| `sd_deepcache` | SD / COCO | SD NFT plus DeepCache. | no | `outputs/cdf/sd/deepcache_i3_fixed` |
| `sd_tome` | SD / COCO | SD NFT plus ToMe token merging. | no | `outputs/cdf/sd/tome_05_fixed` |
| `sdxl_cst_cosine` | optional SDXL | Implemented SDXL/SSD-1B CDF training; not the SD v1.4 Table 2 setup. | yes | `logs/cdf/sd/sdxl_cst_cosine` |
Recommended order for finding the best training parameters:
```text
smoke_cst_fa -> nft -> lr_sweep_cst_cosine -> lr_sweep_cst_cosine_eval -> fa_sweep_cst_cosine -> fa_sweep_cst_cosine_eval -> schedule_ablation -> schedule_ablation_eval
```
Only after selecting `BEST_LR`, `BEST_FA`, and `BEST_SCHEDULE`, run the full 200k-step main experiments.
Sampling resume behavior:
- LDM evaluation skips a ratio if `samples/seed-...-ratio-<r>.npz` already exists.
- If sampling was interrupted before `.npz` creation, rerun the same command; existing PNG batches are skipped and missing images are generated.
- If `.npz` exists but `metrics-ratio-<r>.txt` is missing, rerun the same command; sampling is skipped and only the evaluator runs.
- If you want a completely fresh run, remove the corresponding output directory first.
Runtime logs:
- `run_cdf_experiments.sh` writes stdout/stderr to `run_logs/<command>/<timestamp>.log` and still prints to tmux.
- Set `CDF_RUN_LOG=/path/to/file.log` to choose a specific log path.
- Set `CDF_DISABLE_RUN_LOG=1` to disable automatic tee logging.
Evaluator device and metric resume:
- The runner tries the TensorFlow FID/IS evaluator on GPU first, then falls back to CPU if TensorFlow CUDA fails.
- Set `CDF_EVALUATOR_USE_GPU=1` to force GPU evaluator and fail if it cannot start.
- Set `CDF_EVALUATOR_USE_GPU=0` to force CPU evaluator.
- Existing metric files are skipped only when they contain both `FID:` and `Inception Score:`. Partial crashed logs are recomputed.
### 0.2 Tuning Commands
```bash
# LDM Smoke CST+FA
tmux new -s smoke_cst_fa
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
bash run_cdf_experiments.sh ldm-train-cst-fa \
--data-root "$LDM_DATA" \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.2 \
--fa-weight 0.1 \
--fa-boundary-width 10 \
--logdir logs/cdf/ldm/smoke_cst_fa \
--max-steps 20 \
--batch-size 2 \
--num-workers 0 \
--learning-rate 1e-5 \
--scale-lr false \
--gpus 0
```
```bash
# LDM NFT Baseline Before Tuning
tmux new -s nft
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-nft \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/nft \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM LR Sweep CST Cosine
tmux new -s lr_sweep_cst_cosine
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
for LR in 3e-6 1e-5 3e-5 1e-4; do
bash run_cdf_experiments.sh ldm-train-cst \
--data-root "$LDM_DATA" \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--logdir "logs/cdf/ldm/lr_sweep_cst_cosine/lr_${LR}" \
--max-steps 20000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$LR" \
--scale-lr false \
--gpus 0
done
```
```bash
# LDM LR Sweep CST Cosine Eval
tmux new -s lr_sweep_cst_cosine_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export TUNE_RATIOS=0.0,0.3,0.5,0.7,0.9,1.0
for LR in 3e-6 1e-5 3e-5 1e-4; do
bash run_cdf_experiments.sh ldm-eval-cst \
--checkpoint-dir "logs/cdf/ldm/lr_sweep_cst_cosine/lr_${LR}" \
--eval-ratios "$TUNE_RATIOS" \
--num-fid-samples 1000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir "outputs/cdf/ldm/lr_sweep_cst_cosine/lr_${LR}" \
--nproc-per-node 1 \
--per-proc-batch-size 8
done
```
```bash
# LDM FA Sweep CST Cosine
tmux new -s fa_sweep_cst_cosine
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
for FA in 0.03 0.1 0.3; do
bash run_cdf_experiments.sh ldm-train-cst-fa \
--data-root "$LDM_DATA" \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight "$FA" \
--fa-boundary-width 10 \
--logdir "logs/cdf/ldm/fa_sweep_cst_cosine/fa_${FA}" \
--max-steps 20000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
done
```
```bash
# LDM FA Sweep CST Cosine Eval
tmux new -s fa_sweep_cst_cosine_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export TUNE_RATIOS=0.0,0.3,0.5,0.7,0.9,1.0
export BEST_LR=1e-5
for FA in 0.03 0.1 0.3; do
bash run_cdf_experiments.sh ldm-eval-cst-fa \
--checkpoint-dir "logs/cdf/ldm/fa_sweep_cst_cosine/fa_${FA}" \
--eval-ratios "$TUNE_RATIOS" \
--num-fid-samples 1000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir "outputs/cdf/ldm/fa_sweep_cst_cosine/fa_${FA}" \
--nproc-per-node 1 \
--per-proc-batch-size 8
done
```
```bash
# LDM Schedule Ablation
tmux new -s schedule_ablation
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
bash run_cdf_experiments.sh ldm-train-cst-ablation \
--schedule cosine,cst_v1,cst_v2 \
--ratio-start 0.1 \
--ratio-end 0.9 \
--data-root "$LDM_DATA" \
--logdir logs/cdf/ldm/schedule_ablation \
--max-steps 20000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM Schedule Ablation Eval
tmux new -s schedule_ablation_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export TUNE_RATIOS=0.0,0.3,0.5,0.7,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-cst-ablation \
--checkpoint-dir logs/cdf/ldm/schedule_ablation \
--eval-ratios "$TUNE_RATIOS" \
--num-fid-samples 1000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/schedule_ablation \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
### 0.3 Main LDM Commands
```bash
# LDM NFT
tmux new -s nft
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-nft \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/nft \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM CST Cosine
tmux new -s cst_cosine
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
export BEST_SCHEDULE=cosine
bash run_cdf_experiments.sh ldm-train-cst \
--data-root "$LDM_DATA" \
--schedule "$BEST_SCHEDULE" \
--ratio-start 0.1 \
--ratio-end 0.9 \
--logdir logs/cdf/ldm/cst_cosine \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM CST Cosine Eval
tmux new -s cst_cosine_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-cst \
--checkpoint-dir logs/cdf/ldm/cst_cosine \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/cst_cosine \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM CST Cosine FA
tmux new -s cst_cosine_fa
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
export BEST_SCHEDULE=cosine
export BEST_FA=0.1
bash run_cdf_experiments.sh ldm-train-cst-fa \
--data-root "$LDM_DATA" \
--schedule "$BEST_SCHEDULE" \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight "$BEST_FA" \
--fa-boundary-width 10 \
--logdir logs/cdf/ldm/cst_cosine_fa \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM CST Cosine FA Eval
tmux new -s cst_cosine_fa_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-cst-fa \
--checkpoint-dir logs/cdf/ldm/cst_cosine_fa \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/cst_cosine_fa \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM FRFT
tmux new -s frft
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
bash run_cdf_experiments.sh ldm-train-frft \
--ratios 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9 \
--data-root "$LDM_DATA" \
--logdir logs/cdf/ldm/frft \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM FRFT Eval
tmux new -s frft_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-frft \
--checkpoint-dir logs/cdf/ldm/frft \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/frft \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM Senior Only
tmux new -s senior_only
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
bash run_cdf_experiments.sh ldm-train-senior-only \
--ratios 0.1,0.3,0.5,0.7,0.9 \
--data-root "$LDM_DATA" \
--logdir logs/cdf/ldm/senior_only \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM Senior Only Eval
tmux new -s senior_only_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-senior-only \
--checkpoint-dir logs/cdf/ldm/senior_only \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/senior_only \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# LDM FMGT
tmux new -s fmgt
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export LDM_DATA=$PREP/ldm
export BEST_LR=1e-5
bash run_cdf_experiments.sh ldm-train-fmgt \
--ratios 0.1,0.3,0.5,0.7,0.9 \
--data-root "$LDM_DATA" \
--logdir logs/cdf/ldm/fmgt \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--learning-rate "$BEST_LR" \
--scale-lr false \
--gpus 0
```
```bash
# LDM FMGT Eval
tmux new -s fmgt_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh ldm-eval-fmgt \
--checkpoint-dir logs/cdf/ldm/fmgt \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch "$REF" \
--ldm-s-path "$REPO/ldm/pretrained_models/ldm_s.ckpt" \
--ldm-path "$REPO/ldm/pretrained_models/ldm.ckpt" \
--ae-ckpt "$REPO/ldm/pretrained_models/vq-f8/model.ckpt" \
--output-dir outputs/cdf/ldm/fmgt \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
### 0.4 DiT Commands
```bash
# DiT NFT
tmux new -s dit_nft
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export MODEL_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/models
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export VAE_MODEL=$MODEL_ROOT/sd-vae-ft-ema
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh dit-eval-nft \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 1.5 \
--solver ddim \
--ref-batch "$REF" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--vae-model "$VAE_MODEL" \
--output-dir outputs/cdf/dit/dit_nft \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# DiT CST Cosine
tmux new -s dit_cst_cosine
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export DIT_DATA=$PREP/imagefolder/train
bash run_cdf_experiments.sh dit-train-cst \
--data-path "$DIT_DATA" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--results-dir logs/cdf/dit/dit_cst_cosine \
--epochs 1400 \
--global-batch-size 256 \
--learning-rate 1e-5 \
--nproc-per-node 1
```
```bash
# DiT CST Cosine Eval
tmux new -s dit_cst_cosine_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export MODEL_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/models
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export VAE_MODEL=$MODEL_ROOT/sd-vae-ft-ema
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh dit-eval-cst \
--checkpoint-dir logs/cdf/dit/dit_cst_cosine \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 1.5 \
--solver ddim \
--ref-batch "$REF" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--vae-model "$VAE_MODEL" \
--output-dir outputs/cdf/dit/dit_cst_cosine \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# DiT CST Cosine FA
tmux new -s dit_cst_cosine_fa
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export PREP=$DATA_ROOT/imagenet-1k/cdf_prepared
export DIT_DATA=$PREP/imagefolder/train
bash run_cdf_experiments.sh dit-train-cst-fa \
--data-path "$DIT_DATA" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight 0.1 \
--fa-boundary-width 10 \
--results-dir logs/cdf/dit/dit_cst_cosine_fa \
--epochs 1400 \
--global-batch-size 256 \
--learning-rate 1e-5 \
--nproc-per-node 1
```
```bash
# DiT CST Cosine FA Eval
tmux new -s dit_cst_cosine_fa_eval
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export MODEL_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/models
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export VAE_MODEL=$MODEL_ROOT/sd-vae-ft-ema
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh dit-eval-cst-fa \
--checkpoint-dir logs/cdf/dit/dit_cst_cosine_fa \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 1.5 \
--solver ddim \
--ref-batch "$REF" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--vae-model "$VAE_MODEL" \
--output-dir outputs/cdf/dit/dit_cst_cosine_fa \
--nproc-per-node 1 \
--per-proc-batch-size 8
```
```bash
# DiT Sampler Ablation
tmux new -s dit_sampler_ablation
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export MODEL_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/models
export REF=$REPO/assets/fid_stats/VIRTUAL_imagenet256_labeled.npz
export VAE_MODEL=$MODEL_ROOT/sd-vae-ft-ema
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
for solver in ddpm ddim dpm-solver++; do
bash run_cdf_experiments.sh dit-eval-cst \
--checkpoint-dir logs/cdf/dit/dit_cst_cosine \
--eval-ratios "$RATIOS" \
--num-fid-samples 5000 \
--num-sampling-steps 50 \
--cfg-scale 1.5 \
--solver "$solver" \
--ref-batch "$REF" \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--small-ckpt "$REPO/dit/pretrained_models/dit_s_256.pt" \
--large-ckpt "$REPO/dit/pretrained_models/dit_xl_256.pt" \
--vae-model "$VAE_MODEL" \
--output-dir "outputs/cdf/dit/dit_sampler_ablation_${solver}_50" \
--nproc-per-node 1 \
--per-proc-batch-size 8
done
```
### 0.5 SD / COCO Commands
The repository currently has COCO evaluation for SD v1.4 + BK-SDM Tiny, DeepCache, and ToMe. The training entry `sd-train-cst` exists for SDXL/SSD-1B in `sd/train_sdxl_tstitch.py`; it is not the SD v1.4 + BK-SDM Tiny Table 2 training setup.
```bash
# SD NFT
tmux new -s sd_nft
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export COCO_PROMPTS=$DATA_ROOT/coco/annotations/captions_val2014.json
export COCO_REF=$REPO/assets/fid_stats/coco_val2014_256.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh sd-eval-nft \
--pipeline sd \
--prompts "$COCO_PROMPTS" \
--ref-batch "$COCO_REF" \
--output-dir outputs/cdf/sd/nft_fixed \
--limit 5000 \
--ratios "$RATIOS" \
--height 256 \
--width 256 \
--steps 50 \
--guidance-scale 7.5
```
```bash
# SD DeepCache
tmux new -s sd_deepcache
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export COCO_PROMPTS=$DATA_ROOT/coco/annotations/captions_val2014.json
export COCO_REF=$REPO/assets/fid_stats/coco_val2014_256.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh sd-eval-deepcache \
--pipeline sd \
--prompts "$COCO_PROMPTS" \
--ref-batch "$COCO_REF" \
--output-dir outputs/cdf/sd/deepcache_i3_fixed \
--limit 5000 \
--ratios "$RATIOS" \
--height 256 \
--width 256 \
--steps 50 \
--guidance-scale 7.5 \
--deepcache-interval 3
```
```bash
# SD ToMe
tmux new -s sd_tome
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export REPO=$PWD
export DATA_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/datas
export COCO_PROMPTS=$DATA_ROOT/coco/annotations/captions_val2014.json
export COCO_REF=$REPO/assets/fid_stats/coco_val2014_256.npz
export RATIOS=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
bash run_cdf_experiments.sh sd-eval-cst \
--pipeline sd \
--prompts "$COCO_PROMPTS" \
--ref-batch "$COCO_REF" \
--output-dir outputs/cdf/sd/tome_05_fixed \
--limit 5000 \
--ratios "$RATIOS" \
--height 256 \
--width 256 \
--steps 50 \
--guidance-scale 7.5 \
--tome-ratio 0.5
```
```bash
# Optional SDXL CST Cosine Training
tmux new -s sdxl_cst_cosine
cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/T-Stitch
export MODEL_ROOT=/inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/models
bash run_cdf_experiments.sh sd-train-cst \
--pretrained_model_name_or_path "$MODEL_ROOT/stable-diffusion-xl-base-1.0" \
--small_model_name_or_path "$MODEL_ROOT/SSD-1B" \
--train_data_dir <image_text_train_dir> \
--metadata_file <metadata.jsonl> \
--output_dir logs/cdf/sd/sdxl_cst_cosine \
--resolution 1024 \
--ratio 0.9 \
--ratio_schedule cosine \
--ratio_start 0.1 \
--ratio_schedule_steps 100000 \
--train_mode junior \
--max_train_steps 100000 \
--train_batch_size 1 \
--learning_rate 1e-5
```
## 1. Notation
Let `T` be the full DDPM training horizon. In the main ImageNet experiments, `T = 1000`.
Let `r in [0, 1]` be the junior ratio, i.e. the fraction of denoising responsibility assigned to the junior model.
CDF uses the same coarse-to-fine inference direction as T-Stitch:
```text
t_zeta(r) = floor((1 - r) * T)
junior interval = {t | t_zeta(r) <= t < T}
senior interval = {t | 0 <= t < t_zeta(r)}
```
With `T = 1000`, `r = 0.1` gives `t_zeta = 900`, while `r = 0.9` gives `t_zeta = 100`.
This is the exact schedule expected by the paper text: training moves from short junior responsibility to long junior responsibility.
During inference, sampling starts from high-noise timesteps and moves toward low-noise timesteps.
The junior model handles early high-noise/coarse steps, and the senior model handles late low-noise/refinement steps.
## 2. CDF Inference
Given a junior denoiser `eps_j` and senior denoiser `eps_s`, CDF inference selects the model by timestep:
```text
eps_CDF(x_t, t, y; r) =
eps_j(x_t, t, y), if t >= t_zeta(r)
eps_s(x_t, t, y), if t < t_zeta(r)
```
Meaning:
- `r = 0.0`: pure senior model.
- `r = 1.0`: pure junior model.
- `0.1 <= r <= 0.9`: collaborative CDF/T-Stitch trajectory.
- NFT is exactly this inference rule without any CDF fine-tuning.
Default evaluation ratios:
```text
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
```
## 3. Training Objectives
### 3.1 Standard Diffusion Loss
All model families keep their native diffusion objective.
For LDM and DiT ImageNet experiments, this is epsilon prediction:
```text
x_t = sqrt(alpha_bar_t) * x_0 + sqrt(1 - alpha_bar_t) * eps
L_diff = E || eps - eps_theta(x_t, t, y) ||_2^2
```
For SD/SDXL, the same rule applies to the pipeline's native prediction type:
```text
target =
eps, if prediction_type == epsilon
v, if prediction_type == v_prediction
```
### 3.2 Fixed-Ratio Fine-Tuning
FRFT trains the junior model for one fixed ratio `r0`.
The senior model is frozen.
```text
t_zeta = floor((1 - r0) * T)
t ~ Uniform({t_zeta, ..., T - 1})
L_FRFT(r0) = E || eps - eps_j(x_t, t, y) ||_2^2
```
Meaning:
- One checkpoint is trained for one ratio.
- To support 9 ratios, train 9 junior checkpoints.
- This tests whether ratio-specific specialization generalizes.
### 3.3 Curricular Stitching Training
CST trains one junior model over a moving ratio distribution.
The senior model is frozen.
Let `s = global_step / total_steps`.
Let `r_min = 0.1`, `r_max = 0.9`.
```text
r(s) = r_min + (r_max - r_min) * g(s)
t_zeta(s) = floor((1 - r(s)) * T)
t ~ Uniform({t_zeta(s), ..., T - 1})
L_CST = E || eps - eps_j(x_t, t, y) ||_2^2
```
Curriculum variants:
```text
linear: g(s) = s
cosine: g(s) = (1 - cos(pi * s)) / 2
cst_v1: g(s) = sqrt(s) # large-ratio-biased, harder ratios appear earlier
cst_v2: g(s) = s^2 # small-ratio-biased, easier ratios last longer
staircase: g(s) = floor(K * s) / K, default K = 8
```
Meaning:
- CST turns ratio into a training variable.
- The final junior checkpoint should work for all evaluation ratios.
- `cst_v1` and `cst_v2` are the main ablation schedules.
### 3.4 Feature Alignment at the Stitching Boundary
Feature Alignment (FA) aligns junior and senior representations near the handoff boundary.
For a boundary width `delta`, sample:
```text
t_b ~ Uniform({max(0, t_zeta - delta), ..., min(T - 1, t_zeta + delta)})
```
Let `h_j^ell` and `h_s^ell` be hidden features from the same layer family `ell` in junior and senior.
Because junior and senior can have different channel widths, the alignment uses a channel-invariant feature signature:
```text
phi(h) = normalize(concat(mean_channel(h), std_channel(h)))
L_FA = E || phi(h_j^ell) - stopgrad(phi(h_s^ell)) ||_2^2
L_total = L_CST + lambda_FA * L_FA
```
Default alignment locations:
```text
LDM / SD: U-Net middle block and last decoder/up block signatures.
DiT: final transformer block token signature.
Fallback: denoiser output signature if a hook location is unavailable.
```
Meaning:
- FA does not train the senior model in the default CDF setting.
- FA only acts around the transition boundary, not across every timestep.
- The signature avoids requiring equal hidden dimensions across model scales.
### 3.5 Senior-Only Fine-Tuning
This baseline freezes the junior model and only trains the senior model on the senior interval.
```text
t_zeta = floor((1 - r0) * T)
t ~ Uniform({0, ..., t_zeta - 1})
L_senior_only(r0) = E || eps - eps_s(x_t, t, y) ||_2^2
```
Meaning:
- Tests whether improving the large/refinement part alone explains gains.
- This is not the default CDF deployment strategy.
### 3.6 Full Model Group Training
FMGT jointly trains junior and senior in their assigned intervals.
```text
t_zeta = floor((1 - r0) * T)
t_j ~ Uniform({t_zeta, ..., T - 1})
t_s ~ Uniform({0, ..., t_zeta - 1})
L_FMGT = E || eps - eps_j(x_tj, t_j, y) ||_2^2
+ E || eps - eps_s(x_ts, t_s, y) ||_2^2
```
Meaning:
- This is the high-cost joint-training baseline.
- It is less deployment-friendly because both checkpoints are updated.
## 4. Main LDM Experiments
Main setting:
```text
Dataset: ImageNet 256x256
Junior: LDM-S
Senior: LDM
Batch size: 64
Learning rate: 1e-5
DDPM training timesteps: T = 1000
Evaluation samples: 5000
Evaluation metrics: FID, IS, latency, speedup
Sampler: DDIM 100 steps unless specified
CFG scale: 3.0
Hardware report target: one RTX 4090 or the exact GPU used
```
Resume behavior:
- LDM training writes `checkpoints/last.ckpt` with model, optimizer, scheduler, epoch, global step, and callback state.
- Resume one interrupted run at a time. For fixed-ratio jobs, pass a single ratio matching the checkpoint directory.
- Resume checks the checkpoint optimizer LR against the current effective LR and fails by default on mismatch.
```bash
bash run_cdf_experiments.sh ldm-train-fmgt \
--ratios 0.1 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/fmgt \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5 \
--resume logs/cdf/ldm/fmgt/ratio-0.1/<run_name>/checkpoints/last.ckpt
```
Only use this when intentionally changing LR after resume:
```bash
--allow-lr-mismatch true
```
### 4.1 NFT / T-Stitch Baseline
No training. Directly evaluate the existing pretrained junior and senior checkpoints.
```bash
bash run_cdf_experiments.sh ldm-eval-nft \
--ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--num-fid-samples 5000 \
--num-sampling-steps 100 \
--cfg-scale 3.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/nft
```
Expected output:
```text
outputs/cdf/ldm/nft/samples/ratio-0.5.npz
outputs/cdf/ldm/nft/metrics.csv
```
### 4.2 FRFT Baseline
Train one junior checkpoint per ratio.
```bash
bash run_cdf_experiments.sh ldm-train-frft \
--ratios 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/frft \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate all FRFT checkpoints on all ratios to measure cross-ratio generalization:
```bash
bash run_cdf_experiments.sh ldm-eval-frft \
--checkpoint-dir logs/cdf/ldm/frft \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/frft
```
Expected output:
```text
outputs/cdf/ldm/frft/cross_ratio_metrics.csv
```
### 4.3 Senior-Only Baseline
Freeze junior, train senior on the senior interval for each fixed ratio.
```bash
bash run_cdf_experiments.sh ldm-train-senior-only \
--ratios 0.1,0.3,0.5,0.7,0.9 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/senior_only \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh ldm-eval-senior-only \
--checkpoint-dir logs/cdf/ldm/senior_only \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/senior_only
```
### 4.4 FMGT Baseline
Jointly train junior and senior.
```bash
bash run_cdf_experiments.sh ldm-train-fmgt \
--ratios 0.1,0.3,0.5,0.7,0.9 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/fmgt \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh ldm-eval-fmgt \
--checkpoint-dir logs/cdf/ldm/fmgt \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/fmgt
```
### 4.5 CST Main Run
Train one junior checkpoint with a progressive curriculum.
```bash
bash run_cdf_experiments.sh ldm-train-cst \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/cst_cosine \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate the one CST checkpoint at all ratios:
```bash
bash run_cdf_experiments.sh ldm-eval-cst \
--checkpoint logs/cdf/ldm/cst_cosine/checkpoints/last.ckpt \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/cst_cosine
```
### 4.6 CST Schedule Ablation
Run several curriculum schedules with all other settings fixed.
```bash
bash run_cdf_experiments.sh ldm-train-cst-ablation \
--schedule linear,cosine,cst_v1,cst_v2,staircase \
--ratio-start 0.1 \
--ratio-end 0.9 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/schedule_ablation \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh ldm-eval-cst-ablation \
--checkpoint-dir logs/cdf/ldm/schedule_ablation \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/schedule_ablation
```
### 4.7 CST + Feature Alignment
Train one junior checkpoint with curriculum and boundary feature alignment.
```bash
bash run_cdf_experiments.sh ldm-train-cst-fa \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight 0.1 \
--fa-boundary-width 10 \
--data-root <imagenet_train> \
--logdir logs/cdf/ldm/cst_cosine_fa \
--max-steps 200000 \
--batch-size 64 \
--num-workers 0 \
--scale-lr false \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh ldm-eval-cst-fa \
--checkpoint logs/cdf/ldm/cst_cosine_fa/checkpoints/last.ckpt \
--eval-ratios 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 \
--ref-batch <adm_imagenet_ref.npz> \
--output-dir outputs/cdf/ldm/cst_cosine_fa
```
## 5. DiT Experiments
Purpose:
- Provide quantitative evidence beyond LDM.
- Explicitly connect NFT to T-Stitch under the same DiT samplers.
- Report FID, IS, latency, and speedup for all ratios.
Default DiT setting:
```text
Dataset: ImageNet 256x256
Junior: DiT-S/2
Senior: DiT-XL/2
Optional medium: DiT-B/2
Sampler: DDIM 100, plus DDPM and DPM-Solver++ ablations
CFG scale: 1.5
Evaluation samples: 5000
```
### 5.1 DiT NFT / T-Stitch
```bash
bash run_cdf_experiments.sh dit-eval-nft \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--solver ddim \
--num-sampling-steps 100 \
--cfg-scale 1.5 \
--num-fid-samples 5000 \
--ref-batch <adm_imagenet_ref.npz> \
--vae-model <local_sd_vae_ft_ema_or_hf_id> \
--output-dir outputs/cdf/dit/nft_ddim100
```
### 5.2 DiT FRFT
```bash
bash run_cdf_experiments.sh dit-train-frft \
--ratios 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9 \
--data-path <imagenet_train> \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--logdir logs/cdf/dit/frft \
--epochs 1400 \
--global-batch-size 256 \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh dit-eval-frft \
--checkpoint-dir logs/cdf/dit/frft \
--solver ddim \
--num-sampling-steps 100 \
--ref-batch <adm_imagenet_ref.npz> \
--vae-model <local_sd_vae_ft_ema_or_hf_id> \
--output-dir outputs/cdf/dit/frft
```
### 5.3 DiT CST and CST + FA
```bash
bash run_cdf_experiments.sh dit-train-cst \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--data-path <imagenet_train> \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--logdir logs/cdf/dit/cst_cosine \
--epochs 1400 \
--global-batch-size 256 \
--learning-rate 1e-5
bash run_cdf_experiments.sh dit-train-cst-fa \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight 0.1 \
--fa-boundary-width 10 \
--data-path <imagenet_train> \
--small-model DiT-S/2 \
--large-model DiT-XL/2 \
--logdir logs/cdf/dit/cst_cosine_fa \
--epochs 1400 \
--global-batch-size 256 \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh dit-eval-cst \
--checkpoint logs/cdf/dit/cst_cosine/checkpoints/last.pt \
--solver ddim \
--num-sampling-steps 100 \
--ref-batch <adm_imagenet_ref.npz> \
--vae-model <local_sd_vae_ft_ema_or_hf_id> \
--output-dir outputs/cdf/dit/cst_cosine
```
### 5.4 DiT Sampler Ablation
```bash
for solver in ddpm ddim dpm-solver++; do
bash run_cdf_experiments.sh dit-eval-cst \
--checkpoint logs/cdf/dit/cst_cosine/checkpoints/last.pt \
--solver "$solver" \
--num-sampling-steps 50 \
--ref-batch <adm_imagenet_ref.npz> \
--vae-model <local_sd_vae_ft_ema_or_hf_id> \
--output-dir outputs/cdf/dit/cst_cosine_${solver}_50
done
```
## 6. Stable Diffusion / Text-to-Image Experiments
Purpose:
- Address general text-to-image prompts beyond ImageNet.
- Report FID, IS, and CLIP score on MS-COCO.
- Test orthogonality with DeepCache.
Default SD setting:
```text
Dataset/prompts: MS-COCO validation captions
Junior: BK-SDM Tiny
Senior: SD v1.4 or stylized SD
Sampler: PNDM 50 steps
Guidance scale: 7.5
Resolution: 256x256 for Table 2-style metrics
Evaluation samples: 5000
```
### 6.1 SD NFT / T-Stitch on COCO
```bash
bash run_cdf_experiments.sh sd-eval-nft \
--prompts <captions_val2014.json> \
--ref-batch <coco_ref_batch.npz> \
--output-dir outputs/cdf/sd/nft \
--limit 5000
```
### 6.2 SD CST / CST + FA
```bash
bash run_cdf_experiments.sh sd-train-cst \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--train-data-dir <image_text_train_dir> \
--metadata-file <metadata.jsonl> \
--output-dir logs/cdf/sd/cst_cosine \
--max-train-steps 100000 \
--train-batch-size 1 \
--learning-rate 1e-5
bash run_cdf_experiments.sh sd-train-cst-fa \
--schedule cosine \
--ratio-start 0.1 \
--ratio-end 0.9 \
--fa-weight 0.1 \
--fa-boundary-width 2 \
--train-data-dir <image_text_train_dir> \
--metadata-file <metadata.jsonl> \
--output-dir logs/cdf/sd/cst_cosine_fa \
--max-train-steps 100000 \
--train-batch-size 1 \
--learning-rate 1e-5
```
Evaluate:
```bash
bash run_cdf_experiments.sh sd-eval-cst \
--checkpoint logs/cdf/sd/cst_cosine \
--prompts <captions_val2014.json> \
--ref-batch <coco_ref_batch.npz> \
--output-dir outputs/cdf/sd/cst_cosine \
--limit 5000
```
### 6.3 SD + DeepCache Orthogonal Experiment
Compare:
```text
SD NFT
SD NFT + DeepCache
SD CDF/CST
SD CDF/CST + DeepCache
```
Run:
```bash
bash run_cdf_experiments.sh sd-eval-deepcache \
--checkpoint logs/cdf/sd/cst_cosine \
--prompts <captions_val2014.json> \
--ref-batch <coco_ref_batch.npz> \
--deepcache-interval 3 \
--output-dir outputs/cdf/sd/cst_cosine_deepcache \
--limit 5000
```
Metrics:
```text
FID, IS, CLIP score, latency, speedup
```
## 7. Data Products for Paper Figures
The final implementation should export the following CSV files.
```text
Figure 1: outputs/cdf/ldm/main_tradeoff.csv
columns: method, ratio, fid, is, latency_sec, speedup, checkpoint
Figure 3: outputs/cdf/training_cost.csv
columns: method, num_checkpoints, trainable_params, gpu_days, supported_ratios
Figure 4: outputs/cdf/ldm/cross_ratio_generalization.csv
columns: train_method, train_ratio, eval_ratio, fid, is
Figure 5: outputs/cdf/ldm/cst_convergence.csv
columns: epoch_or_step, ratio, fid, is
Figure 6: outputs/cdf/ldm/schedule_fa_ablation.csv
columns: method, schedule, fa_weight, ratio, fid, is, latency_sec
Figure 7: outputs/cdf/efficiency_by_arch_sampler.csv
columns: arch, sampler, num_steps, ratio, latency_sec, speedup
Figure 8: outputs/cdf/sd/deepcache_compatibility.csv
columns: method, ratio, fid, kid, is, clip_score, latency_sec
```
## 8. Implementation Checklist
The current repository already has partial T-Stitch training and sampling.
The following items must be implemented or verified before the commands above are considered runnable end-to-end:
- Add explicit `train_mode` values: `junior`, `senior`, `joint`.
- Add exact schedule functions: `fixed`, `linear`, `cosine`, `cst_v1`, `cst_v2`, `staircase`.
- Sample training timesteps from the correct interval for each training mode.
- Add boundary Feature Alignment with documented layer hooks and output fallback.
- Add LDM runner commands for NFT, FRFT, senior-only, FMGT, CST, CST+FA.
- Add all-ratio evaluation that emits `.npz` samples and `metrics.csv`.
- Align DiT training flags with the same CDF names and schedules.
- Align SD/SDXL training flags with the same CDF names and schedules.
- Add COCO prompt generation, CLIP score, FID/IS aggregation, and DeepCache toggles to the CDF runner.