The released H-Net code does not write its smoothing loop by hand. It calls the Mamba-2 kernel on carefully chosen parameters, since a fused GPU scan already exists. Reproduce that translation. The scan runs one linear state per head:
ssm_scan(x, dt, A, b, c)
x float (B, M, D), dt float (B, M), A a Python float, b and c float (B, M).M and return y (B, M, D). A plain loop over M is fine here.ema_scan_params(z, P, eps=1e-4)
z float (B, M, D) and P float (B, M) are the inputs of the smoothing EMA.P to [eps, 1 - eps], then return the tuple (x, dt, A, b, c) so that ssm_scan computes the EMA with that clamped P:
dt = log(1 / (1 - P)), A = -1.0, b = P, c = 1, and x = z / dt[..., None].smooth_via_scan(z, P, eps=1e-4)
ssm_scan(*ema_scan_params(z, P, eps)).