mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-30 00:06:07 +00:00
use float for softmax in llm.py (#12438)
fixed numerical issue in `CPU=1 RANGEIFY=1 python3 -m tinygrad.apps.llm`
This commit is contained in:
@@ -135,7 +135,7 @@ class Transformer:
|
||||
x = self.token_embd(tokens) # (B, T, D)
|
||||
for block in self.blk: x = block(x, start_pos)
|
||||
# TODO: add temperature
|
||||
return self.output(self.output_norm(x))[:, -1, :].softmax(-1).argmax(-1, keepdim=True)
|
||||
return self.output(self.output_norm(x))[:, -1, :].softmax(-1, dtype="float").argmax(-1, keepdim=True)
|
||||
|
||||
def __call__(self, tokens:Tensor, start_pos:int|UOp=0) -> Tensor:
|
||||
return (self.forward_jit if getenv("JIT", 1) and tokens.shape[1] == 1 and isinstance(start_pos, UOp) else self.forward)(tokens, start_pos)
|
||||
|
||||
Reference in New Issue
Block a user