Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

revert last 2

roryclear0d036012862a
diff --git a/utils/model.py b/utils/model.py
index bf94987..bc7fe59 100644
--- a/utils/model.py
+++ b/utils/model.py
@@ -6,9 +6,9 @@ from tinygrad.llm.gguf import gguf_load
from tinygrad.uop.ops import resolve
@functools.cache
-def precompute_freqs_cis(dim: int, end: int, theta: float = 10000.0) -> Tensor:
- freqs = 1.0 / (theta ** (Tensor.arange(0, dim)[:(dim // 2)] / dim))
- freqs = Tensor.arange(end).unsqueeze(dim=1) * freqs.unsqueeze(dim=0)
+def precompute_freqs_cis(dim: int, end: int, theta: float = 10000.0, device:str|None=None) -> Tensor:
+ freqs = 1.0 / (theta ** (Tensor.arange(0, dim, 2, device=device)[:(dim // 2)] / dim))
+ freqs = Tensor.arange(end, device=device).unsqueeze(dim=1) * freqs.unsqueeze(dim=0)
return freqs.cos().cat(freqs.sin(), dim=-1).contiguous()
class ExpertWeights:
@@ -187,7 +187,7 @@ class TransformerBlock(FFNBlock):
if not hasattr(self, "cache_kv"):
# TODO: how is the dtype of this determined?
self.cache_kv = Tensor.empty(2, x.shape[0], self.config.n_kv_heads, self.config.max_context, self.config.head_dim, device=x.device)
- self.freqs_cis = precompute_freqs_cis(self.config.rope_dim, self.config.max_context, self.config.rope_theta)
+ self.freqs_cis = precompute_freqs_cis(self.config.rope_dim, self.config.max_context, self.config.rope_theta, device=x.device)
class MLATransformerBlock(FFNBlock):
def __init__(self, config:TransformerConfig):