Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

fix(agent): remove redundant exception handling for OutOfMemoryError

Lim, Xiang Yang9631e9776305
diff --git a/laya/agent.py b/laya/agent.py
index d28040ef..a10d9c04 100644
--- a/laya/agent.py
+++ b/laya/agent.py
@@ -423,7 +423,7 @@ class Agent(HookRegistry):
fell_back_from = fell_back_why = None
try:
self.model.to(self.device).eval()
- except (RuntimeError, torch.cuda.OutOfMemoryError, torch.OutOfMemoryError) as e:
+ except (RuntimeError, torch.cuda.OutOfMemoryError) as e:
if self.device.type != "cpu":
# Record what actually went wrong: the reason matters more than the symptom,
# and it is the only place the underlying exception is ever surfaced.
@@ -633,8 +633,7 @@ class Agent(HookRegistry):
try:
return run()
- except (RuntimeError, torch.cuda.OutOfMemoryError, torch.OutOfMemoryError) as e:
- # torch.OutOfMemoryError (not the CUDA subclass) is what XPU OOMs raise
+ except (RuntimeError, torch.cuda.OutOfMemoryError) as e:
low = str(e).lower()
if self.device.type != "cpu" and ("memory" in low or "cuda" in low):
print("Warning: GPU memory exceeded during inference. Falling back to CPU...")