expand_selection

Function expand_selection 

Source
pub fn expand_selection(
    selected: &[i32],
    pools: &Pools,
    valid_candidates: &[u8],
    valid_keys: &[u8],
    q_positions: &[usize],
    q_mask: &[u8],
    dims: DsaDims,
    seq: usize,
    select_k: usize,
) -> Vec<i32>
Expand description

Expand selected pools into raw token indices, append the visible tail, pad with INVALID.

🔴 The output is fully written for all out_width entries on every row, unconditionally. That is the structural answer to vLLM’s day-0 defect, where a torch.empty buffer’s tail stayed uninitialised whenever the valid pool count fell below the budget and uninitialised memory was read back as token indices.