Instructions to use nvidia/Cosmos3-Super-Image2Video-4Step with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Cosmos
How to use nvidia/Cosmos3-Super-Image2Video-4Step with Cosmos:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add SGLang usage section to the Cosmos3-Super-Image2Video-4Step model card
#23
by majchrow - opened
README.md
CHANGED
|
@@ -9,6 +9,8 @@ tags:
|
|
| 9 |
- cosmos
|
| 10 |
- cosmos3
|
| 11 |
- vllm-omni
|
|
|
|
|
|
|
| 12 |
- image-to-video
|
| 13 |
- video-generation
|
| 14 |
---
|
|
@@ -196,6 +198,7 @@ Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated sys
|
|
| 196 |
|
| 197 |
- [PyTorch](https://github.com/nvidia/cosmos3)
|
| 198 |
- [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
|
|
|
| 199 |
|
| 200 |
**Supported Hardware Microarchitecture Compatibility:**
|
| 201 |
|
|
@@ -504,6 +507,64 @@ python scripts/upsample_prompt.py \
|
|
| 504 |
--output-path scripts/upsampled.json
|
| 505 |
```
|
| 506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
## Limitations
|
| 508 |
|
| 509 |
Cosmos3 may produce imperfect outputs in challenging scenarios. Generation artifacts include temporal inconsistency, unstable camera or object motion, imprecise physical interactions, inaccurate audio-video synchronization, and action-state drift — especially in long-horizon or high-resolution outputs. Reasoning may also be incorrect: object states, causal relationships, spatial geometry, temporal ordering, agent intent, and future outcomes can be misinferred, and complex or long-context inputs may yield hallucinated entities, inconsistent interpretations, or implausible predictions. Because the model lacks an explicit physics simulator, 3D geometry, 4D space-time evolution, object permanence, contact dynamics, and physical laws are only approximated — producing artifacts such as disappearing or morphing objects, unrealistic collisions, and physically implausible motions. Quality further degrades in out-of-distribution environments, safety-critical edge cases, and domains underrepresented in training.
|
|
@@ -512,7 +573,7 @@ Cosmos3 outputs should not be treated as physically accurate simulation, reliabl
|
|
| 512 |
|
| 513 |
## Inference
|
| 514 |
|
| 515 |
-
**Acceleration Engine:** [PyTorch](https://pytorch.org/), [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
| 516 |
|
| 517 |
**Test Hardware:** RTX PRO 6000, H20, H100, H200, B200
|
| 518 |
|
|
|
|
| 9 |
- cosmos
|
| 10 |
- cosmos3
|
| 11 |
- vllm-omni
|
| 12 |
+
- sglang
|
| 13 |
+
- sglang-diffusion
|
| 14 |
- image-to-video
|
| 15 |
- video-generation
|
| 16 |
---
|
|
|
|
| 198 |
|
| 199 |
- [PyTorch](https://github.com/nvidia/cosmos3)
|
| 200 |
- [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
| 201 |
+
- [SGLang](https://github.com/sgl-project/sglang)
|
| 202 |
|
| 203 |
**Supported Hardware Microarchitecture Compatibility:**
|
| 204 |
|
|
|
|
| 507 |
--output-path scripts/upsampled.json
|
| 508 |
```
|
| 509 |
|
| 510 |
+
## Usage: Run Inference with SGLang
|
| 511 |
+
|
| 512 |
+
[SGLang Diffusion](https://docs.sglang.io/docs/sglang-diffusion/index) can serve `nvidia/Cosmos3-Super-Image2Video-4Step` through an OpenAI-compatible video generation endpoint. Install SGLang from the main branch with diffusion dependencies, then start the server:
|
| 513 |
+
|
| 514 |
+
```bash
|
| 515 |
+
git clone --branch main https://github.com/sgl-project/sglang.git
|
| 516 |
+
cd sglang
|
| 517 |
+
pip install -e "python[diffusion]"
|
| 518 |
+
pip install "cosmos-guardrail==0.3.1"
|
| 519 |
+
|
| 520 |
+
sglang serve \
|
| 521 |
+
--model-path nvidia/Cosmos3-Super-Image2Video-4Step \
|
| 522 |
+
--num-gpus 4
|
| 523 |
+
```
|
| 524 |
+
|
| 525 |
+
Cosmos 3 support in SGLang Diffusion currently requires the SGLang main branch. Switch to a stable SGLang release once Cosmos 3 support is included there.
|
| 526 |
+
|
| 527 |
+
The 64B transformer is roughly 128 GB in BF16. Sequence and classifier-free-guidance parallelism divide activations rather than weights, so every GPU still holds a full copy of the model. On devices with less memory, such as H100-class GPUs, shard the weights across GPUs with `--use-fsdp-inference`, or stream them layer by layer with `--dit-layerwise-offload`:
|
| 528 |
+
|
| 529 |
+
```bash
|
| 530 |
+
sglang serve \
|
| 531 |
+
--model-path nvidia/Cosmos3-Super-Image2Video-4Step \
|
| 532 |
+
--num-gpus 4 \
|
| 533 |
+
--use-fsdp-inference true
|
| 534 |
+
```
|
| 535 |
+
|
| 536 |
+
Layerwise offload keeps the transformer in pinned host memory and prefetches each layer as it is needed, so it needs roughly 128 GB of free system RAM in addition to the GPU, and it also works on a single GPU.
|
| 537 |
+
|
| 538 |
+
`Cosmos3-Super-Image2Video-4Step` uses a fixed 4-step distilled schedule. SGLang detects the distilled checkpoint from `scheduler/scheduler_config.json` and drives the sampler directly from `fixed_step_sampler_config.t_list`, so `num_inference_steps` and `flow_shift` are ignored for this model and `guidance_scale` is forced to `1.0`.
|
| 539 |
+
|
| 540 |
+
Example image-to-video request. The video endpoint is asynchronous: submit the job, poll until it completes, then download the result. The example below uses 480p generation (`832x480` at 16:9), the recommended setting for this distilled I2V checkpoint.
|
| 541 |
+
|
| 542 |
+
```bash
|
| 543 |
+
job_id=$(curl -sS -X POST http://localhost:30000/v1/videos \
|
| 544 |
+
--form-string "prompt=A small warehouse robot moves a blue box across a clean floor." \
|
| 545 |
+
--form-string "negative_prompt=blurry, distorted, low quality" \
|
| 546 |
+
--form-string "size=832x480" \
|
| 547 |
+
--form-string "num_frames=189" \
|
| 548 |
+
--form-string "fps=24" \
|
| 549 |
+
--form-string "seed=42" \
|
| 550 |
+
--form-string 'extra_params={"guardrails":true,"use_resolution_template":false,"use_duration_template":false}' \
|
| 551 |
+
-F "input_reference=@input.png" \
|
| 552 |
+
| python -c 'import json, sys; print(json.load(sys.stdin)["id"])')
|
| 553 |
+
|
| 554 |
+
while true; do
|
| 555 |
+
status=$(curl -sS "http://localhost:30000/v1/videos/${job_id}" \
|
| 556 |
+
| python -c 'import json, sys; print(json.load(sys.stdin)["status"])')
|
| 557 |
+
[ "$status" = "completed" ] && break
|
| 558 |
+
[ "$status" = "failed" ] && exit 1
|
| 559 |
+
sleep 1
|
| 560 |
+
done
|
| 561 |
+
|
| 562 |
+
curl -sS -L "http://localhost:30000/v1/videos/${job_id}/content" \
|
| 563 |
+
-o cosmos3_i2v_4step_sglang.mp4
|
| 564 |
+
```
|
| 565 |
+
|
| 566 |
+
For complete serving instructions and request examples, see the [Cosmos3 SGLang cookbook](https://docs.sglang.io/cookbook/diffusion/Cosmos/Cosmos3).
|
| 567 |
+
|
| 568 |
## Limitations
|
| 569 |
|
| 570 |
Cosmos3 may produce imperfect outputs in challenging scenarios. Generation artifacts include temporal inconsistency, unstable camera or object motion, imprecise physical interactions, inaccurate audio-video synchronization, and action-state drift — especially in long-horizon or high-resolution outputs. Reasoning may also be incorrect: object states, causal relationships, spatial geometry, temporal ordering, agent intent, and future outcomes can be misinferred, and complex or long-context inputs may yield hallucinated entities, inconsistent interpretations, or implausible predictions. Because the model lacks an explicit physics simulator, 3D geometry, 4D space-time evolution, object permanence, contact dynamics, and physical laws are only approximated — producing artifacts such as disappearing or morphing objects, unrealistic collisions, and physically implausible motions. Quality further degrades in out-of-distribution environments, safety-critical edge cases, and domains underrepresented in training.
|
|
|
|
| 573 |
|
| 574 |
## Inference
|
| 575 |
|
| 576 |
+
**Acceleration Engine:** [PyTorch](https://pytorch.org/), [vLLM-Omni](https://github.com/vllm-project/vllm-omni), [SGLang](https://github.com/sgl-project/sglang), [SGLang Diffusion](https://docs.sglang.io/docs/sglang-diffusion/index)
|
| 577 |
|
| 578 |
**Test Hardware:** RTX PRO 6000, H20, H100, H200, B200
|
| 579 |
|