pub fn topk_to_mask(
topk: &[i32],
q_rows: usize,
width: usize,
kv_len: usize,
) -> Vec<u8> ⓘExpand description
Turn an index row into the boolean visibility mask the attention consumes.
Mirrors HF’s scatter_add + .ne(0): duplicate indices collapse, so a repeated token is
attended once, not twice. Out-of-range and INVALID entries are dropped.