lamba_cpu: cuda-guvenli (GQACPU._rope arange + Mamba3CPU.forward zeros device=)
Browse files- code/kod/lamba_cpu.py +5 -5
code/kod/lamba_cpu.py
CHANGED
|
@@ -104,10 +104,10 @@ class Mamba3CPU(nn.Module):
|
|
| 104 |
gamma = trap * DT
|
| 105 |
|
| 106 |
# KALİBRE: angle birikimi (işaret/dt-ölçeği) — ilk tahmin: cum += DT·angles
|
| 107 |
-
h = torch.zeros(B, H, P, S) # ssm_state (V,QK) = (P,S)
|
| 108 |
-
x_prev = torch.zeros(B, H, P)
|
| 109 |
-
Bk_prev = torch.zeros(B, H, S)
|
| 110 |
-
cum = torch.zeros(B, H, self.n_ang)
|
| 111 |
ys = []
|
| 112 |
for t in range(L):
|
| 113 |
# fork: angle = angle_state + tanh(angle_proj)·DT·π (mamba3_mimo_rotary_step referans)
|
|
@@ -182,7 +182,7 @@ class GQACPU(nn.Module):
|
|
| 182 |
self.register_buffer("inv", 1.0 / (base ** (torch.arange(0, self.hd, 2).float() / self.hd)), persistent=False)
|
| 183 |
|
| 184 |
def _rope(self, x, T):
|
| 185 |
-
f = torch.outer(torch.arange(T).float(), self.inv); e = torch.cat((f, f), -1)
|
| 186 |
return (x * e.cos()[None, None] + _rot_half(x) * e.sin()[None, None]).to(x.dtype)
|
| 187 |
|
| 188 |
def forward(self, x):
|
|
|
|
| 104 |
gamma = trap * DT
|
| 105 |
|
| 106 |
# KALİBRE: angle birikimi (işaret/dt-ölçeği) — ilk tahmin: cum += DT·angles
|
| 107 |
+
h = torch.zeros(B, H, P, S, device=u.device) # ssm_state (V,QK) = (P,S)
|
| 108 |
+
x_prev = torch.zeros(B, H, P, device=u.device)
|
| 109 |
+
Bk_prev = torch.zeros(B, H, S, device=u.device)
|
| 110 |
+
cum = torch.zeros(B, H, self.n_ang, device=u.device)
|
| 111 |
ys = []
|
| 112 |
for t in range(L):
|
| 113 |
# fork: angle = angle_state + tanh(angle_proj)·DT·π (mamba3_mimo_rotary_step referans)
|
|
|
|
| 182 |
self.register_buffer("inv", 1.0 / (base ** (torch.arange(0, self.hd, 2).float() / self.hd)), persistent=False)
|
| 183 |
|
| 184 |
def _rope(self, x, T):
|
| 185 |
+
f = torch.outer(torch.arange(T, device=x.device).float(), self.inv); e = torch.cat((f, f), -1)
|
| 186 |
return (x * e.cos()[None, None] + _rot_half(x) * e.sin()[None, None]).to(x.dtype)
|
| 187 |
|
| 188 |
def forward(self, x):
|