Language models are trained on packed sequences: several documents back to back in one row. An SSM carries its state across the seam unless the step size is large there. Impose a large at every document start and measure how much the next document still depends on the previous one.
selective_scan_zoh(x, delta, A, B, C)
x and delta are (L, ED), A is (ED, N) with negative entries, B and C are (L, N) (shared across channels). The state has shape (ED, N) and starts at zero.y with shape (L, ED).apply_boundary_reset(delta, boundaries, reset_delta=50.0)
boundaries lists the positions where a new document starts (its first token), . Return a copy of delta with every row in boundaries replaced by reset_delta in all channels. Do not modify the input.boundary_leakage(x, delta, A, B, C, boundaries, noise, reset_delta=50.0)
noise has the shape of x. For one boundary : perturb the past only, with rows replaced by (keep delta, B, C unchanged), run the scan on and on , and take the largest absolute output difference over rows and all channels. The leakage is the maximum of this over all boundaries with (0.0 if there are none).delta ("leak_plain") and once with apply_boundary_reset(delta, boundaries, reset_delta) ("leak_reset").{"y_reset": ..., "leak_plain": float, "leak_reset": float} where "y_reset" is the scan output on the unperturbed x with the reset delta.np.expm1 for ; with the exact hold, a huge gives a finite input weight .