diff --git a/docs/source/inference/cli.md b/docs/source/inference/cli.md index 7570007d4..845d1bec0 100644 --- a/docs/source/inference/cli.md +++ b/docs/source/inference/cli.md @@ -27,7 +27,7 @@ fastvideo generate --help ### Hardware Configuration - `--num-gpus {NUM_GPUS}`: Number of GPUs to use -- `--tp-size {TP_SIZE}`: Tensor parallelism size (Typically should match the number of GPUs) +- `--tp-size {TP_SIZE}`: Tensor parallelism size (only for the encoder, should not be larger than 1 if text encoder offload is enabled, as layerwise offload + prefetch is faster) - `--sp-size {SP_SIZE}`: Sequence parallelism size (Typically should match the number of GPUs) #### Video Configuration @@ -68,7 +68,7 @@ Example configuration file (config.json): "output_path": "outputs/", "num_gpus": 2, "sp_size": 2, - "tp_size": 2, + "tp_size": 1, "num_frames": 45, "height": 720, "width": 1280, @@ -102,7 +102,7 @@ prompt: "A beautiful woman in a red dress walking down a street" output_path: "outputs/" num_gpus: 2 sp_size: 2 -tp_size: 2 +tp_size: 1 num_frames: 45 height: 720 width: 1280 diff --git a/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.sh b/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.sh index 299c132d4..459469299 100644 --- a/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.sh +++ b/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.sh @@ -30,7 +30,7 @@ training_args=( parallel_args=( --num_gpus $NUM_GPUS --sp_size 8 - --tp_size 8 + --tp_size 1 --hsdp_replicate_dim 1 --hsdp_shard_dim 8 ) diff --git a/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.slurm b/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.slurm index 7cce5925f..e78690330 100644 --- a/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.slurm +++ b/examples/training/finetune/wan_i2v_14b_480p/crush_smol/finetune_i2v.slurm @@ -66,7 +66,7 @@ training_args=( parallel_args=( --num_gpus $NUM_GPUS --sp_size $NUM_GPUS - --tp_size $NUM_GPUS + --tp_size 1 --hsdp_replicate_dim $SLURM_JOB_NUM_NODES --hsdp_shard_dim $NUM_GPUS ) diff --git a/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.sh b/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.sh index f1a79d688..7e419ea12 100644 --- a/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.sh +++ b/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.sh @@ -30,7 +30,7 @@ training_args=( parallel_args=( --num_gpus $NUM_GPUS --sp_size $NUM_GPUS - --tp_size $NUM_GPUS + --tp_size 1 --hsdp_replicate_dim 1 --hsdp_shard_dim $NUM_GPUS ) diff --git a/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.slurm b/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.slurm index f439a634b..6005bd001 100644 --- a/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.slurm +++ b/examples/training/finetune/wan_t2v_1_3b/crush_smol/finetune_t2v.slurm @@ -63,7 +63,7 @@ training_args=( parallel_args=( --num_gpus $NUM_GPUS --sp_size 4 - --tp_size 4 + --tp_size 1 --hsdp_replicate_dim 2 --hsdp_shard_dim 4 ) diff --git a/fastvideo/v1/fastvideo_args.py b/fastvideo/v1/fastvideo_args.py index 0c9eba878..0786e8c28 100644 --- a/fastvideo/v1/fastvideo_args.py +++ b/fastvideo/v1/fastvideo_args.py @@ -292,7 +292,7 @@ class FastVideoArgs: assert self.sp_size != -1, "sp_size must be set for training" if self.tp_size == -1: - self.tp_size = self.num_gpus + self.tp_size = 1 if self.sp_size == -1: self.sp_size = self.num_gpus if self.hsdp_shard_dim == -1: @@ -305,11 +305,6 @@ class FastVideoArgs: if self.num_gpus < max(self.tp_size, self.sp_size): self.num_gpus = max(self.tp_size, self.sp_size) - if self.tp_size != self.sp_size: - raise ValueError( - f"tp_size ({self.tp_size}) must be equal to sp_size ({self.sp_size})" - ) - if self.enable_torch_compile and self.num_gpus > 1: logger.warning( "Currently torch compile does not work with multi-gpu. Setting enable_torch_compile to False" diff --git a/fastvideo/v1/tests/nightly/test_e2e_i2v_overfit_single_sample.py b/fastvideo/v1/tests/nightly/test_e2e_i2v_overfit_single_sample.py index d8f6f389b..7ba1f2c76 100644 --- a/fastvideo/v1/tests/nightly/test_e2e_i2v_overfit_single_sample.py +++ b/fastvideo/v1/tests/nightly/test_e2e_i2v_overfit_single_sample.py @@ -105,7 +105,7 @@ def run_training(): "--num_latent_t", "8", "--num_gpus", NUM_GPUS_PER_NODE_TRAINING, "--sp_size", NUM_GPUS_PER_NODE_TRAINING, - "--tp_size", NUM_GPUS_PER_NODE_TRAINING, + "--tp_size", 1, "--hsdp_replicate_dim", "1", "--hsdp_shard_dim", NUM_GPUS_PER_NODE_TRAINING, "--num_gpus", NUM_GPUS_PER_NODE_TRAINING, diff --git a/fastvideo/v1/tests/ssim/README.md b/fastvideo/v1/tests/ssim/README.md index f114b95d0..0f80e81f2 100644 --- a/fastvideo/v1/tests/ssim/README.md +++ b/fastvideo/v1/tests/ssim/README.md @@ -24,7 +24,7 @@ FastHunyuan-diffusers: { "flow_shift": 17, "seed": 1024, "sp_size": 2, -"tp_size": 2, +"tp_size": 1, "vae_sp": true, "fps": 24 } @@ -41,7 +41,7 @@ Wan2.1-T2V-1.3B-Diffusers: { "flow_shift": 7.0, "seed": 1024, "sp_size": 2, -"tp_size": 2, +"tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", @@ -60,7 +60,7 @@ Wan2.1-I2V-14B-480P-Diffusers: { "flow_shift": 7.0, "seed": 1024, "sp_size": 2, -"tp_size": 2, +"tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", diff --git a/fastvideo/v1/tests/ssim/test_inference_similarity.py b/fastvideo/v1/tests/ssim/test_inference_similarity.py index 41076378e..b8478bd39 100644 --- a/fastvideo/v1/tests/ssim/test_inference_similarity.py +++ b/fastvideo/v1/tests/ssim/test_inference_similarity.py @@ -33,7 +33,7 @@ HUNYUAN_PARAMS = { "flow_shift": 17, "seed": 1024, "sp_size": 2, - "tp_size": 2, + "tp_size": 1, "vae_sp": True, "fps": 24, } @@ -50,7 +50,7 @@ WAN_T2V_PARAMS = { "flow_shift": 7.0, "seed": 1024, "sp_size": 2, - "tp_size": 2, + "tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", @@ -69,7 +69,7 @@ WAN_I2V_PARAMS = { "flow_shift": 7.0, "seed": 1024, "sp_size": 2, - "tp_size": 2, + "tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", @@ -238,7 +238,7 @@ def test_i2v_inference_similarity(prompt, ATTENTION_BACKEND, model_id): logger.error("Failed to write SSIM results to file") min_acceptable_ssim = 0.97 - assert mean_ssim >= min_acceptable_ssim, f"SSIM value {mean_ssim} is below threshold {min_acceptable_ssim}" + assert mean_ssim >= min_acceptable_ssim, f"SSIM value {mean_ssim} is below threshold {min_acceptable_ssim} for {model_id} with backend {ATTENTION_BACKEND}" @pytest.mark.parametrize("prompt", TEST_PROMPTS) @pytest.mark.parametrize("ATTENTION_BACKEND", ["FLASH_ATTN", "TORCH_SDPA"]) @@ -337,5 +337,5 @@ def test_inference_similarity(prompt, ATTENTION_BACKEND, model_id): if not success: logger.error("Failed to write SSIM results to file") - min_acceptable_ssim = 0.95 - assert mean_ssim >= min_acceptable_ssim, f"SSIM value {mean_ssim} is below threshold {min_acceptable_ssim}" + min_acceptable_ssim = 0.93 + assert mean_ssim >= min_acceptable_ssim, f"SSIM value {mean_ssim} is below threshold {min_acceptable_ssim} for {model_id} with backend {ATTENTION_BACKEND}" diff --git a/fastvideo/v1/tests/training/Vanilla/test_training_loss.py b/fastvideo/v1/tests/training/Vanilla/test_training_loss.py index 7f1459cc0..b07ade0ee 100644 --- a/fastvideo/v1/tests/training/Vanilla/test_training_loss.py +++ b/fastvideo/v1/tests/training/Vanilla/test_training_loss.py @@ -43,7 +43,7 @@ def run_worker(): "--num_latent_t", "4", "--num_gpus", "4", "--sp_size", "4", - "--tp_size", "4", + "--tp_size", "1", "--hsdp_replicate_dim", "1", "--hsdp_shard_dim", "4", "--train_sp_batch_size", "1", diff --git a/scripts/finetune/finetune_v1.sh b/scripts/finetune/finetune_v1.sh index 3f97a029b..7d195c73f 100644 --- a/scripts/finetune/finetune_v1.sh +++ b/scripts/finetune/finetune_v1.sh @@ -20,7 +20,7 @@ torchrun --nnodes 1 --nproc_per_node $NUM_GPUS\ --train_batch_size=4 \ --num_latent_t 20 \ --sp_size 4 \ - --tp_size 4 \ + --tp_size 1 \ --hsdp_replicate_dim 1 \ --hsdp_shard_dim 4 \ --num_gpus $NUM_GPUS \ diff --git a/scripts/inference/v1_inference_fasthunyuan.sh b/scripts/inference/v1_inference_fasthunyuan.sh index 3eecb3739..e80fec75f 100644 --- a/scripts/inference/v1_inference_fasthunyuan.sh +++ b/scripts/inference/v1_inference_fasthunyuan.sh @@ -3,13 +3,10 @@ num_gpus=4 export MODEL_BASE=FastVideo/FastHunyuan-Diffusers export FASTVIDEO_ATTENTION_BACKEND=FLASH_ATTN -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \ - --tp-size $num_gpus \ + --tp-size 1 \ --num-gpus $num_gpus \ --height 720 \ --width 1280 \ diff --git a/scripts/inference/v1_inference_hunyuan.sh b/scripts/inference/v1_inference_hunyuan.sh index 5683d6761..529305f3c 100644 --- a/scripts/inference/v1_inference_hunyuan.sh +++ b/scripts/inference/v1_inference_hunyuan.sh @@ -4,13 +4,10 @@ num_gpus=4 export MODEL_BASE=hunyuanvideo-community/HunyuanVideo export FASTVIDEO_ATTENTION_BACKEND=FLASH_ATTN # export MODEL_BASE=hunyuanvideo-community/HunyuanVideo -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \ - --tp-size $num_gpus \ + --tp-size 1 \ --num-gpus $num_gpus \ --height 720 \ --width 1280 \ diff --git a/scripts/inference/v1_inference_hunyuan_STA.sh b/scripts/inference/v1_inference_hunyuan_STA.sh index f05f4f54f..1d2186c3f 100644 --- a/scripts/inference/v1_inference_hunyuan_STA.sh +++ b/scripts/inference/v1_inference_hunyuan_STA.sh @@ -5,13 +5,10 @@ export FASTVIDEO_ATTENTION_CONFIG=assets/mask_strategy_hunyuan.json export FASTVIDEO_ATTENTION_BACKEND=SLIDING_TILE_ATTN export MODEL_BASE=hunyuanvideo-community/HunyuanVideo # export MODEL_BASE=hunyuanvideo-community/HunyuanVideo -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size ${num_gpus} \ - --tp-size ${num_gpus} \ + --tp-size 1 \ --height 768 \ --width 1280 \ --num-frames 117 \ diff --git a/scripts/inference/v1_inference_wan.sh b/scripts/inference/v1_inference_wan.sh index b789b2a1b..6bd73234b 100755 --- a/scripts/inference/v1_inference_wan.sh +++ b/scripts/inference/v1_inference_wan.sh @@ -4,13 +4,10 @@ num_gpus=2 export FASTVIDEO_ATTENTION_BACKEND= export MODEL_BASE=Wan-AI/Wan2.1-T2V-1.3B-Diffusers # export MODEL_BASE=hunyuanvideo-community/HunyuanVideo -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \ - --tp-size $num_gpus \ + --tp-size 1 \ --num-gpus $num_gpus \ --height 480 \ --width 832 \ diff --git a/scripts/inference/v1_inference_wan_STA.sh b/scripts/inference/v1_inference_wan_STA.sh index 89959f077..0b707c397 100755 --- a/scripts/inference/v1_inference_wan_STA.sh +++ b/scripts/inference/v1_inference_wan_STA.sh @@ -4,13 +4,10 @@ num_gpus=2 export FASTVIDEO_ATTENTION_CONFIG=assets/mask_strategy_wan.json export FASTVIDEO_ATTENTION_BACKEND=SLIDING_TILE_ATTN export MODEL_BASE=Wan-AI/Wan2.1-T2V-14B-Diffusers -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \ - --tp-size $num_gpus \ + --tp-size 1 \ --num-gpus $num_gpus \ --height 768 \ --width 1280 \ diff --git a/scripts/inference/v1_inference_wan_VSA.sh b/scripts/inference/v1_inference_wan_VSA.sh index 3b8916c62..e75d2c18e 100755 --- a/scripts/inference/v1_inference_wan_VSA.sh +++ b/scripts/inference/v1_inference_wan_VSA.sh @@ -4,14 +4,11 @@ num_gpus=1 export FASTVIDEO_ATTENTION_BACKEND=VIDEO_SPARSE_ATTN # change model path to local dir if you want to inference using your checkpoint export MODEL_BASE=Wan-AI/Wan2.1-T2V-1.3B-Diffusers -# export MODEL_BASE=hunyuanvideo-community/HunyuanVideo -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. +# export MODEL_BASE=hunyuanvideo-community/HunyuanVideo fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \ - --tp-size $num_gpus \ + --tp-size 1 \ --num-gpus $num_gpus \ --height 448 \ --width 832 \ diff --git a/scripts/inference/v1_inference_wan_i2v.sh b/scripts/inference/v1_inference_wan_i2v.sh index 3601ab1fe..c2ef35fc7 100644 --- a/scripts/inference/v1_inference_wan_i2v.sh +++ b/scripts/inference/v1_inference_wan_i2v.sh @@ -4,9 +4,6 @@ num_gpus=2 export FASTVIDEO_ATTENTION_BACKEND= export MODEL_BASE=Wan-AI/Wan2.1-I2V-14B-480P-Diffusers # export MODEL_BASE=hunyuanvideo-community/HunyuanVideo -# Note that the tp_size and sp_size should be the same and equal to the number -# of GPUs. They are used for different parallel groups. sp_size is used for -# dit model and tp_size is used for encoder models. fastvideo generate \ --model-path $MODEL_BASE \ --sp-size $num_gpus \