Skip to content

Commit 83da817

Browse files
authored
[Add] torch_xla support to pipeline_sana.py (#10364)
[Add] torch_xla support in pipeline_sana.py
1 parent f430a0c commit 83da817

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/diffusers/pipelines/sana/pipeline_sana.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
USE_PEFT_BACKEND,
3232
is_bs4_available,
3333
is_ftfy_available,
34+
is_torch_xla_available,
3435
logging,
3536
replace_example_docstring,
3637
scale_lora_layers,
@@ -46,6 +47,13 @@
4647
from .pipeline_output import SanaPipelineOutput
4748

4849

50+
if is_torch_xla_available():
51+
import torch_xla.core.xla_model as xm
52+
53+
XLA_AVAILABLE = True
54+
else:
55+
XLA_AVAILABLE = False
56+
4957
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
5058

5159
if is_bs4_available():
@@ -864,6 +872,9 @@ def __call__(
864872
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
865873
progress_bar.update()
866874

875+
if XLA_AVAILABLE:
876+
xm.mark_step()
877+
867878
if output_type == "latent":
868879
image = latents
869880
else:

0 commit comments

Comments
 (0)