From 2b582c2084266358cfe1b91c249faf739460ed0d Mon Sep 17 00:00:00 2001 From: "Jha, Gopi Krishna" Date: Wed, 30 Sep 2026 10:28:56 +0530 Subject: [PATCH] Enable Intel XPU support for Cosmos3-Edge --- cookbooks/cosmos3/README.md | 25 ++++++++++++++++++- .../cosmos3/generator/audiovisual/README.md | 7 ++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/cookbooks/cosmos3/README.md b/cookbooks/cosmos3/README.md index 9dd21aa5..e631d311 100644 --- a/cookbooks/cosmos3/README.md +++ b/cookbooks/cosmos3/README.md @@ -19,7 +19,8 @@ backend you want to run and follow that one section. ## Prerequisites -- Linux with NVIDIA GPU access. +- Linux with NVIDIA GPU access, or an Intel GPU supported by PyTorch XPU for + the Diffusers backend. - [`uv`](https://docs.astral.sh/uv/getting-started/installation/), `git`, and `git-lfs` installed. - Hugging Face access to the gated Cosmos3 model repos. Generator also requires access to the gated @@ -165,6 +166,28 @@ uv pip install --torch-backend=cu130 \ transformers ``` +For Intel GPUs supported by PyTorch XPU, use the `xpu` Torch backend instead: + +```bash +uv venv --python 3.13 --seed --managed-python +source .venv/bin/activate + +uv pip install --torch-backend=xpu \ + "diffusers @ git+https://github.com/huggingface/diffusers.git" \ + accelerate \ + av \ + cosmos_guardrail \ + huggingface_hub \ + imageio \ + imageio-ffmpeg \ + torch \ + torchvision \ + transformers +``` + +The Intel XPU path is supported by the Diffusers Cosmos3-Edge generator. The +other backends in this guide retain their documented NVIDIA GPU requirements. + ## TensorRT-LLM Generator OpenAI-compatible **VisualGen** server for Generator audiovisual text-to-image, diff --git a/cookbooks/cosmos3/generator/audiovisual/README.md b/cookbooks/cosmos3/generator/audiovisual/README.md index 627275a1..5c1778cf 100644 --- a/cookbooks/cosmos3/generator/audiovisual/README.md +++ b/cookbooks/cosmos3/generator/audiovisual/README.md @@ -118,10 +118,12 @@ from diffusers.utils import export_to_video prompt = json.load(open("assets/prompts/text2video/robot_kitchen.json")) negative = json.load(open("assets/negative_prompts/text2video/neg_prompt.json")) +device = "xpu" if torch.xpu.is_available() else "cuda" pipe = Cosmos3OmniPipeline.from_pretrained( - "nvidia/Cosmos3-Nano", torch_dtype=torch.bfloat16, device_map="cuda" + "nvidia/Cosmos3-Nano", torch_dtype=torch.bfloat16 ) +pipe.to(device) pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=10.0) result = pipe( @@ -137,7 +139,7 @@ result = pipe( enable_sound=False, add_resolution_template=False, add_duration_template=False, - generator=torch.Generator(device="cuda").manual_seed(1234), + generator=torch.Generator(device=device).manual_seed(1234), ) export_to_video(result.video, "/tmp/cosmos3_t2v_diffusers.mp4", fps=24) ``` @@ -148,6 +150,7 @@ To run **Cosmos3-Super** instead, load the larger checkpoint: To run **Cosmos3-Edge** instead, load `nvidia/Cosmos3-Edge` and use its single-GPU, no-audio settings: `height=480`, `width=832`, `num_frames=121`, `num_inference_steps=20`, `guidance_scale=5.0`, and `flow_shift=8.0`. +The Diffusers device selection above supports both CUDA and Intel XPU devices. ### Notebook walkthrough