Skip to content

Add composable world-model pipelines and Cosmos3 export - #466

Open
xiaoyu-work wants to merge 11 commits into
mainfrom
xiaoyu-work/cosmos3-world-model
Open

Add composable world-model pipelines and Cosmos3 export#466
xiaoyu-work wants to merge 11 commits into
mainfrom
xiaoyu-work/cosmos3-world-model

Conversation

@xiaoyu-work

Copy link
Copy Markdown
Contributor

Introduce executable pipeline schema 1.1 with typed generated-input programs, recurrent state lifecycle, scheduler and autoregressive controls, parameterized transforms, runtime assets, and dtype/EP hints.

Implement complete Cosmos3 Omni and Edge exports with the shared MoT generator, Wan video VAE, optional AVAE audio tokenizer, domain-aware action heads, real checkpoint weight routing, CLI support, documentation, and numerical tests.

Introduce executable pipeline schema 1.1 with typed generated-input programs, recurrent state lifecycle, scheduler and autoregressive controls, parameterized transforms, runtime assets, and dtype/EP hints.

Implement complete Cosmos3 Omni and Edge exports with the shared MoT generator, Wan video VAE, optional AVAE audio tokenizer, domain-aware action heads, real checkpoint weight routing, CLI support, documentation, and numerical tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
@CLAassistant

CLAassistant commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ xiaoyu-work
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread src/mobius/_cosmos3_edge_world_model.py Dismissed
Comment thread src/mobius/_cosmos3_world_model.py Fixed
Focus the world-model guides on export commands, package contents, supported checkpoints, runtime usage, and practical options. Remove internal architecture and manifest implementation details from the user guide.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing fd69dc66c0095c

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 60 60 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 105 105 +0.0%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 60 60 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 56 56 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 94 94 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 58 58 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 54 54 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 60 60 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 56 56 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 264 264 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 126 126 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 428 428 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 166 166 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing fd69dc66c0095c

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

Add model-agnostic build, generation, and pipeline configuration for world-model exporters, plus safe shared helpers for diffusers-style checkpoint inspection and asset resolution.

Keep LLM ArchitectureConfig and every model/component implementation unchanged; Cosmos3 Omni and Edge only consume the new outer pipeline configuration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Match upstream chunk-zero temporal resampling so Cosmos3 can decode a single latent frame without running Conv on an empty temporal extent. Preserve bit-identical multi-frame behavior and add ORT/PyTorch parity coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Replace the fixed SigLIP1-style vision graph with the published packed variable-resolution SigLIP2 contract, correct block-major projection ordering, and use interleaved multimodal RoPE.

Add image/video feature routing, processor metadata, real-checkpoint numerical parity tests, and image/video understanding coverage while preserving text-only behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Describe conditioned video encoding, classifier-free guidance, prompt packing, and official Cosmos3 Edge generation recipes in pipeline.json. Ship the recommended negative prompt when available and preserve checkpoint-specific action behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Comment thread src/mobius/_cosmos3_edge_world_model.py Fixed
Comment thread src/mobius/_cosmos3_world_model_test.py Fixed
xiaoyu-work and others added 2 commits August 9, 2026 17:49
Apply the repository Ruff formatter to resolve CI formatting findings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Xiaoyu <85524621+xiaoyu-work@users.noreply.github.com>
Comment thread src/mobius/_cosmos3_world_model.py Fixed
Comment thread src/mobius/_cosmos3_world_model.py Fixed
Comment thread src/mobius/_cosmos3_world_model.py Fixed
Fix the Ruff unused-import failure after the latest world-model cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 997ab62c-69cb-4802-a5c6-fddd51bfd583
Signed-off-by: Xiaoyu Zhang <xiaoyuzhang@microsoft.com>
@xiaoyu-work

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolve conflicts between the world-model/Cosmos3 export work and main:

- --features: keep world-model alongside main's prune-lm-head ->
  prune-prefill-prefix rename (CLI, README, CHANGELOG, cli_reference).
- _diffusers_builder: keep both the component allowlist and pipeline
  component task overrides from main and the EP/trace-optimization
  plumbing from this branch, plus the corresponding tests.
- components/tasks __init__: export main's new components/tasks together
  with the Cosmos3 Edge vision and Cosmos3 audio/generator additions;
  drop the projector removed by this branch.
- _weight_loading: thread main's revision pin through the new
  iter_weight_shards generator.
- _sub_configs: drop duplicated Cosmos3-Edge vision token fields that
  main added independently.
- wan_vae_test: expect the fused Swish op introduced by main.

Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged origin/main into the branch in 6c9cddd. Conflict resolutions:

  • --features: kept world-model alongside main's prune-lm-headprune-prefill-prefix rename (CLI, README, CHANGELOG, cli_reference).
  • _diffusers_builder: kept main's component allowlist + pipeline task overrides together with this branch's execution_provider/trace_optimization plumbing (and both sets of tests).
  • components/__init__.py, tasks/__init__.py: exported main's new components/tasks plus the Cosmos3 Edge vision and Cosmos3 audio/generator additions.

Also fixed two silent (non-conflicting) merge breakages: iter_weight_shards now threads main's revision pin, and duplicated Cosmos3-Edge vision token fields in _sub_configs.py were removed. wan_vae_test.py was updated for main's fused Swish op.

ruff check/ruff format --check are clean and the fast suite passes (5103 passed, 274 skipped). The only remaining failures are pre-existing tests/arch_validation_test.py cases unrelated to this PR (transformers-version issues on gemma4/nemotron/qwen3_asr etc.).

@xiaoyu-work

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…orld-model

Signed-off-by: GitHub <noreply@github.com>

# Conflicts:
#	src/mobius/_model_package_test.py

Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged origin/main (up to fd69dc6) in 6c0095c. Only one conflict this time — duplicate import block in src/mobius/_model_package_test.py; kept both sides (threading, types from main plus unittest.mock from this branch), all three are used in the file.

Verified after the merge: ruff check and ruff format --check are clean, and the fast suite (tests/build_graph_test.py tests/cli_test.py src/) passes with 4410 passed, 61 skipped.

@xiaoyu-work
xiaoyu-work marked this pull request as ready for review August 17, 2026 23:57
@xiaoyu-work
xiaoyu-work requested review from a team and a lite review from Copilot August 17, 2026 23:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a compositional “world-model” export path in Mobius (multi-ONNX-component packages plus a pipeline manifest) and implements full Cosmos3 exports (Cosmos3-Omni and Cosmos3-Edge), including new tasks/components for the shared MoT generator, Wan video VAE, and optional Cosmos3 audio tokenizer. It also upgrades Cosmos3-Edge’s VLM export to match the published packed SigLIP2 + interleaved 3D M-RoPE contracts, and adds extensive tests + documentation for the new pipeline workflow.

Changes:

  • Add a world-model pipeline builder/registry (build_world_model, --features world-model) plus frozen configs for build + generation defaults, and diffusers-checkpoint inspection utilities.
  • Implement/compose Cosmos3 components (Cosmos3-Omni generator task, Wan VAE task, Cosmos3 audio tasks) and update Cosmos3-Edge vision-language export to the packed, variable-resolution SigLIP2 contract with dual (image/video) feature fusion.
  • Improve weight-loading for composite exports (streaming shard iteration + partial weight application + deferred constant folding) and add numerical/integration tests + docs for world-model packages.

Reviewed changes

Copilot reviewed 60 out of 61 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/cosmos3_edge_integration_test.py New integration test validating Cosmos3-Edge Reasoner (vision→fusion→decoder) numerics against a PyTorch reference with real weights.
tests/cli_test.py Add CLI tests for --features world-model dispatch and option incompatibility checks.
tests/_test_configs.py Update tiny Cosmos3-Edge-related vision settings (patch size, tokens, interleaved M-RoPE flag) used by test configs.
testdata/cases/vision-language/cosmos3-omni-nano.yaml Update case notes to distinguish VLM Reasoner validation from full world-model export flow.
src/mobius/tasks/_world_model.py Rename the single-step “world model” task to LatentDynamicsTask with backward-compatible alias.
src/mobius/tasks/_wan_vae.py New task exporting Wan VAE encoder/decoder as 5D video graphs with explicit latent normalization boundary.
src/mobius/tasks/_vision_language_3model.py Update Cosmos3EdgeVLTask to packed vision input (pixel_values, grid_thw) and dual-stream embedding (image_features, video_features).
src/mobius/tasks/_cosmos3_omni_generator.py New task building the packed denoising-step graph for the Cosmos3-Omni unified MoT transformer with gated optional heads.
src/mobius/tasks/_cosmos3_audio.py New tasks for Cosmos3 AVAE audio tokenizer: decoder-only vs full encoder+decoder builds, plus selector.
src/mobius/tasks/init.py Export/register new tasks (Cosmos3 audio, Cosmos3 Omni generator, Wan VAE, latent-dynamics) and keep world-model alias.
src/mobius/models/world_model.py Rename reference module to MLPLatentDynamicsModel, keep MLPWorldModel alias.
src/mobius/models/world_model_test.py Update tests to cover new task/config/model names and backward-compatible aliases.
src/mobius/models/cosmos.py Major Cosmos3-Edge update: packed SigLIP2 vision tower + patch merger, interleaved M-RoPE, dual image/video feature scatter, and unified-checkpoint key dropping.
src/mobius/models/cosmos_test.py Expand unit tests for Edge weight routing, packed vision I/O, token fusion behavior, and config hook extraction.
src/mobius/models/init.py Export new Cosmos3/Wan/latent-dynamics model symbols.
src/mobius/components/_multimodal.py Remove the old fixed-grid Cosmos3-Edge projector component (superseded by new packed SigLIP2 path).
src/mobius/components/_cosmos3_edge_vision.py New packed, variable-resolution SigLIP2 embeddings/tower + pixel-shuffle merger projector with exact resampling.
src/mobius/components/init.py Export new Cosmos3-Edge vision components.
src/mobius/_world_model_config.py New frozen build/generation/pipeline config dataclasses for composed world-model exporters.
src/mobius/_world_model_config_test.py Tests for world-model config immutability, dtype resolution, defaults, and manifest blocks.
src/mobius/_world_model_builder.py New builder registry and build_world_model() entry point (loads model_type from config/model_index).
src/mobius/_world_model_builder_test.py Tests for registry semantics and model_type dispatch behavior (local + pure diffusers pipeline).
src/mobius/_weight_loading.py Add iter_weight_shards() for shard-by-shard streaming; _download_weights() now merges shards then dequantizes FP8.
src/mobius/_weight_loading_test.py Tests for shard iteration, local shard ordering, and FP8 scale application after merge.
src/mobius/_model_package.py Add apply_weights_partial(), finalize_weights(), and validate_weights() to support streaming + deferred folding.
src/mobius/_model_package_test.py Tests for deferred folding semantics and missing-initializer validation.
src/mobius/_diffusers_checkpoint.py New safe, read-only diffusers checkpoint inspection (component class, shard paths, asset resolution, metadata-only weight names).
src/mobius/_diffusers_checkpoint_test.py Tests for traversal protection, metadata reading, shard ordering, and asset resolution behavior.
src/mobius/_diffusers_builder.py Extend diffusers builder for Cosmos3 Omni transformer + Wan VAE, and forward trace_optimization into component builds.
src/mobius/_diffusers_builder_test.py Update/extend tests for new diffusers-supported components and forwarded build kwargs.
src/mobius/_cosmos3_edge_world_model.py New full Cosmos3-Edge world-model exporter composing Reasoner + shared Generator + Wan VAE (+ policy metadata + vision contract metadata).
src/mobius/_cosmos3_edge_world_model_test.py Tests for Edge world-model dispatch, metadata shaping, and checkpoint validation rules.
src/mobius/_configs/per_model/_cosmos3_edge_vision.py Update Cosmos3-Edge vision hook: num_patches semantics, projector flags, token ids, temporal_patch_size=1, and interleaved M-RoPE flag.
src/mobius/_configs/_world_model.py Rename WorldModelConfigLatentDynamicsConfig with backward-compatible alias.
src/mobius/_configs/_wan_vae.py New Wan VAE config parser/validator for diffusers AutoencoderKLWan.
src/mobius/_configs/_sub_configs.py Extend VisionConfig with Edge-specific fields (use_postshuffle_norm, num_patches, mrope_interleaved).
src/mobius/_configs/_extractors.py Include mrope_interleaved in shared vision-config extraction.
src/mobius/_configs/init.py Export new config types (Cosmos3*, WanVAEConfig, LatentDynamicsConfig alias).
src/mobius/main.py Add --features world-model path with incompatibility checks and dispatch to build_world_model().
src/mobius/init.py Export new world-model APIs/types and Cosmos3/Wan components from the public API surface.
README.md Document world-model as a build feature and provide example commands.
docs/world-models.md New documentation page describing world-model export output layout and how to run packages.
docs/index.md Add world-model docs page to the documentation TOC.
docs/cli_reference.md Document --features world-model and usage examples.
docs/api/index.md Add build_world_model() to API docs index.
docs/api/build_world_model.md New API doc page for build_world_model() options and supported model_types.
CHANGELOG.md Changelog entries for pipeline schema, world-model exporters, Cosmos3-Edge fixes, and renamed latent-dynamics API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +423 to +424
scale_factor_temporal=int(raw.get("scale_factor_temporal") or 4),
scale_factor_spatial=int(raw.get("scale_factor_spatial") or 8),
Comment on lines +285 to +286
"temperal_downsample must have len(dim_mult) - 1 = "
f"{len(self.dim_mult) - 1} entries, got {len(self.temporal_downsample)}"
@rui-ren
rui-ren self-requested a review August 18, 2026 00:20
@justinchuby

justinchuby commented Aug 18, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants