someone-in-the-world Claude Sonnet 4.6 commited on
Commit
d66060a
·
1 Parent(s): 000cfc0

Fix torch.compile crash on torch.device ConstantVariable bug

Browse files

The installed PyTorch can't treat torch.device as a ConstantVariable
during tracing (hit in diffusers' get_timestep_embedding). Setting
suppress_errors=True converts the hard crash to a graph break so dynamo
falls back to eager for that subgraph while still compiling the 60
transformer blocks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +1 -0
app.py CHANGED
@@ -95,6 +95,7 @@ try:
95
  except Exception as _fa3_err:
96
  print(f"[startup] FA3 not available ({_fa3_err}), using default attention processor.", flush=True)
97
 
 
98
  print("[startup] applying torch.compile to transformer (mode=reduce-overhead)...", flush=True)
99
  pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead")
100
  print("[startup] torch.compile done.", flush=True)
 
95
  except Exception as _fa3_err:
96
  print(f"[startup] FA3 not available ({_fa3_err}), using default attention processor.", flush=True)
97
 
98
+ torch._dynamo.config.suppress_errors = True
99
  print("[startup] applying torch.compile to transformer (mode=reduce-overhead)...", flush=True)
100
  pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead")
101
  print("[startup] torch.compile done.", flush=True)