# Experiment Command Index Run commands from the repository root unless a block explicitly changes directory. Large experiments require the corresponding pretrained checkpoints, datasets, reference `.npz` batches, and GPUs. ## Setup ```bash bash run_examples.sh install-basic ``` ## Interactive and Qualitative SD Experiments | Experiment | Command | |---|---| | Gradio demo for SD 1.x, SDXL, and LCM | `bash run_examples.sh gradio` | | Stable Diffusion 1.x / stylized SD T-Stitch sweep | `bash run_examples.sh sd-demo` | | SDXL / SSD-1B T-Stitch sweep | `bash run_examples.sh sdxl-demo` | | SDXL + ControlNet Canny demo | `bash run_examples.sh sdxl-canny` | | SDXL + ControlNet Canny with custom image | `bash run_examples.sh sdxl-canny -- --image /path/to/image.jpg` | | SDXL + ControlNet Depth demo | `bash run_examples.sh sdxl-depth` | | SDXL + ControlNet Depth with custom image | `bash run_examples.sh sdxl-depth -- --image /path/to/image.jpg` | | SDXL + ControlNet OpenPose demo | `bash run_examples.sh sdxl-pose` | | SDXL + LCM-LoRA T-Stitch demo | `bash run_examples.sh sdxl-lcm` | ## DiT Experiments Figure 5, DiT two-model combinations: ```bash # DiT-XL/S bash run_examples.sh dit-fid -- --small-model DiT-S/2 --large-model DiT-XL/2 # DiT-XL/B bash run_examples.sh dit-fid-xl-b # DiT-B/S bash run_examples.sh dit-fid-b-s ``` Figure 6, DiT-S/B/XL three-model Pareto sweep: ```bash bash run_examples.sh dit-fid-three # Run a single allocation instead of the full 0.1-grid sweep: bash run_examples.sh dit-fid-three -- --three-fractions 0.5 0.3 0.2 ``` Figure 8, sampler ablation: ```bash # DDPM bash run_examples.sh dit-fid -- --solver ddpm --num-sampling-steps 50 # DDIM bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 50 # DPM-Solver++ bash run_examples.sh dit-fid-dpm -- --num-sampling-steps 50 --dpm-solver-order 2 ``` Figure 9, sampling-step ablation: ```bash bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 10 bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 20 bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 50 bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 100 bash run_examples.sh dit-fid -- --solver ddim --num-sampling-steps 250 ``` DiT qualitative sampling: ```bash bash run_examples.sh dit-sample bash run_examples.sh dit-sample-all ``` DiT frequency analysis: ```bash cd dit python visualize_sampling_freq.py \ --model DiT-XL/2 \ --ckpt pretrained_models/dit_xl_256.pt \ --num-sampling-steps 10 \ --cfg-scale 4.0 ``` Evaluate DiT ImageNet sample batches: ```bash python dit/evaluator.py /path/to/adm_ref_batch.npz /path/to/generated_samples.npz ``` Train / finetune DiT T-Stitch variant: ```bash bash run_examples.sh dit-train -- \ --data-path /path/to/imagenet_train \ --ratio 0.3 \ --ratio-schedule fixed \ --image-size 256 \ --global-batch-size 256 ``` ## LDM / U-Net Experiments Table 1, LDM-S / LDM ImageNet FID sweep: ```bash bash run_examples.sh ldm-fid # Single custom ratio: cd ldm python -m torch.distributed.launch --nproc_per_node=8 --master_port 1236 --use_env \ scripts/sample_imagenet_ddp_t_stitch.py \ --num-fid-samples 5000 \ --num-sampling-steps 100 \ --cfg-scale 3.0 \ --ratio 0.5 ``` LDM qualitative sampling: ```bash bash run_examples.sh ldm-sample bash run_examples.sh ldm-sample-all ``` Evaluate LDM ImageNet sample batches: ```bash python ldm/evaluator.py /path/to/adm_ref_batch.npz /path/to/generated_samples.npz ``` Train LDM T-Stitch variant: ```bash bash run_examples.sh ldm-train ``` ## Stable Diffusion Quantitative Experiments Table 2, SD v1.4 / BK-SDM Tiny on MS-COCO: ```bash # Generate images for all ratios from COCO captions. bash run_examples.sh sd-coco-generate -- \ --prompts /path/to/captions_val2014.json \ --output-dir outputs/sd_coco \ --limit 5000 # Pack one ratio folder into an ADM-style npz for FID / IS. bash run_examples.sh sd-pack -- \ --image-dir outputs/sd_coco/ratio-0.3 \ --output outputs/sd_coco/ratio-0.3.npz # Compute CLIP score for one ratio. bash run_examples.sh clip-score -- \ --metadata outputs/sd_coco/ratio-0.3/metadata.jsonl \ --output outputs/sd_coco/ratio-0.3-clip.json # Compute FID / IS with a matching COCO reference batch. python dit/evaluator.py /path/to/coco_ref_batch.npz outputs/sd_coco/ratio-0.3.npz ``` Appendix DeepCache and ToMe combinations: ```bash # Requires external DeepCache package. python sd/generate_tstitch_prompts.py \ --pipeline sd \ --prompts /path/to/captions_val2014.json \ --output-dir outputs/sd_deepcache \ --deepcache-interval 3 \ --limit 5000 # Requires external tomesd package. python sd/generate_tstitch_prompts.py \ --pipeline sd \ --prompts /path/to/captions_val2014.json \ --output-dir outputs/sd_tome \ --tome-ratio 0.5 \ --limit 5000 ``` ## SDXL / ControlNet / LCM Quantitative Sweeps SDXL / SSD-1B prompt sweep: ```bash bash run_examples.sh sdxl-prompts -- \ --prompts /path/to/prompts.txt \ --output-dir outputs/sdxl_prompts ``` SDXL + ControlNet sweeps: ```bash bash run_examples.sh sdxl-controlnet -- \ --control canny \ --prompts /path/to/prompts.txt \ --source-image /path/to/control_source.jpg \ --output-dir outputs/controlnet_canny bash run_examples.sh sdxl-controlnet -- \ --control depth \ --prompts /path/to/prompts.txt \ --source-image /path/to/control_source.jpg \ --output-dir outputs/controlnet_depth ``` LCM-SDXL / LCM-SSD-1B sweep: ```bash python sd/generate_tstitch_prompts.py \ --pipeline sdxl-lcm \ --prompts /path/to/prompts.txt \ --output-dir outputs/sdxl_lcm \ --steps 4 \ --guidance-scale 0 ``` ## SDXL Training ```bash bash run_examples.sh train-sdxl -- \ --train_data_dir /path/to/images \ --metadata_file /path/to/metadata.jsonl \ --pretrained_model_name_or_path stabilityai/stable-diffusion-xl-base-1.0 \ --small_model_name_or_path segmind/SSD-1B \ --ratio 0.3 \ --ratio_schedule fixed \ --train_batch_size 1 \ --max_train_steps 10000 \ --learning_rate 1e-5 ``` ## External Baselines The paper's SN-Netv2 model-stitching baseline and DiT + U-ViT experiment still require external repositories, model definitions, and checkpoints not vendored here. Use this repository to generate the T-Stitch side of the comparison, then run those baselines in their own codebases and evaluate the resulting `.npz` files with the same evaluator commands above.