Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced DiT Training #11226

Closed
wants to merge 1 commit into from
Closed

Conversation

zpx01
Copy link
Collaborator

@zpx01 zpx01 commented Nov 8, 2024

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
# 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:

  • Make sure you read and followed Contributor guidelines
  • 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:

  • 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 contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

ethanhe42
ethanhe42 previously approved these changes Nov 8, 2024
@@ -19,24 +19,31 @@
import torch
from megatron.core.distributed import DistributedDataParallelConfig
from megatron.core.optimizer import OptimizerConfig
from megatron.core.transformer.enums import AttnMaskType

Check notice

Code scanning / CodeQL

Unused import

Import of 'AttnMaskType' is not used.
Comment on lines +471 to +546
torch.cuda.memory._record_memory_history(
True,
# Keep 100,000 alloc/free events from before the snapshot
trace_alloc_max_entries=100000,
# Record stack information for the trace events
trace_alloc_record_context=True,
)

Check warning

Code scanning / CodeQL

Unreachable code

This statement is unreachable.
ethanhe42
ethanhe42 previously approved these changes Nov 8, 2024
Copy link
Contributor

github-actions bot commented Nov 9, 2024

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!

Copy link
Contributor

github-actions bot commented Nov 9, 2024

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!

@zpx01 zpx01 changed the title Zpx01/dit advanced training Advanced DiT Training Nov 9, 2024
@zpx01 zpx01 force-pushed the zpx01/dit_advanced_training branch from 1b3dae5 to 654b7b6 Compare November 9, 2024 01:13
@zpx01 zpx01 force-pushed the zpx01/dit_advanced_training branch from 654b7b6 to f3fc7ea Compare November 9, 2024 01:16
Signed-off-by: Zeeshan Patel <[email protected]>

packed sequence support

Signed-off-by: Zeeshan Patel <[email protected]>

fixed pylint issues

Signed-off-by: Zeeshan Patel <[email protected]>

add docstrings + remove unused import

Signed-off-by: Zeeshan Patel <[email protected]>

Apply isort and black reformatting

Signed-off-by: zpx01 <[email protected]>
Signed-off-by: Zeeshan Patel <[email protected]>

added some missing args

Signed-off-by: Zeeshan Patel <[email protected]>

reformat

Signed-off-by: Zeeshan Patel <[email protected]>

moving fps embedder to gpu

Signed-off-by: Zeeshan Patel <[email protected]>

moving fps tensor  to gpu

Signed-off-by: Zeeshan Patel <[email protected]>

updated models

Signed-off-by: Zeeshan Patel <[email protected]>

added missing import

Signed-off-by: Zeeshan Patel <[email protected]>

added new configs + bug fixes

Signed-off-by: Zeeshan Patel <[email protected]>

seq len fix

Signed-off-by: Zeeshan Patel <[email protected]>

Apply isort and black reformatting

Signed-off-by: zpx01 <[email protected]>
Signed-off-by: Zeeshan Patel <[email protected]>

added nsys callback

Signed-off-by: Zeeshan Patel <[email protected]>

Apply isort and black reformatting

Signed-off-by: zpx01 <[email protected]>
Signed-off-by: Zeeshan Patel <[email protected]>

isort fix

Signed-off-by: Zeeshan Patel <[email protected]>
@zpx01 zpx01 force-pushed the zpx01/dit_advanced_training branch from f3fc7ea to 3805601 Compare November 9, 2024 01:23
@zpx01 zpx01 closed this Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants