/* Spotlight Memory demo — synthetic dataset + exact CPU reference. * * Mirrors spotlight/memory.py at chunk == 1 (the exact per-token recurrence): * * a = 0.5 * G * (1 + tanh(u)) address in (0, G) * b(t) = cos^2(pi t / 3) for |t| < 3/2 else 0 1D cos^2 bump * phi_z(x) = b(x - z) / sqrt(sum_j b(x - j)^2) 3 nearest cells * c = floor(x + 0.5), z in c + {-1, 0, 1} * w_2d = phi_zx(ax) * phi_zy(ay) 9 cells * q2, k2 = L2-normalised content, with a constant 1 appended (dim dk + 1) * beta = sigmoid(.) * read o_t = sum_j wq_j * (S[cell_j]^T q2_t) * write S[cell_j] += w_j * beta_t * (v_t - S[cell_j] k2_t) k2_t^T * * The cell state buffer is laid out head-outermost, padded lattice N = G + 3: * cell id = (h * N + py) * N + px px, py in [0, N) * slot = cell id * (DK + 1) * DV + d * DV + dv * * Loaded as a classic