Validate repeated learned RMSNorm functions with CPU evidence
This commit is contained in:
+7
-2
@@ -6,6 +6,7 @@ No cached decode, padding, images, generation, fused kernels or autograd.
|
||||
Full-sequence gated delta recurrence replaces the algebraically equivalent
|
||||
chunk algorithm; both are independently compared in remote tests.
|
||||
"""
|
||||
import ctypes
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
@@ -87,6 +88,7 @@ class StreamingLM:
|
||||
self.qk_inputs = {}
|
||||
self.swap_observation = None
|
||||
self.swap_pressure_windows = 0
|
||||
self.malloc_trim = getattr(ctypes.CDLL(None), 'malloc_trim', None)
|
||||
|
||||
def guard(self):
|
||||
if time.monotonic() > self.deadline:
|
||||
@@ -104,8 +106,9 @@ class StreamingLM:
|
||||
elapsed = now-self.swap_observation[0]
|
||||
rate = (count-self.swap_observation[1])*4096/elapsed
|
||||
self.swap_pressure_windows = self.swap_pressure_windows+1 if rate > 4*1024**2 else 0
|
||||
if self.swap_pressure_windows >= 3:
|
||||
raise MemoryError('Sustained host swap IO above 4 MiB/s in three observation windows')
|
||||
own_swap_kib = int(status.get('VmSwap', '0 kB').split()[0])
|
||||
if self.swap_pressure_windows >= 3 and (available < 384*1024 or own_swap_kib > 128*1024):
|
||||
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
||||
self.swap_observation = (now,count)
|
||||
if rss_kib > 512*1024 or available < 256*1024:
|
||||
raise MemoryError(f'Soft memory stop: RSS {rss_kib} KiB, available {available} KiB')
|
||||
@@ -130,6 +133,8 @@ class StreamingLM:
|
||||
result[:, start:end] = flat @ w.T
|
||||
del w
|
||||
t.evict()
|
||||
if self.malloc_trim is not None:
|
||||
self.malloc_trim(0) # Release only this process's freed temporary heap pages.
|
||||
return result.reshape(*x.shape[:-1], outdim)
|
||||
|
||||
def embedding(self, ids):
|
||||
|
||||
Reference in New Issue
Block a user