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 Diffusion Training Features #11246

Merged
merged 1 commit into from
Nov 13, 2024
Merged

Advanced Diffusion Training Features #11246

merged 1 commit into from
Nov 13, 2024

Conversation

zpx01
Copy link
Collaborator

@zpx01 zpx01 commented Nov 10, 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)

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

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!

Copy link
Contributor

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!


video_latent = torch.ones(self.seq_length, c * p**2, dtype=torch.bfloat16) * 0.5
text_embedding = torch.randn(self.text_seqlen, self.text_dim, dtype=torch.bfloat16)
pos_emb = pos_id_3d.get_pos_id_3d(t=t, h=h // p, w=w // p).reshape(-1, 3)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable pos_emb is not used.
Comment on lines +540 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 Warning

This statement is unreachable.
Copy link
Contributor

[🤖]: Hi @zpx01 👋,

We wanted to let you know that a CICD pipeline 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

@zpx01 zpx01 self-assigned this Nov 11, 2024
@zpx01 zpx01 merged commit 6e8e974 into main Nov 13, 2024
165 of 166 checks passed
@zpx01 zpx01 deleted the vfm branch November 13, 2024 04:09
@zpx01 zpx01 restored the vfm branch November 13, 2024 04:09
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