aaronkazah commited on
Commit
d9d4624
·
verified ·
1 Parent(s): 59b8a87

Add Torch flex attention endpoint compatibility shim

Browse files
Files changed (1) hide show
  1. lagunavision/backbones/hf_causal.py +11 -0
lagunavision/backbones/hf_causal.py CHANGED
@@ -83,6 +83,17 @@ def _install_torch_compat_shims() -> None:
83
  except Exception:
84
  pass
85
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  def _install_huggingface_hub_dataclasses_shim() -> None:
88
  """Provide compatibility for Laguna remote code on HF Endpoint runtimes."""
 
83
  except Exception:
84
  pass
85
 
86
+ try:
87
+ import torch.nn.attention.flex_attention as flex_attention
88
+
89
+ if not hasattr(flex_attention, "AuxRequest"):
90
+ class AuxRequest: # noqa: N801 - mirrors PyTorch internal name
91
+ pass
92
+
93
+ flex_attention.AuxRequest = AuxRequest
94
+ except Exception:
95
+ pass
96
+
97
 
98
  def _install_huggingface_hub_dataclasses_shim() -> None:
99
  """Provide compatibility for Laguna remote code on HF Endpoint runtimes."""