Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Commit 35532c2

Browse files
committed
fixlint
Signed-off-by: Pablo Garay <pagaray@nvidia.com>
1 parent 0e3378f commit 35532c2

5 files changed

Lines changed: 54 additions & 54 deletions

File tree

nemo_vfm/diffusion/data/readme.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Preparing Image / Video Megatron Energon WebDataset with Cosmos Tokenizer
1+
Preparing Image / Video Megatron Energon WebDataset with Cosmos Tokenizer
22
===========================
33

44
This script is an example on preparing a WebDataset for an image / video + text dataset using distributed processing with the Cosmos Tokenizer. It processes each sample by generating a **continuous** image / video latent using the Cosmos video tokenizer and a T5 embedding from the text caption. Then, the processed data is stored in a WebDataset-compatible format.
@@ -22,5 +22,5 @@ Usage
2222

2323
3. **Running the Script**:
2424
To run the script on 8 GPUs, use the following command:
25-
25+
2626
``bash torchrun --nproc_per_node=8 nemo/collections/diffusion/data/prepare_energon_dataset.py``

nemo_vfm/diffusion/readme.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Diffusion Training Framework
1+
Diffusion Training Framework
22
=============
33

44
Overview
55
--------
66

7-
The NeMo Diffusion Training Framework provides a scalable training platform for diffusion models with transformer backbones. Our new features streamline the training process, allowing developers to efficiently train state-of-the-art models with ease.
7+
The NeMo Diffusion Training Framework provides a scalable training platform for diffusion models with transformer backbones. Our new features streamline the training process, allowing developers to efficiently train state-of-the-art models with ease.
88

99

1010
Some of the features we currently support include:
@@ -23,13 +23,13 @@ We support image diffusion training. Video training incoming.
2323
+---------------------------+------------------+
2424
| Parallelism | Status |
2525
+===========================+==================+
26-
| FSDP | Supported |
26+
| FSDP | ✅ Supported |
2727
+---------------------------+------------------+
28-
| CP+TP+SP+distopt | Supported |
28+
| CP+TP+SP+distopt | ✅ Supported |
2929
+---------------------------+------------------+
30-
| CP+TP+SP+PP+distopt | Supported |
30+
| CP+TP+SP+PP+distopt | ✅ Supported |
3131
+---------------------------+------------------+
32-
| CP+TP+SP+FSDP | 🕒 Coming Soon |
32+
| CP+TP+SP+FSDP | 🕒 Coming Soon |
3333
+---------------------------+------------------+
3434

3535

@@ -44,11 +44,11 @@ We support image diffusion training. Video training incoming.
4444
+--------------+-------------------+-----------------+
4545
| Model Size | Modality | Status |
4646
+==============+===================+=================+
47-
| DiT 30B+ | 256px image | Supported |
47+
| DiT 30B+ | 256px image | ✅ Supported |
4848
+--------------+-------------------+-----------------+
49-
| DiT 30B+ | 256px image+video | 🕒 Coming Soon |
49+
| DiT 30B+ | 256px image+video | 🕒 Coming Soon |
5050
+--------------+-------------------+-----------------+
51-
| DiT 30B+ | 768px image+video | 🕒 Coming Soon |
51+
| DiT 30B+ | 768px image+video | 🕒 Coming Soon |
5252
+--------------+-------------------+-----------------+
5353

5454

@@ -58,7 +58,7 @@ Energon Dataloader for Webscale Dataloading
5858
Webscale Dataloading
5959
^^^^^^^^^^^^^^^^^^^^
6060

61-
Megatron-Energon is an optimized multi-modal dataloader for large-scale deep learning with Megatron. Energon allows for distributed loading of large training training data for multi-modal model training. Energon allows for blending many datasets together and distributing the dataloading workflow across multiple cluster nodes/processes while ensuring reproducibility and resumability.
61+
Megatron-Energon is an optimized multi-modal dataloader for large-scale deep learning with Megatron. Energon allows for distributed loading of large training training data for multi-modal model training. Energon allows for blending many datasets together and distributing the dataloading workflow across multiple cluster nodes/processes while ensuring reproducibility and resumability.
6262

6363
Dataloader Checkpointing
6464
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -84,7 +84,7 @@ Our dataloader provides support for mixed image-video training by using the NeMo
8484

8585
Model and Data Parallelism
8686
--------------------------
87-
NeMo provides support for training models using tensor parallelism, sequence parallelism, pipeline parallelism, and context parallelism. To support pipeline parallelism with conditional diffusion training, we duplicate the conditional embeddings across the pipeline stages, and perform an all-reduce during the backward pass. This approach uses more compute, but it has a lower communication cost than sending the conditional embeddings through different pipeline stages.
87+
NeMo provides support for training models using tensor parallelism, sequence parallelism, pipeline parallelism, and context parallelism. To support pipeline parallelism with conditional diffusion training, we duplicate the conditional embeddings across the pipeline stages, and perform an all-reduce during the backward pass. This approach uses more compute, but it has a lower communication cost than sending the conditional embeddings through different pipeline stages.
8888

8989
.. image:: assets/pipeline_conditioning.png
9090
:alt: Conditioning mechanism for pipeline parallelism
@@ -116,14 +116,14 @@ this will generate a folder a tar files. .pth contains image/video latent repres
116116
.. code-block:: bash
117117
118118
shard_000.tar
119-
├── samples/sample_0000.pth
120-
├── samples/sample_0000.pickle
121-
├── samples/sample_0000.json
122-
├── samples/sample_0001.pth
123-
├── samples/sample_0001.pickle
124-
├── samples/sample_0001.json
125-
└── ...
126-
shard_001.tar
119+
├── samples/sample_0000.pth
120+
├── samples/sample_0000.pickle
121+
├── samples/sample_0000.json
122+
├── samples/sample_0001.pth
123+
├── samples/sample_0001.pickle
124+
├── samples/sample_0001.json
125+
└── ...
126+
shard_001.tar
127127
128128
The following is a sample command to prepare prepare webdataset into energon dataset:
129129

nemo_vfm/diffusion/vae/readme.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
============================
1+
============================
22
Pretraining Variational AutoEncoder
33
============================
44

@@ -49,11 +49,11 @@ Data Preparation
4949
.. code-block:: bash
5050
5151
000000.tar
52-
├── 1.jpg
53-
├── 2.jpg
52+
├── 1.jpg
53+
├── 2.jpg
5454
000001.tar
55-
├── 3.jpg
56-
├── 4.jpg
55+
├── 3.jpg
56+
├── 4.jpg
5757
5858
2. next we need to index the webdataset with `energon <https://nvidia.github.io/Megatron-Energon/>`_. navigate to the dataset directory and run the following command:
5959

@@ -64,7 +64,7 @@ Data Preparation
6464
3. then select dataset type `ImageWebdataset` and specify the type `jpg`. Below is an example of the interactive setup:
6565

6666
.. code-block:: bash
67-
67+
6868
Found 2925 tar files in total. The first and last ones are:
6969
- 000000.tar
7070
- 002924.tar

nemo_vfm/physicalai/Cosmos/cosmos1/models/autoregressive/nemo/post_training/tokenizer/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cosmos Autoregressive-based World Foundation Models: Changing the Video Tokenizer
1+
# Cosmos Autoregressive-based World Foundation Models: Changing the Video Tokenizer
22

33
Learn how to post-train Cosmos Autoregressive-based World Foundation Models (WFMs) using the NVIDIA NeMo Framework when swapping out the original tokenizer for a new one. This recipe provides a conceptual overview of how to adapt your existing model to handle a different discrete video (DV) tokenizer, ensuring high-quality video generation under a new compression setting.
44

@@ -49,20 +49,20 @@ The NeMo Framework supports the following Cosmos Autoregressive (AR) models for
4949

5050
## Why Change Tokenizers?
5151

52-
Cosmos Autoregressive models are typically trained on a specific tokenizer configuration (e.g., 8×16×16). If you’d like to reduce patch size or change compression (e.g., to 4×8×8), you can post-train the existing weights so that the model effectively aligns its internal representations with the new token embeddings—without re-training the tokenizer.
52+
Cosmos Autoregressive models are typically trained on a specific tokenizer configuration (e.g., 8×16×16). If you’d like to reduce patch size or change compression (e.g., to 4×8×8), you can post-train the existing weights so that the model effectively aligns its internal representations with the new token embeddings—without re-training the tokenizer.
5353

5454
## Tutorial: Finetuning Cosmos-4B on 10k Videos with a New Tokenizer
5555

5656
In this tutorial, we will:
57-
- Take a model originally trained on an 8×16×16 tokenizer.
58-
- Post-train it on a 4×8×8 tokenizer.
57+
- Take a model originally trained on an 8×16×16 tokenizer.
58+
- Post-train it on a 4×8×8 tokenizer.
5959
- Demonstrate using a sample dataset of 10 (in production, we recommend using 10k videos from a distribution similar to that of pretraining).
6060

6161
### 1. Calculate Sequence Lengths
6262

63-
- **Original Sequence Length:** 12,800 tokens (33 frames * 640 px width * 1024 px height, when tokenized with an 8×16×16 tokenizer becomes ⌈33/8⌉ * (640/16) * (1024/16) = 5 * 64 * 80 = 12,800 tokens)
64-
- **New Sequence Length:** 12,800 tokens (17 frames * 320 px width * 512 px height, when tokenized with a 4×8×8 tokenizer becomes ⌈17/8⌉ * (320/4) * (512/8) = 5 * 80 * 64 = 12,800 tokens)
65-
- For other resolutions or frame counts, recalculate your maximum tokens to ensure you do not exceed the model’s capacity.
63+
- **Original Sequence Length:** 12,800 tokens (33 frames * 640 px width * 1024 px height, when tokenized with an 8×16×16 tokenizer becomes ⌈33/8⌉ * (640/16) * (1024/16) = 5 * 64 * 80 = 12,800 tokens)
64+
- **New Sequence Length:** 12,800 tokens (17 frames * 320 px width * 512 px height, when tokenized with a 4×8×8 tokenizer becomes ⌈17/8⌉ * (320/4) * (512/8) = 5 * 80 * 64 = 12,800 tokens)
65+
- For other resolutions or frame counts, recalculate your maximum tokens to ensure you do not exceed the model’s capacity.
6666

6767
```bash
6868
export WIDTH=512
@@ -137,15 +137,15 @@ torchrun --nproc-per-node=$NUM_GPUS cosmos1/models/autoregressive/nemo/post_trai
137137
```
138138

139139
- Adjust parameters such as `--max_steps`, `--global_batch_size`, and `--lr` to suit your needs.
140-
- Ensure that `--model_path` matches the checkpoint originally trained on an 8×16×16 tokenizer.
140+
- Ensure that `--model_path` matches the checkpoint originally trained on an 8×16×16 tokenizer.
141141
- For an explanation on other configuration options, please see [the general post-training tutorial](https://github.com/NVIDIA/Cosmos/blob/main/cosmos1/models/autoregressive/nemo/post_training/README.md#configuration-options).
142142

143143
### 5. Monitor Quality
144144

145145
After training, monitor checkpoints and generate sample outputs. Please keep in mind that you will have to
146146
disable the diffusion decoder, as this is not yet supported for non-standard tokenizers.
147147

148-
1. **Checkpoints:**
148+
1. **Checkpoints:**
149149
Checkpoints are saved under `./experiments/example_log_dir/default/checkpoints/`. For example:
150150
```bash
151151
epoch=1-step=49
@@ -154,7 +154,7 @@ disable the diffusion decoder, as this is not yet supported for non-standard tok
154154
```
155155
Choose a checkpoint (e.g., `epoch=1-step=99`) for inference.
156156

157-
2. **Run Inference:**
157+
2. **Run Inference:**
158158
Generate sample video outputs:
159159
```bash
160160
# Set the checkpoint directory
@@ -177,7 +177,7 @@ disable the diffusion decoder, as this is not yet supported for non-standard tok
177177
--tokenizer_compression_factor $TOKENIZER_COMPRESSION_FACTOR
178178
```
179179

180-
3. **(Optional) Evaluate with TokenBench:**
180+
3. **(Optional) Evaluate with TokenBench:**
181181
To compute quantitative metrics (e.g., PSNR, SSIM), generate a large number of videos using the script above and place them into the `evals`
182182
folder of the checkpoint. Please ensure that the input filename in the original folder (e.g. `my-video.mp4` matches the output filename in the
183183
`evals` folder). This is because PSNR and SSIM compare video quality against a reference, and our script will match the output video with
@@ -245,7 +245,7 @@ python cosmos1/models/autoregressive/nemo/post_training/video2world_prepare_data
245245

246246
### 3. Training/Finetuning for Video2World
247247

248-
Fine-tune a Video2World–specific checkpoint (or any compatible Cosmos AR model) on your new data. For example, using the 5B Video2World model:
248+
Fine-tune a Video2World–specific checkpoint (or any compatible Cosmos AR model) on your new data. For example, using the 5B Video2World model:
249249

250250
```bash
251251
torchrun --nproc-per-node=$NUM_GPUS cosmos1/models/autoregressive/nemo/post_training/video2world_finetuning.py \

nemo_vfm/physicalai/Cosmos/cosmos1/models/diffusion/nemo/post_training/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cosmos Diffusion-based World Foundation Models: NeMo Framework User Guide
1+
# Cosmos Diffusion-based World Foundation Models: NeMo Framework User Guide
22

33
Learn how to [post-train](#post-train) Cosmos Diffusion-based World Foundation Models (WFMs) using the [NVIDIA NeMo Framework](https://docs.nvidia.com/nemo-framework/user-guide/latest/overview.html) for your custom Physical AI tasks by following this guide.
44

@@ -439,7 +439,7 @@ srun \
439439
torchrun --nproc_per_node=8 cosmos1/models/diffusion/nemo/post_training/multicamera.py --factory cosmos_multicamera_diffusion_7b_text2world_overfit --yes trainer.max_steps=1000 optim.config.lr=1e-6
440440
```
441441

442-
4. (Optional) Run Largescale Full Post-Training
442+
4. (Optional) Run Largescale Full Post-Training
443443
You will need to prepare you own data similar with the overfit dataset in step 3. Change XDG_CACHE_HOME to point to the custom dataset
444444
```bash
445445
torchrun --nproc_per_node=8 cosmos1/models/diffusion/nemo/post_training/multicamera.py --yes trainer.max_steps=1000 optim.config.lr=1e-6
@@ -461,26 +461,26 @@ srun \
461461
# --factory cosmos_multicamera_diffusion_7b_image2world_finetune_w_traj
462462
```
463463

464-
For different post-training recipes make sure to change the autoresume directory so that checkpoints generated from recipe A are not used for recipe B. Modify 'recipe.trainer.callbacks.dirpath' and 'recipe.resume.resume_from_directory'.
464+
For different post-training recipes make sure to change the autoresume directory so that checkpoints generated from recipe A are not used for recipe B. Modify 'recipe.trainer.callbacks.dirpath' and 'recipe.resume.resume_from_directory'.
465465

466-
'recipe.trainer.val_check_interval' and 'recipe.trainer.limit_val_batches' can be set to 0 to disable validation during post-training.
466+
'recipe.trainer.val_check_interval' and 'recipe.trainer.limit_val_batches' can be set to 0 to disable validation during post-training.
467467

468468
Under `HF_HOME`, there should be a `hub` folder, which contains the base checkpoints. Under `multicamera` folder, there should be view embeddings, `mkdir -p $HF_HOME/multicamera && symlink -s cosmos1/models/diffusion/nemo/post_training/multicamera/*.pt $HF_HOME/multicamera`
469469
```
470470
hub/
471-
├── models--nvidia--Cosmos-1.0-Diffusion-7B-Text2World/
472-
├── models--nvidia--Cosmos-1.0-Diffusion-7B-Video2World/
473-
└── models--nvidia--Cosmos-1.0-Tokenizer-CV8x8x8/
471+
├── models--nvidia--Cosmos-1.0-Diffusion-7B-Text2World/
472+
├── models--nvidia--Cosmos-1.0-Diffusion-7B-Video2World/
473+
└── models--nvidia--Cosmos-1.0-Tokenizer-CV8x8x8/
474474
475475
multicamera/
476-
├── video_camera_embeddings_v0_camera_front_tele_30fov.pt
477-
├── video_camera_embeddings_v0_camera_rear_tele_30fov.pt
478-
├── video_camera_embeddings_v0_camera_front_wide_120fov.pt
479-
├── video_neg_prompt_embeddings_v0.pt
480-
├── video_camera_embeddings_v0_camera_cross_left_120fov.pt
481-
├── video_camera_embeddings_v0_camera_cross_right_120fov.pt
482-
├── video_camera_embeddings_v0_camera_rear_left_70fov.pt
483-
└── video_camera_embeddings_v0_camera_rear_right_70fov.pt
476+
├── video_camera_embeddings_v0_camera_front_tele_30fov.pt
477+
├── video_camera_embeddings_v0_camera_rear_tele_30fov.pt
478+
├── video_camera_embeddings_v0_camera_front_wide_120fov.pt
479+
├── video_neg_prompt_embeddings_v0.pt
480+
├── video_camera_embeddings_v0_camera_cross_left_120fov.pt
481+
├── video_camera_embeddings_v0_camera_cross_right_120fov.pt
482+
├── video_camera_embeddings_v0_camera_rear_left_70fov.pt
483+
└── video_camera_embeddings_v0_camera_rear_right_70fov.pt
484484
```
485485

486486
## DiT Video2World Camera-Control Post-Training

0 commit comments

Comments
 (0)