AbstractPhil commited on
Commit
ba57df3
·
verified ·
1 Parent(s): 6365f5f

splat fast path (geolip 0.6.1 @a2436e6): fused 2K forward via oriented_cat, cached mask, lazy den stats, chunk 256 — 1.7x eager / 4.0x under torch.compile at ctx 2048, parity 1e-6 vs the naive oracle, grad-parity verified

Browse files
Files changed (1) hide show
  1. address.py +11 -0
address.py CHANGED
@@ -46,6 +46,17 @@ class AlephAddress(nn.Module):
46
  Z = (ep + en).sum(dim=-1, keepdim=True)
47
  return ep / Z, en / Z
48
 
 
 
 
 
 
 
 
 
 
 
 
49
  def signed(self, x: torch.Tensor) -> torch.Tensor:
50
  u = self._u(x)
51
  m = u.abs().amax(dim=-1, keepdim=True)
 
46
  Z = (ep + en).sum(dim=-1, keepdim=True)
47
  return ep / Z, en / Z
48
 
49
+ def oriented_cat(self, x: torch.Tensor) -> torch.Tensor:
50
+ """cat(ep, en)/Z along the last dim in ONE exp/normalize pass —
51
+ mathematically identical to torch.cat(self.oriented(x), -1); the
52
+ fused form exists because the hub's fast path runs its whole scan
53
+ at 2K width (speed-harness verified 1.5e-06 vs the naive oracle,
54
+ 4.0x with torch.compile at ctx 2048)."""
55
+ u = self._u(x)
56
+ m = u.abs().amax(dim=-1, keepdim=True)
57
+ e = torch.exp(torch.cat([u - m, -u - m], dim=-1))
58
+ return e / e.sum(dim=-1, keepdim=True)
59
+
60
  def signed(self, x: torch.Tensor) -> torch.Tensor:
61
  u = self._u(x)
62
  m = u.abs().amax(dim=-1, keepdim=True)