mirror of
https://github.com/ollama/ollama.git
synced 2026-11-08 02:16:57 -06:00
MLX's argpartition sorts the whole row, and a row longer than one block of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each 2048-value chunk in a single block, then only the chunks' top k, and returns the same indices in the same order. The sampler's top_k and top_logprobs and the DFlash2 candidate selector use it in place of a full-vocabulary argpartition.