← back to Exo
run realize on the result in tinygrad
e616d4e86bce5c4ac638ef1c927f4d262a33afa0 · 2024-09-05 17:28:21 +0100 · Alex Cheema
Files touched
M exo/inference/tinygrad/inference.py
Diff
commit e616d4e86bce5c4ac638ef1c927f4d262a33afa0
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Thu Sep 5 17:28:21 2024 +0100
run realize on the result in tinygrad
---
exo/inference/tinygrad/inference.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/exo/inference/tinygrad/inference.py b/exo/inference/tinygrad/inference.py
index 63519488..55c25739 100644
--- a/exo/inference/tinygrad/inference.py
+++ b/exo/inference/tinygrad/inference.py
@@ -64,7 +64,7 @@ class TinygradDynamicShardInferenceEngine(InferenceEngine):
n_captured_toks = json.loads(inference_state or "{}").get("n_captured_toks", 0)
toks = await asyncio.get_event_loop().run_in_executor(self.executor, self.tokenizer.encode, prompt)
- h = await asyncio.get_event_loop().run_in_executor(self.executor, self.model, Tensor([toks]), start_pos, TEMPERATURE)
+ h = await asyncio.get_event_loop().run_in_executor(self.executor, lambda: self.model(Tensor([toks]), start_pos, TEMPERATURE).realize())
if h.shape == (1,):
start_pos += len(toks)
@@ -80,7 +80,7 @@ class TinygradDynamicShardInferenceEngine(InferenceEngine):
start_pos = json.loads(inference_state or "{}").get("start_pos", 0)
n_captured_toks = json.loads(inference_state or "{}").get("n_captured_toks", 0)
- h = await asyncio.get_event_loop().run_in_executor(self.executor, self.model, Tensor(input_data), start_pos, TEMPERATURE)
+ h = await asyncio.get_event_loop().run_in_executor(self.executor, lambda: self.model(Tensor(input_data), start_pos, TEMPERATURE).realize())
if h.shape == (1,):
start_pos += n_captured_toks
← 9345684b closely match prev impl mlx non blocking
·
back to Exo
·
simplify mlx non blocking 874886ab →