summaryrefslogtreecommitdiff
path: root/model.py
diff options
context:
space:
mode:
authorVoid Agent <void@jayrup.hermes>2026-07-29 17:49:17 +0100
committerVoid Agent <void@jayrup.hermes>2026-07-29 17:49:17 +0100
commit11263aaf0a6abf035f7b1d48f3cc8bf38ad41ccf (patch)
treeeb20254330e87b276a0f7ea4cc01917507859f77 /model.py
parentdb4ec5bb3839bc5cc50d82e427848595d14b3070 (diff)
Maxwell GPU fixes: disable bf16 SDPA, force fp32
- model.py: honor config.flash flag (defaults True, False disables SDPA) - config: force dtype=float32 and flash=False for K2200 (compute 5.0) - Maxwell GPUs don't support bf16; SDPA internally uses bf16 operations
Diffstat (limited to 'model.py')
-rw-r--r--model.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/model.py b/model.py
index c698f8b..7071571 100644
--- a/model.py
+++ b/model.py
@@ -42,7 +42,8 @@ class CausalSelfAttention(nn.Module):
self.n_embd = config.n_embd
self.dropout = config.dropout
# flash attention make GPU go brrrrr but support is only in PyTorch >= 2.0
- self.flash = hasattr(torch.nn.functional, 'scaled_dot_product_attention')
+ # Maxwell GPUs (compute 5.0) don't support bf16 ops used by SDPA internals
+ self.flash = hasattr(torch.nn.functional, 'scaled_dot_product_attention') and getattr(config, 'flash', True)
if not self.flash:
print("WARNING: using slow attention. Flash Attention requires PyTorch >= 2.0")
# causal mask to ensure that attention is only applied to the left in the input sequence