Skip to content

Add Cosmos3 Edge and Distilled checkpoints support - #5001

Merged
ywang96 merged 13 commits into
vllm-project:mainfrom
bastefaniak:bstefaniak/add-cosmos3-edge
Jul 16, 2026
Merged

ywang96 merged 13 commits into
vllm-project:mainfrom
bastefaniak:bstefaniak/add-cosmos3-edge

Conversation

@bastefaniak

@bastefaniak bastefaniak commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Adds Cosmos3EdgeVFMTransformer, a Nemotron-based transformer architecture
    used by Cosmos3 Edge models.
  • Selects the Edge transformer using the backbone_type field from
    transformer/config.json.

Distilled models

  • Distilled checkpoints differ from regular one only by scheduler used, detects them from FlowMatchEulerDiscreteScheduler in the scheduler configuration.
  • Forces guidance_scale=1.0 for distilled inference.

Pipeline compatibility

  • Registers Cosmos3OmniPipeline as an alias for
    Cosmos3OmniDiffusersPipeline to support the new checkpoint configuration.

Parity with cosmos-framework

  • Generates TimestepEmbedder frequencies in FP32.
  • Loads JSON prompts and updates their metadata from request parameters.
  • Replaces the previous UniPCMultistepScheduler approximation with the
    native FlowUniPCMultistepScheduler implementation.

Note: The regression reported in
#4627 was not caused by
the scheduler change. It was caused by the video-generation default
flow_shift being 1.0; the default is now 10.0.

vLLM Version:
0.25

vLLM-Omni Commit:
Top of tree of this MR

Test Result

python3 -m pytest -q   tests/diffusion/models/cosmos3   tests/diffusion/cache/test_cache_dit.py   tests/config/test_pipeline_registry.py   tests/model_extras/test_model_extras.py
158 passed, 22 warnings in 1.74s
pytest -s -v -m "core_model and cpu"
4185 passed, 22 skipped, 2189 deselected, 72 warnings in 266.64s (0:04:26)

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)

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>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Comment thread recipes/cosmos3/Cosmos3-Edge.md Outdated

#### Notes

- **Performance:** TBD. Checkpoint is not yet released

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next PR for updates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is for edge? if so can we rename the pipelines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new name is required by diffusers. I wanted to have both names to remain backward compatible with previously downloaded checkpoints

Comment thread docs/models/supported_models.md Outdated
| `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` | ✅︎ | ✅︎ | ✅︎ | ✅︎ |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Cosmos3-Edge from docs, will add in followup PR when checkpoint is released

Comment thread recipes/cosmos3/Cosmos3-Edge.md Outdated

#### Notes

- **Performance:** TBD. Checkpoint is not yet released

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be fine, if I removed docs changes and created followup PR when checkpoint is oficially released?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Cosmos3-Edge from docs, will add in followup PR when checkpoint is released

@Gaohan123 Gaohan123 added this to the v0.26.0 milestone Jul 13, 2026
Comment thread docs/models/supported_models.md Outdated
| `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` | ✅︎ | ✅︎ | ✅︎ | ✅︎ |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so


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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we change it? It seems to affect the accuracy

@bastefaniak bastefaniak Jul 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

return hidden_states, k, v


class Cosmos3EdgeLanguageModel(nn.Module):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


self.is_distilled_model = False
if scheduler_class_name == COSMOS3_DISTILLED_CHECKPOINT_SCHEDULER_CLASS:
self.scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates process-global RNG state for every request, and overlapping requests can interfere. Please thread the request-local generator into scheduler.step() instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@hsliuustc0106 hsliuustc0106 added the ready label to trigger buildkite CI label Jul 16, 2026
@ywang96
ywang96 merged commit 85f7a5b into vllm-project:main Jul 16, 2026
6 checks passed
y-null pushed a commit to y-null/vllm-omni that referenced this pull request Jul 21, 2026
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Signed-off-by: y_null <y_null@qq.com>
bowieshi pushed a commit to bowieshi/vllm-omni that referenced this pull request Jul 22, 2026
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
nagisa-kunhah pushed a commit to nagisa-kunhah/vllm-omni that referenced this pull request Jul 30, 2026
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
khairulkabir1661 pushed a commit to khairulkabir1661/vllm-omni that referenced this pull request Sep 25, 2026
Signed-off-by: Bartosz Stefaniak <bstefaniak@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants