Add NVIDIA Cosmos 3 Edge: reasoner (VLM surface) + generative world model#2675
Add NVIDIA Cosmos 3 Edge: reasoner (VLM surface) + generative world model#2675probicheaux wants to merge 9 commits into
Conversation
Adds the reasoner tower of NVIDIA Cosmos 3 Edge as a core model: - inference_models: Cosmos3EdgeReasoner (prompt/prompt_video following the standard VLM contract) + registry entry (cosmos-3-edge, vlm, hugging-face) - serving bridge: InferenceModelsCosmos3ReasonerAdapter registered in ROBOFLOW_MODEL_TYPES (inference_models-only, gated on COSMOS3_ENABLED and USE_INFERENCE_MODELS), served via the existing /infer/lmm route - workflow block: roboflow_core/cosmos3_edge@v1 emitting language_model_output, GPU-gated via get_restrictions() - mocked unit tests for the model class and the block manifest; changelog The generative world-model tower (image-to-video, dynamics, anomaly generation) ships separately. Weight packaging/registration is pending with the Inference Core team. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Generative tower of Cosmos 3 Edge, stacked on the reasoner branch: - Cosmos3EdgeWorldModel (cosmos-3-edge-world, world-model, custom backend): generate_video, start_rollout/forward_dynamics with explicit opaque state_dict threading (raises on missing session), inverse_dynamics returning a Cosmos3ActionTrajectory. Policy mode deferred by design. - New WORLD_MODEL_TASK constant. - Runtime seam: packages ship a self-contained runtime module imported via import_class_from_file (moondream2 precedent) - NVIDIA's cosmos stack is not an inference_models dependency. - Mocked unit tests; changelog. Follow-ups: HTTP entities + workflow blocks for frame/action outputs, policy mode, weight packaging with the Inference Core team. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- development/cosmos3/pull_weights.py: downloads the nvidia/Cosmos3-Edge snapshot once (the towers share MoT weight shards) and materializes the cosmos-3-edge (reasoner) and cosmos-3-edge-world (generator) package layouts via hardlinks. Supports --snapshot-dir reuse, --runtime-module injection for the world package, and --gcs-dest mirroring (gcloud/gsutil) for uploading the same layout to GCS. - development/cosmos3/reference_generator_runtime.py: the self-contained runtime module shipped inside the world package, backed by diffusers' Cosmos3OmniPipeline (image-to-video working; dynamics methods raise until the action-conditioning path is wired). Verified on an L4 with real weights: reasoner prompt() 8.6s/4.9GB VRAM, world generate_video() 13 frames @416x240 in 6.6s/9.4GB peak. Requires transformers and diffusers git-main builds (cosmos3_edge model type / Cosmos3OmniTransformer are newer than current releases). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
👋 Thanks for the pull request! Here is how automated Claude review works here, so you spend credits (and reviewer time) wisely. 🚦 This PR is marked Ready for review, so automated Claude review will run — and every pass spends real credits. Warning 💸 The Claude reviewer bills in credits, not vibesAutomated review spins up a real agent that reads real code and spends real credits on every pass. It is glad to help — but it is not a rubber duck, a linter you poke in a loop, or a substitute for reading the contributing guide. Treat it like an expensive senior reviewer whose time you booked, and show up prepared. Draft when unsure, Ready when you mean it:
However you get there, arrive prepared:
Reviews are not free. A draft costs nothing to review; a Ready PR is a promise that it is worth reviewing.
|
…integration tests - Reference runtime now implements forward dynamics (chunked rollout via CosmosActionCondition, conditioning each chunk on the previous chunk's final frame carried in the session dict) and inverse dynamics (action inference from observation video). action_space maps to the pipeline's embodiment domain_name; generation kwargs (seed, num_inference_steps) pass through. - Cosmos3EdgeWorldModel threads action_space/session options through to the runtime; inverse_dynamics now takes a required action_space. - Integration tests (slow, env-gated local package dirs) for reasoner prompt, image-to-video, and two-chunk forward-dynamics session threading. Validated on L4 against NVIDIA's example assets: FD 2x16 UMI chunks -> 34 frames @256p in 6.6s; ID on the AV example reproduces the published Edge output at 0.945 correlation (MAE 0.10, 15 denoise steps). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- black on inference/models/utils.py, isort on core_steps/loader.py - inference/models/cosmos3/LICENSE.txt (OpenMDW-1.1 full text) and README.md license-table row, satisfying the validate-models check Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the patterns used across the maintained VLM implementations
(glm_ocr, gemma4, qwen3_5, smolvlm):
- flash-attention-2 selection on Ampere+ CUDA with Jetson guard, eager
fallback (glm_ocr pattern)
- device-aware dtype resolution (bf16 if supported, fp16 on older CUDA,
fp32 on CPU) instead of hardcoded bf16
- cast floating-point processor outputs to the model dtype in
pre_process_generation; keep integer tensors intact
- max_new_tokens=None resolves to the configured default in generate()
- quantization_config passthrough in from_pretrained; pad-token fallback
to eos in generate(); __call__ alias for prompt()
- thinking-aware post-processing (qwen3_5 pattern): the chat template
opens the reasoning block in the prompt, so a bare closing </think>
appears in output - strip the block by default, or return
{thinking, answer} dicts with return_thinking=True
Verified on real weights: default prompt() now returns the clean final
answer ('blue' for a blue image) with reasoning available on request.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🤖 Claude review started at commit New commits are not auto-reviewed. Add the |
|
🤖 Claude review started at commit New commits are not auto-reviewed. Add the |
2 similar comments
|
🤖 Claude review started at commit New commits are not auto-reviewed. Add the |
|
🤖 Claude review started at commit New commits are not auto-reviewed. Add the |
|
|
||
| LMM_ENABLED = str2bool(os.getenv("LMM_ENABLED", False)) | ||
|
|
||
| COSMOS3_ENABLED = str2bool(os.getenv("COSMOS3_ENABLED", True)) |
There was a problem hiding this comment.
COSMOS3_ENABLED defaults to True, but the reasoner cannot actually load on a standard install.
With the default on (and USE_INFERENCE_MODELS), inference/models/utils.py registers ("vlm","cosmos-3-edge") / ("text-image-pairs","cosmos-3-edge") into ROBOFLOW_MODEL_TYPES. The module import chain only needs base transformers symbols (AutoModelForImageTextToText, AutoProcessor), so registration succeeds and the model/block appears available.
But loading the weights needs transformers>=5.15 and diffusers>=0.40 (per requirements/requirements.cosmos.txt and the PR notes), whereas requirements/requirements.transformers.txt caps transformers>=4.57.3,<=5.9.0, and requirements.cosmos.txt is wired into no pip extra / setup.py. So on any standard pip install inference[...], a self-hosted GPU user who runs the block in LOCAL mode will hit a runtime failure at AutoModelForImageTextToText.from_pretrained (config model_type: cosmos3_edge unknown to transformers ≤5.9), even though get_restrictions() only HARD-blocks CPU — implying local GPU is supported.
Question (IMPORTANT): is local/self-hosted execution meant to be supported at merge? If only the hosted serving image carries the right deps, consider defaulting COSMOS3_ENABLED off until the dependency releases land + an extra is wired, or otherwise surfacing a clear "dependencies missing" error rather than a bare transformers load failure. See the action-item comment.
|
|
||
| openspec*/ | ||
| opsx/ No newline at end of file | ||
| opsx/.venv-cosmos3/ |
There was a problem hiding this comment.
This replaces the previous whole-directory ignore opsx/ with only opsx/.venv-cosmos3/, so the rest of opsx/ is no longer git-ignored. If that narrowing is unintentional, files under opsx/ could now be accidentally committed. Was dropping the blanket opsx/ ignore intended? (optional)
|
⏳ This PR is ON HOLD pending your answers — the review will not advance to sign-off and the PR should not proceed to merge until the IMPORTANT questions below are resolved. Your own PR description also lists unchecked "Remaining before merge" items (weight publication + registry registration, dependency-pin → release wiring, reviewer name confirmation), which keep this open. I reviewed the shipping surfaces (workflow block IMPORTANT — please answer
Optional
Tests to add (non-blocking)
Escalation to code-owners@PawelPeczek-Roboflow @grzegorz-roboflow @dkosowski87 — decision needed on Q2 (naming/contract): this PR introduces registry- and API-visible identifiers ( Re-review is not automatic: new commits are not auto-reviewed. After answering and/or pushing changes, add the Reviewed at HEAD: 3d02838 |
📦 Release coordination (maintainers)inference-models requires a version bump for release. This PR adds two new model families to the
No Execution Engine version bump is required: this PR adds a new Workflow block (additive Note the still-open dependency item ( Reviewed at HEAD: 3d02838 |

Adds NVIDIA Cosmos 3 Edge (HF model, blog) as a core model family, in two stacked pieces:
(corresponding sdk registry PR: https://github.com/roboflow/model-registry-sdk/pull/8)
Reasoner (
cosmos-3-edge, taskvlm, backendhugging-face)Cosmos3EdgeReasonerininference_modelsfollowing the standard VLM contract (prompt(), staged pre/generate/post), plusprompt_video()for multi-frame reasoning./infer/lmmroute (no new HTTP surface), gated byCOSMOS3_ENABLED(default on; deployments that shouldn't serve it disable via env).roboflow_core/cosmos3_edge@v1emittinglanguage_model_output(chains intovlm_as_detectoretc.), GPU-gated viaget_restrictions().Generator (
cosmos-3-edge-world, new taskworld-model, backendcustom)Cosmos3EdgeWorldModel:generate_video()(image-to-video),start_rollout()/forward_dynamics()with explicit opaquestate_dictthreading (raises on missing session),inverse_dynamics()returning aCosmos3ActionTrajectory(action_spaceselects the embodiment domain:umi,av,droid_lerobot, …).cosmos3_generator_runtime.pyimported viaimport_class_from_file(moondream2 precedent) — no new coreinference_modelsdependencies. Reference runtime (diffusersCosmos3OmniPipeline, all modes wired) + weight-pull tooling ininference_models/development/cosmos3/.Verified with real weights (NVIDIA L4, 24 GB)
Output-quality checks against NVIDIA's official example assets:
prompt()produces a coherent multi-step robot task plan for the official reasoning example;generate_video()produces a coherent temporal continuation of the official i2v conditioning image.-m slow).Timings / VRAM per mode (bf16, defaults = 35 denoise steps unless noted):
prompt(), single image, 256 new tokensprompt_video(), 16 frames, 256 new tokensgenerate_video(), 25 frames @ 480pgenerate_video(), 13 frames @ 240pforward_dynamics(), 16-action UMI chunk @ 256 tierinverse_dynamics(), 61-frame AV video @ 480 tierBoth towers share the MoT weight shards —
development/cosmos3/pull_weights.pydownloads one snapshot, materializes both package layouts via hardlinks, and mirrors them to GCS (--gcs-dest gs://…;--dry-runprints the exact file manifest, including the runtime module the world package must contain).Remaining before merge
pull_weights.py --towers reasoner,world --runtime-module reference_generator_runtime.py --gcs-dest gs://<bucket>/<prefix>and register both packages in the model registry (staging → production). The integration tests then switch from env-var local dirs to downloaded-package fixtures like the other suites.requirements/requirements.cosmos.txtpins transformers/diffusers to validated git SHAs becausecosmos3_edge(transformers ≥5.15) and theCosmos3OmniTransformercheckpoint format (diffusers ≥0.40) are unreleased; the repo also capstransformers<=5.9.0. When the releases land: swap to version pins, raise the cap, and wire anextras_requireentry (git URLs can't ship in pypi extras).cosmos-3-edge/cosmos-3-edge-world,WORLD_MODEL_TASK,COSMOS3_ENABLED,BackendType.CUSTOMfor the world package.Explicitly out of scope (follow-up PRs): step-wise policy mode (DROID), and an HTTP/workflow-block surface for generative outputs (
LMMInferenceResponseis text-only; frames/actions need new entities and kinds).🤖 Generated with Claude Code