Advanced Diffusion Training Features
State: closed | Pull request: yes
Labels: name: Run CICD

# What does this PR do ?

Adds the following new features to the Diffusion Training Framework:
- FSDP support
- MovieGen 1B/5B/30B Stages 1-3 Training with FSDP + TP/SP + CP
- EC-DiT model (https://arxiv.org/abs/2410.02098)
- Adds mock video data module for mock training across stages 1-3 
- Mixed Image-Video Training with THD Packed Sequencing

**Collection**: diffusion

# Changelog 
- Add specific line by line info of high level changes in this PR.

# Usage
* You can potentially add a usage example below

```python
# Add a code snippet demonstrating how to use this 
```

# GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

# Before your PR is "Ready for review"
**Pre checks**:
- [X] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [ ] Did you write any new necessary tests?
- [ ] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [X] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)


<!-- pylint-output-strict-mode-true -->

beep boop 🤖: 🚨 The following files must be fixed before merge!

---

Your code was analyzed with PyLint. The following annotations have been identified:

```

------------------------------------
Your code has been rated at 10.00/10
```

---

Thank you for improving NeMo's documentation!

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module nemo.collections.diffusion.models.dit.dit_embeddings
nemo/collections/diffusion/models/dit/dit_embeddings.py:141:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_embeddings.py:147:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_embeddings.py:173:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_embeddings.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_embeddings.py:183:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_embeddings.py:16:0: W0611: Unused import math (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:17:0: W0611: Unused Dict imported from typing (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:17:0: W0611: Unused Literal imported from typing (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:17:0: W0611: Unused Optional imported from typing (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:19:0: W0611: Unused numpy imported as np (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:21:0: W0611: Unused torch.nn.functional imported as F (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:24:0: W0611: Unused Rearrange imported from einops.layers.torch (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:26:0: W0611: Unused get_pos_emb_on_this_cp_rank imported from megatron.core.models.common.embeddings.rotary_pos_embedding (unused-import)
nemo/collections/diffusion/models/dit/dit_embeddings.py:28:0: W0611: Unused nn imported from torch (unused-import)
************* Module nemo.collections.diffusion.models.dit.dit_layer_spec
nemo/collections/diffusion/models/dit/dit_layer_spec.py:194:0: C0301: Line too long (138/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:234:0: C0301: Line too long (132/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:249:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:268:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:288:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:306:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:362:0: C0301: Line too long (138/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:396:0: C0301: Line too long (129/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:416:0: C0301: Line too long (129/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:549:0: C0301: Line too long (127/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:552:0: C0301: Line too long (138/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:53:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:59:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:65:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:74:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:108:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:112:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:116:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:120:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:132:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:138:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:157:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:221:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:383:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:482:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:565:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:623:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:643:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:675:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:736:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:775:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:800:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:826:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:845:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:21:0: W0611: Unused rearrange imported from einops (unused-import)
nemo/collections/diffusion/models/dit/dit_layer_spec.py:22:0: W0611: Unused jit_fuser imported from megatron.core.jit (unused-import)
************* Module nemo.collections.diffusion.models.dit.dit_model
nemo/collections/diffusion/models/dit/dit_model.py:111:0: C0301: Line too long (156/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_model.py:115:0: C0301: Line too long (134/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_model.py:117:0: C0301: Line too long (157/119) (line-too-long)
nemo/collections/diffusion/models/dit/dit_model.py:40:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_model.py:44:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/diffusion/models/dit/dit_model.py:53:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_model.py:71:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit/dit_model.py:20:0: W0611: Unused torch.nn.functional imported as F (unused-import)
************* Module nemo.collections.diffusion.models.dit_llama.dit_llama_layer_spec
nemo/collections/diffusion/models/dit_llama/dit_llama_layer_spec.py:76:0: C0301: Line too long (138/119) (line-too-long)
nemo/collections/diffusion/models/dit_llama/dit_llama_layer_spec.py:103:0: C0301: Line too long (129/119) (line-too-long)
nemo/collections/diffusion/models/dit_llama/dit_llama_layer_spec.py:119:0: C0301: Line too long (125/119) (line-too-long)
nemo/collections/diffusion/models/dit_llama/dit_llama_layer_spec.py:88:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/dit_llama/dit_llama_layer_spec.py:195:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.diffusion.models.dit_llama.dit_llama_model
nemo/collections/diffusion/models/dit_llama/dit_llama_model.py:25:0: C0115: Missing class docstring (missing-class-docstring)
************* Module nemo.collections.diffusion.models.model
nemo/collections/diffusion/models/model.py:312:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/models/model.py:334:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.diffusion.sampler.edm.edm_pipeline
nemo/collections/diffusion/sampler/edm/edm_pipeline.py:20:0: W0611: Unused rearrange imported from einops (unused-import)
************* Module nemo.collections.diffusion.train
nemo/collections/diffusion/train.py:223:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/diffusion/train.py:258:0: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.50/10
```

---

Thank you for improving NeMo's documentation!

[🤖]: Hi @zpx01 👋,

We wanted to let you know that a [CICD pipeline](https://github.com/NVIDIA/NeMo/actions/runs/11761770174) for this PR just finished successfully

So it might be time to merge this PR or get some approvals

I'm just a bot so I'll leave it you what to do next.

//cc @pablo-garay @ko3n1g