"""Phase-2 RAEv2 ISIC configs: extend the FM ladder under RAEv2. dinov3l-k7 : DINOv3-L multi-layer sum (7 layers) — completes K1 same DiT as dinov3l-k1. Same budget (gb256/accum4, 200ep) = fair vs Phase-1. """ import yaml, os REPO = "/data/temp/qinshengqian/c3/Code/RAEv2" DATA = "/data/temp/qinshengqian/c3/data/isic-arrow-256" NUM_CLASSES = 8 ENCODERS = { "dinov3l-k7": "dinov3mls-vit-l16[layers=11.13.15.17.19.21.23]", "mael": "mae-vit-l", "dinov2l": "dinov2-vit-l", } def dataset_block(): return {"target": "imagenet", "type": "hf", "data_dir": DATA, "split": "train", "condition_type": "label", "shared_tmpdir": "~/tmp"} for tag, enc in ENCODERS.items(): s1dir = f"results/stage1/ISIC_{tag}" # ---- stage1 ---- s1 = { "stage_1": {"target": "stage1.RAE", "params": { "encoder_name": enc, "resolution": 256, "decoder_config_path": "configs/decoder/ViTXL", "noise_tau": 0.8}}, "dataset": dataset_block(), "training": {"epochs": 40, "ema_decay": 0.9978, "global_batch_size": 64, "num_workers": 4, "clip_grad": 0.0, "log_interval": 50, "checkpoint_interval": 5, "sample_every": 100000, "image_size": 256, "optimizer": {"lr": 2.0e-4, "betas": [0.9, 0.95], "weight_decay": 0.0}, "scheduler": {"type": "cosine", "warmup_epochs": 1, "decay_end_epoch": 40, "base_lr": 2.0e-4, "final_lr": 2.0e-5, "warmup_from_zero": True}}, "eval": {"eval_interval": 100000, "eval_model": False, "eval_dir": "results/stage1/eval", "datasets": {}}, "gan": {"arch": {"dino_ckpt_path": REPO + "/pretrained_models/encoders/dino/dino_vit_small_patch8_224.pth", "ks": 9, "norm_type": "bn", "using_spec_norm": True, "recipe": "S_8"}, "optimizer": {"lr": 2.0e-4, "betas": [0.9, 0.95], "weight_decay": 0.0}, "scheduler": {"type": "cosine", "warmup_epochs": 1, "decay_end_epoch": 40, "base_lr": 2.0e-4, "final_lr": 2.0e-5, "warmup_from_zero": True}, "augment": {"prob": 1.0, "cutout": 0.0}, "loss": {"disc_loss": "hinge", "gen_loss": "vanilla", "disc_weight": 0.75, "perceptual_weight": 1.0, "disc_start": 20, "disc_upd_start": 15, "lpips_start": 0, "max_d_weight": 10000.0, "disc_updates": 1}}, } os.makedirs(f"{REPO}/configs/stage1/training/ISIC", exist_ok=True) yaml.safe_dump(s1, open(f"{REPO}/configs/stage1/training/ISIC/{tag}.yaml", "w"), sort_keys=False) # ---- stage2 ---- s2 = { "stage_1": {"target": "stage1.RAE", "params": { "encoder_name": enc, "resolution": 256, "decoder_config_path": "configs/decoder/ViTXL", "pretrained_decoder_path": f"{s1dir}/decoder_ema.pt", "noise_tau": 0.0, "normalization_stat_path": f"{s1dir}/stats.pt"}}, "stage_2": {"target": "stage2.models.DDT.DiTwDDTHeadIG", "params": { "input_size": 16, "patch_size": [1, 1], "in_channels": 1024, "hidden_size": [1440, 2048], "depth": [28, 2], "num_heads": [20, 16], "mlp_ratio": 4.0, "base_model_depth": 8}}, "conditioning": {"type": "label", "cfg_dropout_prob": 0.1, "arch": {"num_t_tokens": 4, "num_c_tokens": 8}}, "transport": {"prediction": "x", "time_dist_type": "logit-normal_0_1"}, "sampler": {"num_steps": 50}, "guidance": {"cfg": {"scale": 1.0, "t_min": 0.0, "t_max": 1.0}}, "dataset": dataset_block(), "training": {"epochs": 200, "global_batch_size": 256, "grad_accum_steps": 4, "ema_decay": 0.9995, "num_workers": 4, "log_interval": 50, "checkpoint_interval": 10, "sample_every": 100000, "clip_grad": 1.0, "global_seed": 42, "optimizer": {"type": "gmuon", "lr": 0.0002, "momentum": 0.95, "nesterov": True, "ns_coefficients_preset": "POLAR_EXPRESS_COEFFICIENTS", "ns_use_kernels": False, "weight_decay": 0.0}, "scheduler": {"type": "linear", "warmup_epochs": 10, "decay_end_epoch": 150, "base_lr": 0.0002, "final_lr": 2.0e-05, "warmup_from_zero": False}, "image_size": 256}, "eval": {"eval_interval": 100000, "eval_model": False, "eval_dir": "results/stage2/eval", "datasets": {}}, "misc": {"latent_size": [1024, 16, 16], "num_classes": NUM_CLASSES, "time_dist_shift_dim": 1024 * 16 * 16, "time_dist_shift_base": 4096}, } os.makedirs(f"{REPO}/configs/stage2/training/ISIC", exist_ok=True) yaml.safe_dump(s2, open(f"{REPO}/configs/stage2/training/ISIC/{tag}.yaml", "w"), sort_keys=False) print("wrote phase2 configs:", tag, "->", enc) print("PHASE2_CONFIGS_DONE")