Spaces:
Running on Zero
Running on Zero
File size: 14,726 Bytes
f7dc16a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | import argparse
from .config import resolve_args
def parse_args():
parser = argparse.ArgumentParser(description="Train Multics")
parser.add_argument(
"--task",
type=str,
default="train",
required=False,
choices=["train"],
help="Train the hierarchical model.",
)
parser.add_argument(
"--dataset_path",
type=str,
default=None,
required=True,
help="The path of the Dataset.",
)
parser.add_argument(
"--output_path", type=str, default="./", help="Path to save the model."
)
parser.add_argument(
"--ckpt_local_dir",
type=str,
default=None,
help="If set, torch.save writes checkpoints here instead of the Lightning checkpoint directory.",
)
parser.add_argument(
"--run_version",
type=str,
default=None,
help="Lightning log directory name, for example version_76. If omitted, the next local version_N under the output path is used.",
)
parser.add_argument(
"--text_encoder_path", type=str, default=None, help="Path of text encoder."
)
parser.add_argument(
"--image_encoder_path", type=str, default=None, help="Path of image encoder."
)
parser.add_argument("--vae_path", type=str, default=None, help="Path of VAE.")
parser.add_argument("--dit_path", type=str, default=None, help="Path of DiT.")
parser.add_argument(
"--steps_per_epoch", type=int, default=500, help="Number of steps per epoch."
)
parser.add_argument(
"--dataloader_num_workers",
type=int,
default=4,
help="Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process.",
)
parser.add_argument(
"--learning_rate", type=float, default=1e-05, help="Learning rate."
)
parser.add_argument(
"--accumulate_grad_batches",
type=int,
default=1,
help="The number of batches in gradient accumulation.",
)
parser.add_argument(
"--gradient_clip_val",
type=float,
default=1.0,
help="Global gradient-norm clip. 0 disables clipping.",
)
parser.add_argument("--max_epochs", type=int, default=1, help="Number of epochs.")
parser.add_argument(
"--max_steps",
type=int,
default=-1,
help="Maximum optimizer steps for this run; -1 disables the step limit.",
)
parser.add_argument(
"--training_strategy",
type=str,
default="deepspeed_stage_1",
choices=["auto", "deepspeed_stage_1", "deepspeed_stage_2", "deepspeed_stage_3"],
help="Training strategy",
)
parser.add_argument(
"--use_gradient_checkpointing",
default=False,
action="store_true",
help="Whether to use gradient checkpointing.",
)
parser.add_argument(
"--use_gradient_checkpointing_offload",
default=False,
action="store_true",
help="Whether to use gradient checkpointing offload.",
)
parser.add_argument(
"--use_swanlab",
default=False,
action="store_true",
help="Whether to use SwanLab logger.",
)
parser.add_argument(
"--swanlab_mode", default=None, help="SwanLab mode (cloud or local)."
)
parser.add_argument(
"--val_infer",
action="store_true",
help="Run causal inference on the first --val_num_samples training rows and log the generated and reference videos.",
)
parser.add_argument(
"--val_num_samples", type=int, default=4, help="Number of leading training samples used for validation."
)
parser.add_argument(
"--val_every_n_steps",
type=int,
default=500,
help="Run validation every this many training batches.",
)
parser.add_argument(
"--val_num_inference_steps",
type=int,
default=50,
help="Denoising steps used during validation inference.",
)
parser.add_argument(
"--val_causal_num_frames",
type=int,
default=None,
help="Frames to generate during validation. Defaults to target_rgb_frames.",
)
parser.add_argument(
"--val_output_dir",
type=str,
default="outputs/validation",
help="Directory for validation MP4 files.",
)
parser.add_argument(
"--val_grid_fps", type=int, default=15, help="Frames per second for saved validation videos."
)
parser.add_argument("--metadata_file_name", type=str, default="metadata.csv")
parser.add_argument("--resume_ckpt_path", type=str, default=None)
parser.add_argument(
"--train_step_offset",
type=int,
default=None,
help="Completed optimizer updates before this run. Default: infer from the resume checkpoint's parent hparams.yaml and stepN filename.",
)
parser.add_argument(
"--num_players",
type=int,
default=4,
help="Number of player streams in the precomputed dataset.",
)
parser.add_argument(
"--use_simplex_rope",
action="store_true",
default=True,
help="Use simplex 4D RoPE instead of learned player embeddings.",
)
parser.add_argument(
"--simplex_pool_size",
type=int,
default=4,
help="Simplex vertex-pool size. Training draws num_players vertices from this pool.",
)
parser.add_argument(
"--simplex_gamma", type=float, default=1.0, help="Rotation strength of the simplex player axis."
)
parser.add_argument(
"--simplex_train_permute",
action="store_true",
help="Randomly permute player slots at each step, together with the sampled vertices.",
)
parser.add_argument(
"--no_simplex_train_permute",
action="store_false",
dest="simplex_train_permute",
help="Do not permute player streams. Vertex sampling stays on its own switch.",
)
parser.add_argument(
"--simplex_train_sample_vertex_ids",
action="store_true",
help="Sample P vertex IDs from the simplex pool without replacement, without reordering player streams.",
)
parser.add_argument(
"--training_stage",
type=str,
default="stage2",
choices=["stage2"],
help=argparse.SUPPRESS,
)
parser.add_argument(
"--loss_type",
type=str,
default="diffusion_forcing",
choices=["diffusion_forcing"],
help="Training objective. Fixed to diffusion forcing.",
)
parser.add_argument(
"--attention_mode",
type=str,
default="hier_hub",
choices=["hier_hub"],
help="Attention layout. Fixed to hierarchical hubs.",
)
parser.add_argument("--local_attn_size", type=int, default=7)
parser.add_argument("--local_attn_size_after", type=int, default=21)
parser.add_argument("--local_attn_switch_step", type=int, default=10000)
parser.add_argument("--num_frame_per_block", type=int, default=7)
parser.add_argument(
"--num_local_hub_tokens",
type=int,
default=5,
help="hier_hub: local hub tokens K_L.",
)
parser.add_argument(
"--num_global_hub_tokens",
type=int,
default=6,
help="hier_hub: global hub tokens K_G.",
)
parser.add_argument(
"--hier_no_local_hub",
action="store_true",
help="Ablation: remove local hubs and connect every player directly to the global hub.",
)
parser.add_argument(
"--hier_local_hub_mode",
type=str,
default="shared",
choices=["shared", "per_group"],
help="hier_hub local seed parameterization: shared uses [K_L,D] for all dynamic group slots; per_group learns independent [N,K_L,D] seeds.",
)
parser.add_argument(
"--hier_direct_schedule",
type=str,
default="none",
choices=["none", "uniform", "explicit"],
help="hier_hub: selected layers with same-block same-group direct player attention.",
)
parser.add_argument(
"--hier_direct_frac",
type=float,
default=0.0,
help="hier_hub uniform schedule only: fraction in [0,1] of DiT layers that enable direct same-group, same-latent-block player-player attention. Ignored when --hier_direct_schedule is none or explicit; same-player self-history is always controlled by the base mask.",
)
parser.add_argument(
"--hier_direct_layers",
type=str,
default=None,
help="hier_hub explicit zero-based layer ids, e.g. 2,5,8,11.",
)
parser.add_argument("--group_path_column", type=str, default="group_path")
parser.add_argument(
"--hier_group_format",
type=str,
default="labels",
choices=["labels", "membership"],
help="hier_hub grouping tensor format. labels: partition ids in [0,N), no player↔global (default, bit-identical to previous runs). membership: cover with membership[T,N,P] + global_only[T,P].",
)
parser.add_argument(
"--hier_group_mode",
type=str,
default="csv",
choices=["csv", "random_static", "random_block"],
help="hier_hub grouping: CSV labels, one fixed random permutation, or one permutation per latent block.",
)
parser.add_argument("--hier_group_seed", type=int, default=0)
parser.add_argument(
"--hier_random_preserve_sizes",
type=int,
default=1,
choices=[0, 1],
help="Random grouping: preserve each source block's group-size histogram when set to 1.",
)
parser.add_argument(
"--group_label_player_ids",
type=str,
default=None,
help="1-based original player ids for group label columns; default 1..P.",
)
parser.add_argument(
"--attn_impl",
type=str,
default="sdpa",
choices=["sdpa", "flex", "hier_tiled_ste"],
help="Self-attention kernel: sdpa, flex, or hier_tiled_ste. hier_tiled_ste uses tiled forward and Flex backward, and requires hier_hub.",
)
parser.add_argument(
"--use_camera_pose",
action="store_true",
help="Add relative camera conditioning to self-attention Q and K. The CSV must contain precomputed camera_pose_path* or camera12_path*.",
)
parser.add_argument(
"--camera_dim",
type=int,
default=12,
help="Camera-pose embedding size. The default is the 12-D relative camera.",
)
parser.add_argument(
"--camera_dropout_p",
type=float,
default=0.1,
help="Shared dropout on the camera Q/K adapter. Used only while training. Default 0.1.",
)
parser.add_argument(
"--unfreeze_self_attn",
action="store_true",
help="Train the self-attention weights. On by default.",
)
parser.add_argument(
"--causal_forcing_training",
action="store_true",
default=False,
help="Causal-forcing block training. A supervised block is chosen at random; earlier blocks are teacher-forced from clean latents. Inference context noise should stay at 0 when this flag is active.",
)
parser.add_argument(
"--clean_prefix_prob",
type=float,
default=0.0,
help="Probability of training on a clean prefix and supervising only the current block. 0 disables it. A typical range is 0.5 to 0.8.",
)
parser.add_argument(
"--clean_prefix_context_noise",
type=int,
default=0,
help="Context timestep used for clean-prefix blocks. Keep it equal to the inference context noise. 0 means fully clean.",
)
parser.add_argument(
"--generated_history_prob",
type=float,
default=0.0,
help="Fraction of batches that train on generated history: a ground-truth prefix, one to three generated blocks, and loss only on the next ground-truth block. 0 disables it.",
)
parser.add_argument(
"--df_per_frame_noise",
action="store_true",
help="Sample an independent noise level for each latent frame instead of sharing one level across a block.",
)
parser.add_argument(
"--target_rgb_frames",
type=int,
default=81,
help="RGB frames in the supervised clip. Must be 4n+1. Default 81. The diffusion loss and action slices use this window.",
)
parser.add_argument(
"--blank_prompt_emb_path",
type=str,
default=None,
help="Cached embedding of the empty text prompt. Defaults to asset/blank_string_prompt_emb.pth. If the file is missing, training encodes the empty string and writes the cache.",
)
parser.add_argument(
"--text_prompt_dropout_p",
type=float,
default=0.0,
help="Probability of replacing a sample's text embedding with the empty-prompt embedding. 0 disables it. The bundled training configs use 0.1.",
)
parser.add_argument(
"--vae_latent_channels",
type=int,
default=48,
help="VAE latent channels. 48 for the Wan 5B VAE.",
)
parser.add_argument(
"--first_frame_dropout_p",
type=float,
default=0.0,
help="Probability of dropping the clean first frame during training and applying loss to every frame. Inference still uses a clean first frame. 0 disables it.",
)
parser.add_argument(
"--first_frame_noise_p",
type=float,
default=0.0,
help="Probability of noising the first latent frame of the anchor. 0 disables it.",
)
parser.add_argument(
"--first_frame_noise_corrupt_ratio",
type=float,
default=1 / 3,
help="Upper bound of the uniform noise scale applied to the anchor's first frame. Default 1/3.",
)
parser.add_argument(
"--first_frame_noise_min_seg",
type=int,
default=1,
help="Apply anchor corruption only at or after this segment index.",
)
parser.add_argument(
"--perf_log_every_n_steps",
type=int,
default=100,
help="Print averaged timing and the bottleneck every N steps.",
)
parser.add_argument(
"--no_perf_timing",
action="store_true",
help="Disable step timing. Skips the extra CUDA sync and the perf logs.",
)
args = resolve_args(parser, "train")
if args.hier_group_format == "membership" and args.attn_impl == "hier_tiled_ste":
raise ValueError(
"hier_group_format=membership is not supported with --attn_impl hier_tiled_ste; use flex or sdpa"
)
return args
|