Instructions to use nvidia/Cosmos3-Super-Text2Image-4Step with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Cosmos
How to use nvidia/Cosmos3-Super-Text2Image-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-Text2Image-4Step model card
#18
by majchrow - opened
README.md
CHANGED
|
@@ -9,6 +9,8 @@ tags:
|
|
| 9 |
- cosmos
|
| 10 |
- cosmos3
|
| 11 |
- vllm-omni
|
|
|
|
|
|
|
| 12 |
- text-to-image
|
| 13 |
- image-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 |
|
|
@@ -494,6 +497,55 @@ Example output generated from `assets/example_caption.json`:
|
|
| 494 |
|
| 495 |

|
| 496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
## Limitations
|
| 498 |
|
| 499 |
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.
|
|
@@ -502,7 +554,7 @@ Cosmos3 outputs should not be treated as physically accurate simulation, reliabl
|
|
| 502 |
|
| 503 |
## Inference
|
| 504 |
|
| 505 |
-
**Acceleration Engine:** [PyTorch](https://pytorch.org/), [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
| 506 |
|
| 507 |
**Test Hardware:** RTX PRO 6000, H20, H100, H200, B200
|
| 508 |
|
|
|
|
| 9 |
- cosmos
|
| 10 |
- cosmos3
|
| 11 |
- vllm-omni
|
| 12 |
+
- sglang
|
| 13 |
+
- sglang-diffusion
|
| 14 |
- text-to-image
|
| 15 |
- image-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 |
|
|
|
|
| 497 |
|
| 498 |

|
| 499 |
|
| 500 |
+
## Usage: Run Inference with SGLang
|
| 501 |
+
|
| 502 |
+
[SGLang Diffusion](https://docs.sglang.io/docs/sglang-diffusion/index) can serve `nvidia/Cosmos3-Super-Text2Image-4Step` through an OpenAI-compatible image generation endpoint. Install SGLang from the main branch with diffusion dependencies, then start the server:
|
| 503 |
+
|
| 504 |
+
```bash
|
| 505 |
+
git clone --branch main https://github.com/sgl-project/sglang.git
|
| 506 |
+
cd sglang
|
| 507 |
+
pip install -e "python[diffusion]"
|
| 508 |
+
pip install "cosmos-guardrail==0.3.1"
|
| 509 |
+
|
| 510 |
+
sglang serve \
|
| 511 |
+
--model-path nvidia/Cosmos3-Super-Text2Image-4Step \
|
| 512 |
+
--num-gpus 4
|
| 513 |
+
```
|
| 514 |
+
|
| 515 |
+
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.
|
| 516 |
+
|
| 517 |
+
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`:
|
| 518 |
+
|
| 519 |
+
```bash
|
| 520 |
+
sglang serve \
|
| 521 |
+
--model-path nvidia/Cosmos3-Super-Text2Image-4Step \
|
| 522 |
+
--num-gpus 4 \
|
| 523 |
+
--use-fsdp-inference true
|
| 524 |
+
```
|
| 525 |
+
|
| 526 |
+
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. For text-to-image the per-request cost of streaming is proportionally larger than it is for video, so prefer weight sharding when several GPUs are available.
|
| 527 |
+
|
| 528 |
+
`Cosmos3-Super-Text2Image-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`.
|
| 529 |
+
|
| 530 |
+
Example text-to-image request:
|
| 531 |
+
|
| 532 |
+
```bash
|
| 533 |
+
curl -sS -X POST http://localhost:30000/v1/images/generations \
|
| 534 |
+
-H "Content-Type: application/json" \
|
| 535 |
+
-d '{
|
| 536 |
+
"prompt": "A warehouse robot folds a blue cloth on a clean workbench.",
|
| 537 |
+
"size": "1280x720",
|
| 538 |
+
"n": 1,
|
| 539 |
+
"seed": 0,
|
| 540 |
+
"extra_args": {
|
| 541 |
+
"use_resolution_template": false,
|
| 542 |
+
"guardrails": true
|
| 543 |
+
}
|
| 544 |
+
}'
|
| 545 |
+
```
|
| 546 |
+
|
| 547 |
+
For complete serving instructions and request examples, see the [Cosmos3 SGLang cookbook](https://docs.sglang.io/cookbook/diffusion/Cosmos/Cosmos3).
|
| 548 |
+
|
| 549 |
## Limitations
|
| 550 |
|
| 551 |
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.
|
|
|
|
| 554 |
|
| 555 |
## Inference
|
| 556 |
|
| 557 |
+
**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)
|
| 558 |
|
| 559 |
**Test Hardware:** RTX PRO 6000, H20, H100, H200, B200
|
| 560 |
|