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.

Merge main into this branch and resolve conflicts

Nandakishor6c5ad8030a02
diff --cc laya/agent.py
index 880b23cd,f3ca21d1..a0b0fb16
--- a/laya/agent.py
+++ b/laya/agent.py
@@@ -395,13 -409,15 +421,16 @@@ class Agent(HookRegistry)
"using %s. Treat confidence from the affected entries as uncalibrated."
% (TEMP_MIN, TEMP_MAX, ", ".join(rejected)),
RuntimeWarning, stacklevel=2)
- # Autocast policy. CUDA and MPS both support fp16/bf16 autocast and the shipped
+ # Autocast policy. CUDA, MPS and XPU all support fp16/bf16 autocast and the shipped
- # checkpoints are trained in reduced precision. CPU bf16 is only a win on hardware with
- # native BF16, so it stays opt-in via LAYA_CPU_AMP=bf16. MPS fp16 is slower than fp32 on
+ # checkpoints are trained in reduced precision; on CUDA the checkpoint's `amp_dtype`
+ # (bf16) is the default and LAYA_CUDA_AMP=fp16|bf16 overrides it. CPU bf16 is only a win
+ # on hardware with native BF16, so it stays opt-in via LAYA_CPU_AMP=bf16. MPS fp16 is slower than fp32 on
# a single small row (autocast overhead dominates) and only wins once the batch has
# several rows, so it is gated per call by `mps_amp_min_rows` (default 5, override with
- # LAYA_MPS_AMP_MIN_ROWS) rather than enabled unconditionally.
+ # LAYA_MPS_AMP_MIN_ROWS) rather than enabled unconditionally. XPU autocast supports
+ # bf16/fp16 only, and entering it on a torch build without an XPU autocast backend
+ # raises on every predict (the failure #273 fixed for MPS), so it is only enabled on
+ # builds that have one.
self.dtype = torch.float32
self.amp_enabled = False
self.mps_amp_min_rows = _mps_amp_min_rows()