Repository navigation
Add Cosmos3 Edge and Distilled checkpoints support - #5001
Conversation
Add native Cosmos3 Edge image and video generation support across the transformer, diffusion pipeline, model registry, documentation, and tests. - add Cosmos3EdgeVFMTransformer and select it from the checkpoint's Edge backbone type - implement the Edge-specific ReLU2 feed-forward and Q/K normalization behavior - support Edge T2I, T2V, and I2V resolutions, with video guidance scale 5.0 and flow shift 3.0 - register Cosmos3OmniPipeline as an alias of Cosmos3OmniDiffusersPipeline for the new checkpoint model-index format - register the Edge transformer with Cosmos3 Cache-DiT integration - round requested video lengths to the causal VAE temporal grid - use FlowUniPCMultistepScheduler for regular checkpoints and apply the request flow shift while constructing timesteps - select FlowMatchEulerDiscreteScheduler from distilled checkpoint configuration and use its fixed sigma schedule - validate distilled checkpoint modalities and enforce guidance scale 1.0 - parse structured JSON prompts, update duration, FPS, resolution, and aspect-ratio metadata, and serialize them for model conditioning - distinguish explicitly provided guidance from request fallback values - seed PyTorch and CUDA consistently for request reproducibility - create timestep embedding frequencies in FP32 - add transformer, pipeline, registry, scheduler, prompt-formatting, and integration coverage - document Cosmos3 Edge registration, supported modes, defaults, and known limitations Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
|
|
||
| #### Notes | ||
|
|
||
| - **Performance:** TBD. Checkpoint is not yet released |
There was a problem hiding this comment.
next PR for updates?
There was a problem hiding this comment.
Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?
There was a problem hiding this comment.
Removed Cosmos3-Edge from docs, will add in followup PR when checkpoint is released
| "Wan22VACEPipeline": enable_cache_for_wan22, | ||
| "Wan22S2VPipeline": enable_cache_for_wan22_s2v, | ||
| "Cosmos3OmniDiffusersPipeline": enable_cache_for_cosmos3, | ||
| "Cosmos3OmniPipeline": enable_cache_for_cosmos3, |
There was a problem hiding this comment.
this one is for edge? if so can we rename the pipelines?
There was a problem hiding this comment.
The new name is required by diffusers. I wanted to have both names to remain backward compatible with previously downloaded checkpoints
| | `WanPipeline` | Wan2.1-T2V, Wan2.2-T2V, Wan2.2-TI2V | `Wan-AI/Wan2.1-T2V-1.3B-Diffusers`, `Wan-AI/Wan2.1-T2V-14B-Diffusers`, `Wan-AI/Wan2.2-T2V-A14B-Diffusers`, `Wan-AI/Wan2.2-TI2V-5B-Diffusers` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `WanImageToVideoPipeline` | Wan2.2-I2V | `Wan-AI/Wan2.2-I2V-A14B-Diffusers` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `Cosmos3OmniDiffusersPipeline` | Cosmos3 T2I, T2V, I2V, V2V, T2V with sound, action policy | `nvidia/Cosmos3-Nano`, `nvidia/Cosmos3-Super` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `Cosmos3OmniDiffusersPipeline` | Cosmos3 T2I, T2V, I2V, V2V, T2V with sound, action policy; Cosmos3 Edge T2I/T2V/I2V/action | `nvidia/Cosmos3-Nano`, `nvidia/Cosmos3-Super`, `nvidia/Cosmos3-Edge` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | |
There was a problem hiding this comment.
This marks Cosmos3 Edge as fully supported, but the PR does not include Edge run evidence yet. Please add runnable Edge online/offline commands, sample output, latency, and peak VRAM, or keep the support row scoped until that evidence is available.
There was a problem hiding this comment.
Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?
There was a problem hiding this comment.
Removed Cosmos3-Edge from docs, will add in followup PR when checkpoint is released
|
|
||
| #### Notes | ||
|
|
||
| - **Performance:** TBD. Checkpoint is not yet released |
There was a problem hiding this comment.
Need actual Edge latency and peak VRAM here before merge, with hardware, resolution, step count, and the command used to measure. TBD makes the new model support unverifiable.
There was a problem hiding this comment.
Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?
There was a problem hiding this comment.
Removed Cosmos3-Edge from docs, will add in followup PR when checkpoint is released
| | `WanPipeline` | Wan2.1-T2V, Wan2.2-T2V, Wan2.2-TI2V | `Wan-AI/Wan2.1-T2V-1.3B-Diffusers`, `Wan-AI/Wan2.1-T2V-14B-Diffusers`, `Wan-AI/Wan2.2-T2V-A14B-Diffusers`, `Wan-AI/Wan2.2-TI2V-5B-Diffusers` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `WanImageToVideoPipeline` | Wan2.2-I2V | `Wan-AI/Wan2.2-I2V-A14B-Diffusers` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `Cosmos3OmniDiffusersPipeline` | Cosmos3 T2I, T2V, I2V, V2V, T2V with sound, action policy | `nvidia/Cosmos3-Nano`, `nvidia/Cosmos3-Super` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | | ||
| | `Cosmos3OmniDiffusersPipeline` | Cosmos3 T2I, T2V, I2V, V2V, T2V with sound, action policy; Cosmos3 Edge T2I/T2V/I2V/action | `nvidia/Cosmos3-Nano`, `nvidia/Cosmos3-Super`, `nvidia/Cosmos3-Edge` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | |
|
|
||
| half = frequency_embedding_size // 2 | ||
| freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=target_dtype) / half) | ||
| freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32) / half) |
There was a problem hiding this comment.
Why do we change it? It seems to affect the accuracy
There was a problem hiding this comment.
I've changed it for better parity with cosmos-framework that contains source of truth for code. I verified on internal benchmarks, that quality remains very similar, but it's easier to debug when we are as close to original code as possible
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
| return hidden_states, k, v | ||
|
|
||
|
|
||
| class Cosmos3EdgeLanguageModel(nn.Module): |
There was a problem hiding this comment.
Cosmos3LanguageModel declares _layerwise_offload_blocks_attrs = ["layers"]; this sibling does not, so the Edge UND tower is skipped by layerwise CPU offload. Please add the same attribute and cover it in the offload contract test.
|
|
||
| self.is_distilled_model = False | ||
| if scheduler_class_name == COSMOS3_DISTILLED_CHECKPOINT_SCHEDULER_CLASS: | ||
| self.scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config) |
There was a problem hiding this comment.
FlowMatchEulerDiscreteScheduler defaults to deterministic Euler, while Cosmos3 distilled sampling re-noises at every fixed step. Please force or validate stochastic_sampling=True here and cover an actual scheduler step.
There was a problem hiding this comment.
We store that in checkpoint, but added forcing, tests and validation of other parameters
| if seed is None: | ||
| return | ||
| seed = int(seed) | ||
| torch.manual_seed(seed) |
There was a problem hiding this comment.
This mutates process-global RNG state for every request, and overlapping requests can interfere. Please thread the request-local generator into scheduler.step() instead.
There was a problem hiding this comment.
Fixed, note that FlowMatchEulerDiscreteScheduler doesn't respect generator in diffusers==0.38.0, it's fixed in diffusers==0.39.0 (but we should be fine for now).
| def _resolve_guidance_scale(self, sp: OmniDiffusionSamplingParams, default: float) -> float: | ||
| if self.is_distilled_model: | ||
| return 1.0 | ||
| if sp.guidance_scale_provided: |
There was a problem hiding this comment.
The new 0.0 case is not reachable through a real request: OmniDiffusionRequest.__post_init__ treats zero as omitted and overwrites it with 1.0. Please fix the sentinel handling or drop that contract.
There was a problem hiding this comment.
Is this comment about unittests? If so updated them
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com> Signed-off-by: y_null <y_null@qq.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Summary
This MR adds support for the upcoming Cosmos3 Edge and distilled models and
improves parity with the original implementation in
cosmos-framework.Cosmos3 Edge
Cosmos3EdgeVFMTransformer, a Nemotron-based transformer architectureused by Cosmos3 Edge models.
backbone_typefield fromtransformer/config.json.Distilled models
FlowMatchEulerDiscreteSchedulerin the scheduler configuration.guidance_scale=1.0for distilled inference.Pipeline compatibility
Cosmos3OmniPipelineas an alias forCosmos3OmniDiffusersPipelineto support the new checkpoint configuration.Parity with
cosmos-frameworkTimestepEmbedderfrequencies in FP32.UniPCMultistepSchedulerapproximation with thenative
FlowUniPCMultistepSchedulerimplementation.vLLM Version:
0.25
vLLM-Omni Commit:
Top of tree of this MR
Test Result
BEFORE SUBMITTING: read CONTRIBUTING.md and run the precheck-pr skill with the code agent for a self-check against project conventions.
(anything written below this line will be removed by GitHub Actions)