|
27 | 27 | from dfm.src.megatron.model.wan.utils.utils import grid_sizes_calculation, patchify |
28 | 28 | from megatron.core import parallel_state |
29 | 29 | from torch.nn import functional as F |
30 | | -from dfm.src.megatron.model.wan.utils.utils import split_inputs_cp, cat_outputs_cp |
31 | 30 |
|
32 | 31 | import math |
33 | 32 | from typing import Tuple, Union |
@@ -99,10 +98,8 @@ def __init__( |
99 | 98 | wan_checkpoint_dir = self._select_checkpoint_dir(checkpoint_dir, checkpoint_step) |
100 | 99 | self.model = self.setup_model_from_checkpoint(wan_checkpoint_dir) |
101 | 100 |
|
102 | | - # DEBUGGING thd |
103 | | - # set qkv_format to to "thd" for context parallelism |
104 | | - # self.model.config.qkv_format = "sbhd" |
105 | | - self.model.config.qkv_format = "thd" |
| 101 | + # if we use context parallelism, we need to set qkv_format to "thd" for context parallelism |
| 102 | + self.model.config.qkv_format = "thd" # "sbhd" |
106 | 103 |
|
107 | 104 | # set self.sp_size=1 for later use, just to respect the original Wan inference code |
108 | 105 | self.sp_size = 1 |
@@ -487,31 +484,13 @@ def noop_no_sync(): |
487 | 484 | timestep = [t] * batch_size |
488 | 485 | timestep = torch.stack(timestep) |
489 | 486 |
|
490 | | - # DEBUGGING thd |
491 | | - # # run context parallelism slitting |
492 | | - # if parallel_state.get_context_parallel_world_size() > 1: |
493 | | - # latent_model_input = split_inputs_cp(latent_model_input, 0) |
494 | | - # arg_c['context'] = split_inputs_cp(arg_c['context'], 0) |
495 | | - # arg_null['context'] = split_inputs_cp(arg_null['context'], 0) |
496 | | - |
497 | 487 | self.model.to(self.device) |
498 | 488 | noise_pred_cond = self.forward_pp_step( |
499 | 489 | latent_model_input, grid_sizes=grid_sizes, max_video_seq_len=max_video_seq_len, timestep=timestep, arg_c=arg_c) |
500 | 490 |
|
501 | 491 | noise_pred_uncond = self.forward_pp_step( |
502 | 492 | latent_model_input, grid_sizes=grid_sizes, max_video_seq_len=max_video_seq_len, timestep=timestep, arg_c=arg_null) |
503 | 493 |
|
504 | | - # DEBUGGING thd |
505 | | - # # run context parallelism gathering |
506 | | - # if parallel_state.get_context_parallel_world_size() > 1: |
507 | | - # arg_c['context'] = cat_outputs_cp(arg_c['context'], 0) # we need to cat the context back together for the next timestep |
508 | | - # arg_null['context'] = cat_outputs_cp(arg_null['context'], 0) # we need to cat the context back together for the next timestep |
509 | | - # # TODO: does this step slow down speed??? |
510 | | - # noise_pred_cond = noise_pred_cond.contiguous() |
511 | | - # noise_pred_uncond = noise_pred_uncond.contiguous() |
512 | | - # noise_pred_cond = cat_outputs_cp(noise_pred_cond, 0) |
513 | | - # noise_pred_uncond = cat_outputs_cp(noise_pred_uncond, 0) |
514 | | - |
515 | 494 | # run unpatchify |
516 | 495 | unpatchified_noise_pred_cond = noise_pred_cond |
517 | 496 | unpatchified_noise_pred_cond = unpatchified_noise_pred_cond.transpose(0, 1) # bring sbhd -> bshd |
|
0 commit comments