dagloop5 commited on
Commit
d4f9aa4
·
verified ·
1 Parent(s): 2cd6532

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -6,12 +6,6 @@ import sys
6
  os.environ["TORCH_COMPILE_DISABLE"] = "1"
7
  os.environ["TORCHDYNAMO_DISABLE"] = "1"
8
 
9
- # Install xformers for memory-efficient attention
10
- subprocess.run(
11
- [sys.executable, "-m", "pip", "install", "xformers==0.0.32.post2", "--no-build-isolation"],
12
- check=False,
13
- )
14
-
15
  # Clone LTX-2 repo and install packages
16
  LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
17
  LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
@@ -84,12 +78,19 @@ from ltx_pipelines.utils.media_io import decode_audio_from_file, encode_video
84
  from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
85
  from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
86
 
87
- # xformers attention patch (same as the outpaint app).
88
  from ltx_core.model.transformer import attention as _attn_mod
 
89
  print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
90
  try:
91
  from xformers.ops import memory_efficient_attention as _mea
92
- _attn_mod.memory_efficient_attention = _mea
 
 
 
 
 
 
 
93
  print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
94
  except Exception as e:
95
  print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")
 
6
  os.environ["TORCH_COMPILE_DISABLE"] = "1"
7
  os.environ["TORCHDYNAMO_DISABLE"] = "1"
8
 
 
 
 
 
 
 
9
  # Clone LTX-2 repo and install packages
10
  LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
11
  LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
 
78
  from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
79
  from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
80
 
 
81
  from ltx_core.model.transformer import attention as _attn_mod
82
+
83
  print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
84
  try:
85
  from xformers.ops import memory_efficient_attention as _mea
86
+ from xformers.ops.fmha import cutlass
87
+
88
+ def _cutlass_memory_efficient_attention(*args, **kwargs):
89
+ # Force CUTLASS and avoid FlashAttention paths that are crashing.
90
+ kwargs["op"] = (cutlass.FwOp, cutlass.BwOp)
91
+ return _mea(*args, **kwargs)
92
+
93
+ _attn_mod.memory_efficient_attention = _cutlass_memory_efficient_attention
94
  print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
95
  except Exception as e:
96
  print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")