FlashVideo icon indicating copy to clipboard operation
FlashVideo copied to clipboard

AssertionError: context parallel size is not initialized

Open MehmetcanTozlu opened this issue 1 year ago • 5 comments

I'm having problem:

[2025-03-13 08:34:22,169] [INFO] [RANK 0] merge layer 35 lora attention back to linear INFO:sat:[RANK 0] merge layer 35 lora attention back to linear [2025-03-13 08:34:22,170] [INFO] [RANK 0] merge layer 36 lora attention back to linear INFO:sat:[RANK 0] merge layer 36 lora attention back to linear [2025-03-13 08:34:22,170] [INFO] [RANK 0] merge layer 37 lora attention back to linear INFO:sat:[RANK 0] merge layer 37 lora attention back to linear [2025-03-13 08:34:22,171] [INFO] [RANK 0] merge layer 38 lora attention back to linear INFO:sat:[RANK 0] merge layer 38 lora attention back to linear [2025-03-13 08:34:22,172] [INFO] [RANK 0] merge layer 39 lora attention back to linear INFO:sat:[RANK 0] merge layer 39 lora attention back to linear [2025-03-13 08:34:22,173] [INFO] [RANK 0] merge layer 40 lora attention back to linear INFO:sat:[RANK 0] merge layer 40 lora attention back to linear [2025-03-13 08:34:22,174] [INFO] [RANK 0] merge layer 41 lora attention back to linear INFO:sat:[RANK 0] merge layer 41 lora attention back to linear merge lora of model.diffusion_model.mixins.lora rank and world_size 0 1 load from /home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/example.txt with 25 vis_270p_1080p_example rank 0 processing 0 {'prompt': 'The video begins with a view of a cozy log cabin nestled among lush trees in a dense forest. A gentle plume of white smoke rises gracefully from the chimney, curling against the backdrop of towering pines. The windows emit a warm, soft glow, hinting at a comforting and inviting atmosphere within. The camera slowly pans from right to left, capturing the serene setting and emphasizing the harmony between the cabin and its natural surroundings.', 'negative_prompt': 'very low motion,, low motion,', 'num_frames': tensor([13])} txt [445] overwrite cfg scale in config of stage-1 ############################## Sampling setting ############################## Sampler: VPSDEDPMPP2MSampler Discretization: ZeroSNRDDPMDiscretization Guider: DynamicCFG Sampling with VPSDEDPMPP2MSampler for 52 steps: 98%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 51/52 [01:33<00:01, 1.83s/it] _CONTEXT_PARALLEL_SIZE: None [rank0]: Traceback (most recent call last): [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 390, in [rank0]: sampling_main(args, [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 308, in sampling_main [rank0]: first_stage_samples = get_first_results(model, text, num_frames, H, W) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 124, in get_first_results [rank0]: samples = decode(first_stage_model, latent) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/utils.py", line 81, in decode [rank0]: recon = first_stage_model.decode( [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/vae_modules/autoencoder.py", line 704, in decode [rank0]: global_src_rank = get_context_parallel_group_rank() * self.cp_size [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/sgm/util.py", line 71, in get_context_parallel_group_rank [rank0]: assert _CONTEXT_PARALLEL_SIZE is not None, 'context parallel size is not initialized' [rank0]: AssertionError: context parallel size is not initialized

How can I solve this problem?

MehmetcanTozlu avatar Mar 13 '25 08:03 MehmetcanTozlu

How did you launch the program, and have you made any modifications to the code?

It should be configured when launching the program, as shown here: https://github.com/FoundationVision/FlashVideo/blob/8de4ae2b2c468e78116ad821e8bcd2339282e2b8/flashvideo/arguments.py#L272C9-L272C35.

The function call stack is as follows:

/flashvideo/dist_inf_text_file.py(363)<module>()
-> args = get_args(args_list)
/flashvideo/arguments.py(216)get_args()
-> initialize_distributed(args)
> /flashvideo/arguments.py(274)initialize_distributed()
-> set_context_parallel_group(args.model_parallel_size,

jshilong avatar Mar 13 '25 09:03 jshilong

I have changed these:

dist_inf_text_file.py:

if name == 'main':

# if 'OMPI_COMM_WORLD_LOCAL_RANK' in os.environ:
#     os.environ['LOCAL_RANK'] = os.environ['OMPI_COMM_WORLD_LOCAL_RANK']
#     os.environ['WORLD_SIZE'] = os.environ['OMPI_COMM_WORLD_SIZE']
#     os.environ['RANK'] = os.environ['OMPI_COMM_WORLD_RANK']
os.environ['MASTER_ADDR'] = 'localhost' # added
os.environ['MASTER_PORT'] = '12345' # added

torch.distributed.init_process_group(backend='gloo', rank=0, world_size=1)
py_parser = argparse.ArgumentParser(add_help=False)
known, args_list = py_parser.parse_known_args()
second_args_list = copy.deepcopy(args_list)

args = get_args(args_list)
args = argparse.Namespace(**vars(args), **vars(known))

del args.deepspeed_config
args.model_config.first_stage_config.params.cp_size = 1
args.model_config.network_config.params.transformer_args.model_parallel_size = 1
args.model_config.network_config.params.transformer_args.checkpoint_activations = False
args.model_config.loss_fn_config.params.sigma_sampler_config.params.uniform_sampling = False

args.model_config.conditioner_config.params.emb_models[0].params['model_dir'] = "/home/wrusr/genai_workspace/flash_env/workspace/pretrained/t5-v1_1-xxl" # added

args.model_config.first_stage_config.params['ckpt_path'] = "/home/wrusr/genai_workspace/flash_env/workspace/pretrained/FlashVideo/3d-vae.pt" # added

second_args_list[1] = args.second[0]
second_args = get_args(second_args_list)
second_args = argparse.Namespace(**vars(second_args), **vars(known))

second_args.model_config.conditioner_config.params.emb_models[0].params['model_dir'] = "/home/wrusr/genai_workspace/flash_env/workspace/pretrained/t5-v1_1-xxl" # added

second_args.model_config.first_stage_config.params['ckpt_path'] = "/home/wrusr/genai_workspace/flash_env/workspace/pretrained/FlashVideo/3d-vae.pt" # added

del second_args.deepspeed_config
second_args.model_config.first_stage_config.params.cp_size = 1
second_args.model_config.network_config.params.transformer_args.model_parallel_size = 1
second_args.model_config.network_config.params.transformer_args.checkpoint_activations = False
second_args.model_config.loss_fn_config.params.sigma_sampler_config.params.uniform_sampling = False

sampling_main(args,
              second_args,
              model_cls=SATVideoDiffusionEngine,
              second_model_cls=FlowEngine)

MehmetcanTozlu avatar Mar 13 '25 09:03 MehmetcanTozlu

Do not modify them. Initializing dist externally has disrupted the related logic.

If you only have one GPU, change 8 to 1 in the following script:
https://github.com/FoundationVision/FlashVideo/blob/8de4ae2b2c468e78116ad821e8bcd2339282e2b8/inf_270_1080p.sh#L1.

jshilong avatar Mar 13 '25 09:03 jshilong

I did what you said. But gives this:

############################## Sampling setting ############################## Sampler: VPSDEDPMPP2MSampler Discretization: ZeroSNRDDPMDiscretization Guider: DynamicCFG Sampling with VPSDEDPMPP2MSampler for 52 steps: 98%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 51/52 [01:33<00:01, 1.84s/it] _CONTEXT_PARALLEL_SIZE: None [rank0]: Traceback (most recent call last): [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 390, in [rank0]: sampling_main(args, [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 308, in sampling_main [rank0]: first_stage_samples = get_first_results(model, text, num_frames, H, W) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 124, in get_first_results [rank0]: samples = decode(first_stage_model, latent) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/utils.py", line 81, in decode [rank0]: recon = first_stage_model.decode( [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/vae_modules/autoencoder.py", line 704, in decode [rank0]: global_src_rank = get_context_parallel_group_rank() * self.cp_size [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/sgm/util.py", line 71, in get_context_parallel_group_rank [rank0]: assert _CONTEXT_PARALLEL_SIZE is not None, 'context parallel size is not initialized' [rank0]: AssertionError: context parallel size is not initialized E0313 12:42:48.050000 61305 torch/distributed/elastic/multiprocessing/api.py:869] failed (exitcode: 1) local_rank: 0 (pid: 61335) of binary: /home/wrusr/genai_workspace/flash_env/bin/python3.10 Traceback (most recent call last): File "/home/wrusr/genai_workspace/flash_env/bin/torchrun", line 8, in sys.exit(main()) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 355, in wrapper return f(*args, **kwargs) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/run.py", line 918, in main run(args) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/run.py", line 909, in run elastic_launch( File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 138, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 269, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py FAILED

Failures: <NO_OTHER_FAILURES>

Root Cause (first observed failure): [0]: time : 2025-03-13_12:42:48 host : ml-development-1 rank : 0 (local_rank: 0) exitcode : 1 (pid: 61335) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

MehmetcanTozlu avatar Mar 13 '25 12:03 MehmetcanTozlu

I did what you said. But gives this:

############################## Sampling setting

Sampler: VPSDEDPMPP2MSampler Discretization: ZeroSNRDDPMDiscretization Guider: DynamicCFG Sampling with VPSDEDPMPP2MSampler for 52 steps: 98%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 51/52 [01:33<00:01, 1.84s/it] _CONTEXT_PARALLEL_SIZE: None [rank0]: Traceback (most recent call last): [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 390, in [rank0]: sampling_main(args, [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 308, in sampling_main [rank0]: first_stage_samples = get_first_results(model, text, num_frames, H, W) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py", line 124, in get_first_results [rank0]: samples = decode(first_stage_model, latent) [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/utils.py", line 81, in decode [rank0]: recon = first_stage_model.decode( [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/vae_modules/autoencoder.py", line 704, in decode [rank0]: global_src_rank = get_context_parallel_group_rank() * self.cp_size [rank0]: File "/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/sgm/util.py", line 71, in get_context_parallel_group_rank [rank0]: assert _CONTEXT_PARALLEL_SIZE is not None, 'context parallel size is not initialized' [rank0]: AssertionError: context parallel size is not initialized E0313 12:42:48.050000 61305 torch/distributed/elastic/multiprocessing/api.py:869] failed (exitcode: 1) local_rank: 0 (pid: 61335) of binary: /home/wrusr/genai_workspace/flash_env/bin/python3.10 Traceback (most recent call last): File "/home/wrusr/genai_workspace/flash_env/bin/torchrun", line 8, in sys.exit(main()) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 355, in wrapper return f(*args, **kwargs) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/run.py", line 918, in main run(args) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/run.py", line 909, in run elastic_launch( File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 138, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/home/wrusr/genai_workspace/flash_env/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 269, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

/home/wrusr/genai_workspace/flash_env/workspace/FlashVideo/flashvideo/dist_inf_text_file.py FAILED

Failures:

<NO_OTHER_FAILURES> Root Cause (first observed failure): [0]: time : 2025-03-13_12:42:48 host : ml-development-1 rank : 0 (local_rank: 0) exitcode : 1 (pid: 61335) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Hello, it seems that our computing environments are somewhat different, and I am unable to reproduce your results.

One possible debugging approach I can suggest is to run your program step by step and compare the function call stack with the correct one.

/flashvideo/dist_inf_text_file.py(363)<module>()
-> args = get_args(args_list)
/flashvideo/arguments.py(216)get_args()
-> initialize_distributed(args)
> /flashvideo/arguments.py(274)initialize_distributed()
-> set_context_parallel_group(args.model_parallel_size,

Debug in this way has a very low cost, as it is at the beginning of the program and doesn’t require any computation. This might help identify why it doesn't reach set_context_parallel_group.

jshilong avatar Mar 13 '25 15:03 jshilong