zl_softmax() normalises each column (the first dimension) after
multiplying by scale and adding mask, an additive f32 tensor whose
first two dimensions are x's and whose third and fourth are 1 or
x's, so one mask serves every head. zl_causal_mask() sets to -Inf
every element of each matrix whose row index exceeds its column index,
so that for scores of dims c(n_kv, n_q, ...) a query sees only keys
at or before it.
Usage
zl_softmax(x, mask = NULL, scale = 1)
zl_causal_mask(x)
zl_rope(x, pos, n_dims, base = 10000, mode = c("interleaved", "half"))
zl_rms_norm(x, eps = 1e-05)
zl_layer_norm(x, eps = 1e-05)Details
zl_rope() applies rotary positions to x of dims
c(head_dim, heads, n, ...) with integer positions pos of length n
(an input declared with zl_int()). mode = "interleaved" rotates
adjacent pairs ('ggml”s default and Toto's convention); mode = "half" rotates the first half against the second (TimesFM, Chronos-2,
most Hugging Face checkpoints). n_dims below head_dim rotates the
leading n_dims only. head_dim must be even.
zl_rms_norm() divides each column by its root mean square;
zl_layer_norm() subtracts the column mean first.