Verba/Rapida

Esperimenti #167

A fused top-64 select for the 2-bit head shortlist: row 67c's `r67cScores` (`src/transformer.zig:4564`)...

done

Il testo degli esperimenti resta in inglese, come l'ha scritto il laboratorio.

Cosa è stato provato

A fused top-64 select for the 2-bit head shortlist: row 67c's `r67cScores` (`src/transformer.zig:4564`) negates the 162,489 2-bit scores and calls `mlx_argpartition_axis`, which runs as MLX's multi-block sort (`merge_mbsort`, `partition_mbsort`, 131 us a step), then builds a 162,489-wide -1e30 row with `mlx_full` and `mlx_put_along_axis` that the head argmax reads whole (58 us); a Lesto kernel that keeps each threadgroup's 64 largest and merges them once, and an argmax over the 64 rescored values only, with the argpartition's own tie order (read from MLX's sort, then checked against it on captured rows), so the reply is unchanged; step 1 a kernel test against `mlx_argpartition` on captured 2-bit rows, then the 50-session identity count, then a pair

Modello e configurazione

the best

Guadagno atteso

about +1.0% to +1.8% (0.10 to 0.19 ms of 10.4 ms at 8k; **measured** cost, **estimate** of the kernel's own time)

Da dove viene l'idea

rows 67c, 165

Esito

done 2026-11-19: ; lossless (150 of 150), decode +0.59% [+0.57, +0.62] against the 0.7% line (`mac/167/1`), about 61 us a step of the 100 to 190 estimated; `row/167` kept for a stacked lossless pair; shortfall split in row 167p (`2026-11-19-mac-r167-topk-select/README.md` § Result, row 167)

Lezione

replacing the shortlist's full merge sort and full-row argmax with a fused top-64 select and a 64-wide argmax keeps every reply and shortens the decode step by about 61 us (+0.59% [+0.57, +0.62]), a third to two thirds of the estimate, because the fused select's first pass (80 threadgroups each bitonic-sorting 2,048 scores) runs 106 us by itself.

Adottato

no (no-gain under the pre-registered +0.7%; lossless and measured, so `row/167` stays for the next stacked lossless pair, beside rows 159z and 156g)

Vuoi vedere cosa hanno prodotto questi esperimenti? Lesto, il motore di inferenza per Gemma 4 sui Mac con Apple silicon, è su lestoengine.com

Creato da Federico Andrioli, @fedeandri su X Le misure di un laboratorio di ricerca, ricavate direttamente dai suoi file. Dati aggiornati al