Skip to content

Commit c6d8353

Browse files
authored
Merge branch 'main' into fix-chrono-edit-cp
2 parents 8acc10e + 3579fda commit c6d8353

24 files changed

+1570
-68
lines changed

.github/workflows/nightly_tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
CUBLAS_WORKSPACE_CONFIG: :16:8
8585
run: |
8686
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
87-
-s -v -k "not Flax and not Onnx" \
87+
-k "not Flax and not Onnx" \
8888
--make-reports=tests_pipeline_${{ matrix.module }}_cuda \
8989
--report-log=tests_pipeline_${{ matrix.module }}_cuda.log \
9090
tests/pipelines/${{ matrix.module }}
@@ -138,7 +138,7 @@ jobs:
138138
CUBLAS_WORKSPACE_CONFIG: :16:8
139139
run: |
140140
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
141-
-s -v -k "not Flax and not Onnx" \
141+
-k "not Flax and not Onnx" \
142142
--make-reports=tests_torch_${{ matrix.module }}_cuda \
143143
--report-log=tests_torch_${{ matrix.module }}_cuda.log \
144144
tests/${{ matrix.module }}
@@ -151,7 +151,7 @@ jobs:
151151
CUBLAS_WORKSPACE_CONFIG: :16:8
152152
run: |
153153
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
154-
-s -v --make-reports=examples_torch_cuda \
154+
--make-reports=examples_torch_cuda \
155155
--report-log=examples_torch_cuda.log \
156156
examples/
157157
@@ -198,7 +198,7 @@ jobs:
198198
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
199199
RUN_COMPILE: yes
200200
run: |
201-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "compile" --make-reports=tests_torch_compile_cuda tests/
201+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "compile" --make-reports=tests_torch_compile_cuda tests/
202202
- name: Failure short reports
203203
if: ${{ failure() }}
204204
run: cat reports/tests_torch_compile_cuda_failures_short.txt
@@ -293,7 +293,7 @@ jobs:
293293
CUBLAS_WORKSPACE_CONFIG: :16:8
294294
run: |
295295
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
296-
-s -v -k "not Flax and not Onnx" \
296+
-k "not Flax and not Onnx" \
297297
--make-reports=tests_torch_minimum_version_cuda \
298298
tests/models/test_modeling_common.py \
299299
tests/pipelines/test_pipelines_common.py \
@@ -531,7 +531,7 @@ jobs:
531531
# HF_HOME: /System/Volumes/Data/mnt/cache
532532
# HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
533533
# run: |
534-
# ${CONDA_RUN} pytest -n 1 -s -v --make-reports=tests_torch_mps \
534+
# ${CONDA_RUN} pytest -n 1 --make-reports=tests_torch_mps \
535535
# --report-log=tests_torch_mps.log \
536536
# tests/
537537
# - name: Failure short reports
@@ -587,7 +587,7 @@ jobs:
587587
# HF_HOME: /System/Volumes/Data/mnt/cache
588588
# HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
589589
# run: |
590-
# ${CONDA_RUN} pytest -n 1 -s -v --make-reports=tests_torch_mps \
590+
# ${CONDA_RUN} pytest -n 1 --make-reports=tests_torch_mps \
591591
# --report-log=tests_torch_mps.log \
592592
# tests/
593593
# - name: Failure short reports

.github/workflows/pr_modular_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
if: ${{ matrix.config.framework == 'pytorch_pipelines' }}
121121
run: |
122122
pytest -n 8 --max-worker-restart=0 --dist=loadfile \
123-
-s -v -k "not Flax and not Onnx" \
123+
-k "not Flax and not Onnx" \
124124
--make-reports=tests_${{ matrix.config.report }} \
125125
tests/modular_pipelines
126126

.github/workflows/pr_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ jobs:
126126
if: ${{ matrix.config.framework == 'pytorch_pipelines' }}
127127
run: |
128128
pytest -n 8 --max-worker-restart=0 --dist=loadfile \
129-
-s -v -k "not Flax and not Onnx" \
129+
-k "not Flax and not Onnx" \
130130
--make-reports=tests_${{ matrix.config.report }} \
131131
tests/pipelines
132132
133133
- name: Run fast PyTorch Model Scheduler CPU tests
134134
if: ${{ matrix.config.framework == 'pytorch_models' }}
135135
run: |
136136
pytest -n 4 --max-worker-restart=0 --dist=loadfile \
137-
-s -v -k "not Flax and not Onnx and not Dependency" \
137+
-k "not Flax and not Onnx and not Dependency" \
138138
--make-reports=tests_${{ matrix.config.report }} \
139139
tests/models tests/schedulers tests/others
140140
@@ -255,11 +255,11 @@ jobs:
255255
- name: Run fast PyTorch LoRA tests with PEFT
256256
run: |
257257
pytest -n 4 --max-worker-restart=0 --dist=loadfile \
258-
-s -v \
258+
\
259259
--make-reports=tests_peft_main \
260260
tests/lora/
261261
pytest -n 4 --max-worker-restart=0 --dist=loadfile \
262-
-s -v \
262+
\
263263
--make-reports=tests_models_lora_peft_main \
264264
tests/models/ -k "lora"
265265

.github/workflows/pr_tests_gpu.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ jobs:
151151
run: |
152152
if [ "${{ matrix.module }}" = "ip_adapters" ]; then
153153
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
154-
-s -v -k "not Flax and not Onnx" \
154+
-k "not Flax and not Onnx" \
155155
--make-reports=tests_pipeline_${{ matrix.module }}_cuda \
156156
tests/pipelines/${{ matrix.module }}
157157
else
158158
pattern=$(cat ${{ steps.extract_tests.outputs.pattern_file }})
159159
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
160-
-s -v -k "not Flax and not Onnx and $pattern" \
160+
-k "not Flax and not Onnx and $pattern" \
161161
--make-reports=tests_pipeline_${{ matrix.module }}_cuda \
162162
tests/pipelines/${{ matrix.module }}
163163
fi
@@ -222,10 +222,10 @@ jobs:
222222
run: |
223223
pattern=$(cat ${{ steps.extract_tests.outputs.pattern_file }})
224224
if [ -z "$pattern" ]; then
225-
pytest -n 1 -sv --max-worker-restart=0 --dist=loadfile -k "not Flax and not Onnx" tests/${{ matrix.module }} \
225+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "not Flax and not Onnx" tests/${{ matrix.module }} \
226226
--make-reports=tests_torch_cuda_${{ matrix.module }}
227227
else
228-
pytest -n 1 -sv --max-worker-restart=0 --dist=loadfile -k "not Flax and not Onnx and $pattern" tests/${{ matrix.module }} \
228+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "not Flax and not Onnx and $pattern" tests/${{ matrix.module }} \
229229
--make-reports=tests_torch_cuda_${{ matrix.module }}
230230
fi
231231
@@ -274,7 +274,7 @@ jobs:
274274
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
275275
run: |
276276
uv pip install ".[training]"
277-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v --make-reports=examples_torch_cuda examples/
277+
pytest -n 1 --max-worker-restart=0 --dist=loadfile --make-reports=examples_torch_cuda examples/
278278
279279
- name: Failure short reports
280280
if: ${{ failure() }}

.github/workflows/push_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
CUBLAS_WORKSPACE_CONFIG: :16:8
8888
run: |
8989
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
90-
-s -v -k "not Flax and not Onnx" \
90+
-k "not Flax and not Onnx" \
9191
--make-reports=tests_pipeline_${{ matrix.module }}_cuda \
9292
tests/pipelines/${{ matrix.module }}
9393
- name: Failure short reports
@@ -141,7 +141,7 @@ jobs:
141141
CUBLAS_WORKSPACE_CONFIG: :16:8
142142
run: |
143143
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
144-
-s -v -k "not Flax and not Onnx" \
144+
-k "not Flax and not Onnx" \
145145
--make-reports=tests_torch_cuda_${{ matrix.module }} \
146146
tests/${{ matrix.module }}
147147
@@ -189,7 +189,7 @@ jobs:
189189
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
190190
RUN_COMPILE: yes
191191
run: |
192-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "compile" --make-reports=tests_torch_compile_cuda tests/
192+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "compile" --make-reports=tests_torch_compile_cuda tests/
193193
- name: Failure short reports
194194
if: ${{ failure() }}
195195
run: cat reports/tests_torch_compile_cuda_failures_short.txt
@@ -230,7 +230,7 @@ jobs:
230230
env:
231231
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
232232
run: |
233-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
233+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
234234
- name: Failure short reports
235235
if: ${{ failure() }}
236236
run: cat reports/tests_torch_xformers_cuda_failures_short.txt
@@ -273,7 +273,7 @@ jobs:
273273
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
274274
run: |
275275
uv pip install ".[training]"
276-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v --make-reports=examples_torch_cuda examples/
276+
pytest -n 1 --max-worker-restart=0 --dist=loadfile --make-reports=examples_torch_cuda examples/
277277
278278
- name: Failure short reports
279279
if: ${{ failure() }}

.github/workflows/push_tests_fast.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
if: ${{ matrix.config.framework == 'pytorch' }}
7171
run: |
7272
pytest -n 4 --max-worker-restart=0 --dist=loadfile \
73-
-s -v -k "not Flax and not Onnx" \
73+
-k "not Flax and not Onnx" \
7474
--make-reports=tests_${{ matrix.config.report }} \
7575
tests/
7676

.github/workflows/push_tests_mps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
HF_HOME: /System/Volumes/Data/mnt/cache
5858
HF_TOKEN: ${{ secrets.HF_TOKEN }}
5959
run: |
60-
${CONDA_RUN} python -m pytest -n 0 -s -v --make-reports=tests_torch_mps tests/
60+
${CONDA_RUN} python -m pytest -n 0 --make-reports=tests_torch_mps tests/
6161
6262
- name: Failure short reports
6363
if: ${{ failure() }}

.github/workflows/release_tests_fast.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
CUBLAS_WORKSPACE_CONFIG: :16:8
8585
run: |
8686
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
87-
-s -v -k "not Flax and not Onnx" \
87+
-k "not Flax and not Onnx" \
8888
--make-reports=tests_pipeline_${{ matrix.module }}_cuda \
8989
tests/pipelines/${{ matrix.module }}
9090
- name: Failure short reports
@@ -137,7 +137,7 @@ jobs:
137137
CUBLAS_WORKSPACE_CONFIG: :16:8
138138
run: |
139139
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
140-
-s -v -k "not Flax and not Onnx" \
140+
-k "not Flax and not Onnx" \
141141
--make-reports=tests_torch_${{ matrix.module }}_cuda \
142142
tests/${{ matrix.module }}
143143
@@ -187,7 +187,7 @@ jobs:
187187
CUBLAS_WORKSPACE_CONFIG: :16:8
188188
run: |
189189
pytest -n 1 --max-worker-restart=0 --dist=loadfile \
190-
-s -v -k "not Flax and not Onnx" \
190+
-k "not Flax and not Onnx" \
191191
--make-reports=tests_torch_minimum_cuda \
192192
tests/models/test_modeling_common.py \
193193
tests/pipelines/test_pipelines_common.py \
@@ -240,7 +240,7 @@ jobs:
240240
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
241241
RUN_COMPILE: yes
242242
run: |
243-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "compile" --make-reports=tests_torch_compile_cuda tests/
243+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "compile" --make-reports=tests_torch_compile_cuda tests/
244244
- name: Failure short reports
245245
if: ${{ failure() }}
246246
run: cat reports/tests_torch_compile_cuda_failures_short.txt
@@ -281,7 +281,7 @@ jobs:
281281
env:
282282
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
283283
run: |
284-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
284+
pytest -n 1 --max-worker-restart=0 --dist=loadfile -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
285285
- name: Failure short reports
286286
if: ${{ failure() }}
287287
run: cat reports/tests_torch_xformers_cuda_failures_short.txt
@@ -326,7 +326,7 @@ jobs:
326326
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
327327
run: |
328328
uv pip install ".[training]"
329-
pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v --make-reports=examples_torch_cuda examples/
329+
pytest -n 1 --max-worker-restart=0 --dist=loadfile --make-reports=examples_torch_cuda examples/
330330
331331
- name: Failure short reports
332332
if: ${{ failure() }}

docs/source/en/api/pipelines/sana_video.md

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License. -->
1414

15-
# SanaVideoPipeline
15+
# Sana-Video
1616

1717
<div class="flex flex-wrap space-x-1">
1818
<img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/>
@@ -37,6 +37,85 @@ Refer to [this](https://huggingface.co/collections/Efficient-Large-Model/sana-vi
3737

3838
Note: The recommended dtype mentioned is for the transformer weights. The text encoder and VAE weights must stay in `torch.bfloat16` or `torch.float32` for the model to work correctly. Please refer to the inference example below to see how to load the model with the recommended dtype.
3939

40+
41+
## Generation Pipelines
42+
43+
<hfoptions id="generation pipelines">`
44+
<hfoption id="Text-to-Video">
45+
46+
The example below demonstrates how to use the text-to-video pipeline to generate a video using a text descriptio and a starting frame.
47+
48+
```python
49+
model_id =
50+
pipe = SanaVideoPipeline.from_pretrained("Efficient-Large-Model/SANA-Video_2B_480p_diffusers", torch_dtype=torch.bfloat16)
51+
pipe.text_encoder.to(torch.bfloat16)
52+
pipe.vae.to(torch.float32)
53+
pipe.to("cuda")
54+
55+
prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
56+
negative_prompt = "A chaotic sequence with misshapen, deformed limbs in heavy motion blur, sudden disappearance, jump cuts, jerky movements, rapid shot changes, frames out of sync, inconsistent character shapes, temporal artifacts, jitter, and ghosting effects, creating a disorienting visual experience."
57+
motion_scale = 30
58+
motion_prompt = f" motion score: {motion_scale}."
59+
prompt = prompt + motion_prompt
60+
61+
video = pipe(
62+
prompt=prompt,
63+
negative_prompt=negative_prompt,
64+
height=480,
65+
width=832,
66+
frames=81,
67+
guidance_scale=6,
68+
num_inference_steps=50,
69+
generator=torch.Generator(device="cuda").manual_seed(0),
70+
).frames[0]
71+
72+
export_to_video(video, "sana_video.mp4", fps=16)
73+
```
74+
75+
</hfoption>
76+
<hfoption id="Image-to-Video">
77+
78+
The example below demonstrates how to use the image-to-video pipeline to generate a video using a text descriptio and a starting frame.
79+
80+
```python
81+
model_id = "Efficient-Large-Model/SANA-Video_2B_480p_diffusers"
82+
pipe = SanaImageToVideoPipeline.from_pretrained(
83+
model_id,
84+
torch_dtype=torch.bfloat16,
85+
)
86+
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe.scheduler.config, flow_shift=8.0)
87+
pipe.vae.to(torch.float32)
88+
pipe.text_encoder.to(torch.bfloat16)
89+
pipe.to("cuda")
90+
91+
image = load_image("https://raw.githubusercontent.com/NVlabs/Sana/refs/heads/main/asset/samples/i2v-1.png")
92+
prompt = "A woman stands against a stunning sunset backdrop, her long, wavy brown hair gently blowing in the breeze. She wears a sleeveless, light-colored blouse with a deep V-neckline, which accentuates her graceful posture. The warm hues of the setting sun cast a golden glow across her face and hair, creating a serene and ethereal atmosphere. The background features a blurred landscape with soft, rolling hills and scattered clouds, adding depth to the scene. The camera remains steady, capturing the tranquil moment from a medium close-up angle."
93+
negative_prompt = "A chaotic sequence with misshapen, deformed limbs in heavy motion blur, sudden disappearance, jump cuts, jerky movements, rapid shot changes, frames out of sync, inconsistent character shapes, temporal artifacts, jitter, and ghosting effects, creating a disorienting visual experience."
94+
motion_scale = 30
95+
motion_prompt = f" motion score: {motion_scale}."
96+
prompt = prompt + motion_prompt
97+
98+
motion_scale = 30.0
99+
100+
video = pipe(
101+
image=image,
102+
prompt=prompt,
103+
negative_prompt=negative_prompt,
104+
height=480,
105+
width=832,
106+
frames=81,
107+
guidance_scale=6,
108+
num_inference_steps=50,
109+
generator=torch.Generator(device="cuda").manual_seed(0),
110+
).frames[0]
111+
112+
export_to_video(video, "sana-i2v.mp4", fps=16)
113+
```
114+
115+
</hfoption>
116+
</hfoptions>
117+
118+
40119
## Quantization
41120

42121
Quantization helps reduce the memory requirements of very large models by storing model weights in a lower precision data type. However, quantization may have varying impact on video quality depending on the video model.
@@ -97,6 +176,13 @@ export_to_video(output, "sana-video-output.mp4", fps=16)
97176
- __call__
98177

99178

179+
## SanaImageToVideoPipeline
180+
181+
[[autodoc]] SanaImageToVideoPipeline
182+
- all
183+
- __call__
184+
185+
100186
## SanaVideoPipelineOutput
101187

102-
[[autodoc]] pipelines.sana.pipeline_sana_video.SanaVideoPipelineOutput
188+
[[autodoc]] pipelines.sana_video.pipeline_sana_video.SanaVideoPipelineOutput

scripts/convert_sana_video_to_diffusers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def main(args):
8080

8181
# scheduler
8282
flow_shift = 8.0
83+
if args.task == "i2v":
84+
assert args.scheduler_type == "flow-euler", "Scheduler type must be flow-euler for i2v task."
8385

8486
# model config
8587
layer_num = 20
@@ -312,6 +314,7 @@ def main(args):
312314
choices=["flow-dpm_solver", "flow-euler", "uni-pc"],
313315
help="Scheduler type to use.",
314316
)
317+
parser.add_argument("--task", default="t2v", type=str, required=True, help="Task to convert, t2v or i2v.")
315318
parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.")
316319
parser.add_argument("--save_full_pipeline", action="store_true", help="save all the pipeline elements in one.")
317320
parser.add_argument("--dtype", default="fp32", type=str, choices=["fp32", "fp16", "bf16"], help="Weight dtype.")

0 commit comments

Comments
 (0)