Skip to content

Commit 8bebb07

Browse files
Replaced the dev environment with a task; improved configuration (uv, cache), single/multiple gpus supports; also added more details; added the example into the docs.
1 parent dbb2d55 commit 8bebb07

File tree

6 files changed

+190
-26
lines changed

6 files changed

+190
-26
lines changed

docs/examples.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,22 @@ hide:
230230
</a>
231231
</div>
232232

233+
## Models
234+
235+
<div class="tx-landing__highlights_grid">
236+
<a href="/examples/models/wan22"
237+
class="feature-cell sky">
238+
<h3>
239+
Wan2.2
240+
</h3>
241+
242+
<p>
243+
Use Wan2.2 to generate videos from text
244+
</p>
245+
</a>
246+
</div>
247+
248+
233249
<!-- ## Misc
234250
235251
<div class="tx-landing__highlights_grid">

docs/examples/models/wan22/index.md

Whitespace-only changes.

docs/overrides/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<a href="/examples#distributed-training" class="tx-footer__section-link">Distributed training</a>
123123
<a href="/examples#clusters" class="tx-footer__section-link">Clusters</a>
124124
<a href="/examples#inference" class="tx-footer__section-link">Inference</a>
125+
<a href="/examples#models" class="tx-footer__section-link">Models</a>
125126
</div>
126127

127128
<div class="tx-footer__section">

examples/models/wan22/.dstack.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
type: task
2+
name: wan22
3+
4+
repos:
5+
# Clones it to `/workflow` (the default working directory)
6+
- https://github.com/Wan-Video/Wan2.2.git
7+
8+
python: 3.12
9+
nvcc: true
10+
11+
env:
12+
- PROMPT="Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
13+
# Required for storing cache on a volume
14+
- UV_LINK_MODE=copy
15+
commands:
16+
# Install flash-attn
17+
- |
18+
uv pip install torch
19+
uv pip install flash-attn --no-build-isolation
20+
# Install dependencies
21+
- |
22+
uv pip install . decord librosa
23+
uv pip install "huggingface_hub[cli]"
24+
hf download Wan-AI/Wan2.2-T2V-A14B --local-dir /root/.cache/Wan2.2-T2V-A14B
25+
# Generate video
26+
- |
27+
if [ ${DSTACK_GPUS_NUM} -gt 1 ]; then
28+
torchrun \
29+
--nproc_per_node=${DSTACK_GPUS_NUM} \
30+
generate.py \
31+
--task t2v-A14B \
32+
--size 1280*720 \
33+
--ckpt_dir /root/.cache/Wan2.2-T2V-A14B \
34+
--dit_fsdp --t5_fsdp --ulysses_size ${DSTACK_GPUS_NUM} \
35+
--save_file ${DSTACK_RUN_NAME}.mp4 \
36+
--prompt "${PROMPT}"
37+
else
38+
python generate.py \
39+
--task t2v-A14B \
40+
--size 1280*720 \
41+
--ckpt_dir /root/.cache/Wan2.2-T2V-A14B \
42+
--offload_model True \
43+
--convert_model_dtype \
44+
--save_file ${DSTACK_RUN_NAME}.mp4 \
45+
--prompt "${PROMPT}"
46+
fi
47+
# Upload video
48+
- curl https://bashupload.com/ -T ./${DSTACK_RUN_NAME}.mp4
49+
50+
resources:
51+
gpu:
52+
name: [H100, H200]
53+
count: 1..8
54+
disk: 300GB
55+
56+
# Change to on-demand for disabling spot
57+
spot_policy: auto
58+
59+
volumes:
60+
# Cache pip packages and HF models
61+
- instance_path: /root/dstack-cache
62+
path: /root/.cache/
63+
optional: true

examples/models/wan22/README.md

Lines changed: 110 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Wan2.2
22

3-
[Wan2.2](https://github.com/Wan-Video/Wan2.2) is an open-source SOTA foundational video model. This example shows how to run the T2V-A14B model variant via `dstack` for text-to-video generation.
3+
[Wan2.2 :material-arrow-top-right-thin:{ .external }](https://github.com/Wan-Video/Wan2.2){:target="_blank"} is an open-source SOTA foundational video model. This example shows how to run the T2V-A14B model variant via `dstack` for text-to-video generation.
44

55
??? info "Prerequisites"
66
Once `dstack` is [installed](https://dstack.ai/docs/installation), clone the repo with examples.
@@ -14,28 +14,129 @@
1414

1515
</div>
1616

17-
Apply the [configuration](https://github.com/dstackai/dstack/blob/master/examples/models/wan22/dev-env.dstack.yml) to provision a GPU instance and run a dev environment with all the Wan2.2 dependencies installed:
17+
## Define a configuration
18+
19+
Below is a task configuration that generates a video using Wan2.2, uploads it, and provides the download link.
20+
21+
<div editor-title="examples/models/wan22/.dstack.yml">
22+
23+
```yaml
24+
type: task
25+
name: wan22
26+
27+
repos:
28+
# Clones it to `/workflow` (the default working directory)
29+
- https://github.com/Wan-Video/Wan2.2.git
30+
31+
python: 3.12
32+
nvcc: true
33+
34+
env:
35+
- PROMPT="Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
36+
# Required for storing cache on a volume
37+
- UV_LINK_MODE=copy
38+
commands:
39+
# Install flash-attn
40+
- |
41+
uv pip install torch
42+
uv pip install flash-attn --no-build-isolation
43+
# Install dependencies
44+
- |
45+
uv pip install . decord librosa
46+
uv pip install "huggingface_hub[cli]"
47+
hf download Wan-AI/Wan2.2-T2V-A14B --local-dir /root/.cache/Wan2.2-T2V-A14B
48+
# Generate video
49+
- |
50+
if [ ${DSTACK_GPUS_NUM} -gt 1 ]; then
51+
torchrun \
52+
--nproc_per_node=${DSTACK_GPUS_NUM} \
53+
generate.py \
54+
--task t2v-A14B \
55+
--size 1280*720 \
56+
--ckpt_dir /root/.cache/Wan2.2-T2V-A14B \
57+
--dit_fsdp --t5_fsdp --ulysses_size ${DSTACK_GPUS_NUM} \
58+
--save_file ${DSTACK_RUN_NAME}.mp4 \
59+
--prompt "${PROMPT}"
60+
else
61+
python generate.py \
62+
--task t2v-A14B \
63+
--size 1280*720 \
64+
--ckpt_dir /root/.cache/Wan2.2-T2V-A14B \
65+
--offload_model True \
66+
--convert_model_dtype \
67+
--save_file ${DSTACK_RUN_NAME}.mp4 \
68+
--prompt "${PROMPT}"
69+
fi
70+
# Upload video
71+
- curl https://bashupload.com/ -T ./${DSTACK_RUN_NAME}.mp4
72+
73+
resources:
74+
gpu:
75+
name: [H100, H200]
76+
count: 1..8
77+
disk: 300GB
78+
79+
# Change to on-demand for disabling spot
80+
spot_policy: auto
81+
82+
volumes:
83+
# Cache pip packages and HF models
84+
- instance_path: /root/dstack-cache
85+
path: /root/.cache/
86+
optional: true
87+
```
88+
89+
</div>
90+
91+
You can customize the
92+
93+
## Run the configuration
94+
95+
Once the configuration is ready, run `dstack apply -f <configuration file>`, and `dstack` will automatically provision the
96+
cloud resources and run the configuration.
1897

1998
<div class="termy">
2099

21100
```shell
22-
$ dstack apply -f examples/models/wan22/dev-env.dstack.yml
23-
Provisioning...
101+
$ dstack apply -f examples/models/wan22/.dstack.yml
102+
103+
# BACKEND RESOURCES INSTANCE TYPE PRICE
104+
1 datacrunch (FIN-01) cpu=30 mem=120GB disk=200GB H100:80GB:1 (spot) 1H100.80S.30V $0.99
105+
2 datacrunch (FIN-01) cpu=30 mem=120GB disk=200GB H100:80GB:1 (spot) 1H100.80S.30V $0.99
106+
3 datacrunch (FIN-02) cpu=44 mem=182GB disk=200GB H200:141GB:1 (spot) 1H200.141S.44V $0.99
107+
24108
---> 100%
109+
110+
Uploaded 1 file, 8 375 523 bytes
111+
112+
wget https://bashupload.com/fIo7l/wan22.mp4
25113
```
26114

27115
</div>
28116

29-
Then you can attach to the dev environment and generate videos:
117+
If you want you can override the default GPU, spot policy, and even the prompt via the CLI.
30118

31119
<div class="termy">
32120

33121
```shell
34-
$ torchrun --nproc_per_node=8 generate.py --task t2v-A14B --size 1280*720 --ckpt_dir ./Wan2.2-T2V-A14B --dit_fsdp --t5_fsdp --ulysses_size 8 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
122+
$ PROMPT=...
123+
$ dstack apply -f examples/models/wan22/.dstack.yml --spot --gpu H100,H200:8
35124
36-
[2025-08-26 05:41:54,911] INFO: Input prompt: Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.
37-
[2025-08-26 05:41:54,912] INFO: Creating WanT2V pipeline.
38-
[2025-08-26 05:42:50,296] INFO: loading ./Wan2.2-T2V-A14B/models_t5_umt5-xxl-enc-bf16.pth
125+
# BACKEND RESOURCES INSTANCE TYPE PRICE
126+
1 aws (us-east-2) cpu=192 mem=2048GB disk=300GB H100:80GB:8 (spot) p5.48xlarge $6.963
127+
2 datacrunch (FIN-02) cpu=176 mem=1480GB disk=300GB H100:80GB:8 (spot) 8H100.80S.176V $7.93
128+
3 datacrunch (ICE-01) cpu=176 mem=1450GB disk=300GB H200:141GB:8 (spot) 8H200.141S.176V $7.96
129+
130+
---> 100%
131+
132+
Uploaded 1 file, 8 375 523 bytes
133+
134+
wget https://bashupload.com/fIo7l/wan22.mp4
39135
```
40136

41137
</div>
138+
139+
## Source code
140+
141+
The source-code of this example can be found in
142+
[`examples/models/wan22` :material-arrow-top-right-thin:{ .external }](https://github.com/dstackai/dstack/blob/master/examples/models/wan22){:target="_blank"}.

examples/models/wan22/dev-env.dstack.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)