dagloop5 commited on
Commit
e8273a7
·
verified ·
1 Parent(s): 4583bba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -6,8 +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([sys.executable, "-m", "pip", "install", "xformers==0.0.32.post2", "--no-build-isolation"], check=False)
11
 
12
  # Clone LTX-2 repo and install packages
13
  LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
@@ -73,12 +71,19 @@ from ltx_pipelines.utils.media_io import decode_audio_from_file, encode_video
73
  from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
74
  from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
75
 
76
- # Force-patch xformers attention into the LTX attention module.
77
  from ltx_core.model.transformer import attention as _attn_mod
 
78
  print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
79
  try:
80
  from xformers.ops import memory_efficient_attention as _mea
81
- _attn_mod.memory_efficient_attention = _mea
 
 
 
 
 
 
 
82
  print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
83
  except Exception as e:
84
  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
 
10
  # Clone LTX-2 repo and install packages
11
  LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
 
71
  from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
72
  from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
73
 
 
74
  from ltx_core.model.transformer import attention as _attn_mod
75
+
76
  print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
77
  try:
78
  from xformers.ops import memory_efficient_attention as _mea
79
+ from xformers.ops.fmha import cutlass
80
+
81
+ def _cutlass_memory_efficient_attention(*args, **kwargs):
82
+ # Force CUTLASS and avoid FlashAttention paths that are crashing.
83
+ kwargs["op"] = (cutlass.FwOp, cutlass.BwOp)
84
+ return _mea(*args, **kwargs)
85
+
86
+ _attn_mod.memory_efficient_attention = _cutlass_memory_efficient_attention
87
  print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
88
  except Exception as e:
89
  print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")