Module token_overlay

Module token_overlay 

Source
Expand description

Token-overlay kernel launchers (Feature 2). Thin KernelLaunch wrappers over kernels/gb10/common/token_overlay.cu:

Argument order is in LOCKSTEP with the .cu signatures (cuLaunchKernel is type-blind). All device tables are load-time-fixed addresses; the only per-step arg is seq_slot (NULL ⇒ uniform active) — graph-capture safe.

Structs§

OverlayKernels
The four token-overlay kernels, resolved once at model construction via try_kernel (null-on-miss ⇒ the feature is silently unused rather than a hard init failure on a kernel image that predates the overlay).

Functions§

embed_overlay_routed
In-place row-replace of overridden vocab rows on the residual stream after the embed gather (BEFORE scale_embeddings). Per row r: s = seq_slot[r] (or active when NULL); s<0 skip; ids[r]>=vocab skip (no overlay entry for a token beyond the overlay’s served-vocab snapshot — CWE-125 guard); slot=slot_map_tab[s][ids[r]]; slot<0 or slot>=n_tab[s] skip; copy rows_tab[s][slot] over out[r].
embed_rowdiff
flags[r] = (max_i |base[r,i] - served[r,i]| > thresh). Grid one thread/row.
lmhead_overlay_routed
In-place recompute of overridden logit columns (BEFORE softcap). One warp per (row, j); j indexes the overridden-id slot of that row’s adapter. Picks the bf16 or f32 logits kernel per is_fp32.