Verba/Rapida

Experiments #172

The shortlist's top-64 pick as a threshold select (row 171; row 167p's unbuilt half): `r167_topk_part`...

done

What was tested

The shortlist's top-64 pick as a threshold select (row 171; row 167p's unbuilt half): `r167_topk_part` bitonic-sorts every 256-score chunk in full and `r167_topk_merge` runs 64 sequential one-threadgroup rounds, 61.5 plus 53.1 us a step at both lengths for 162,489 scores (`src/topk_select.zig:38`, `:69` at 729d1f79). Find the cut with a count above candidate values (a radix or histogram pass over the row), gather the scores at or above it, and order only those with `r167_before` (argpartition's tie order), so the 64 indices and their order stay identical. Step 1a: microbench at the shape against part plus with row 167f's harness, picks checked equal to argpartition at every size; kill when the new pick takes above 0.6 of the current one

Model and setup

the best

Expected gain

+0.7% to +0.9% (75 to 95 us a step, estimated kernel time)

Where the idea came from

row 171, row 167p

Outcome

done 2026-11-19: , decode +0.79% [+0.65, +0.84] (floor 0.05, line +0.4%), replies identical 150 of 150, first +0.4 ms [+0.2, +0.7] (A/A +0.1 [-0.2, +0.3]); scored run mac/172/1; replicated 19:42, +0.85% [+0.71, +0.91] (mac/172/2), the warm first token inside the A/A; adopted 20:30: Lesto main 4acc3806 v0.22.4, tag best-2026-11-19-r172, merged binary 150 of 150 identical (diag172m), ledger lesto_r172 97.3 (`2026-11-19-mac-r172-threshold-select/README.md` ยง Adoption, row 172)

Lesson

the threshold select that cut the top-64 pick from 91.7 to 27.3 us in the microbench keeps that saving in the engine. Decode rises +0.79% [+0.65, +0.84] (about 82 us a step against 80 predicted), flat across turns, with every reply identical, so a pick kernel's microbench ratio at the served length predicts its decode effect here.

Adopted

yes (Lesto main 4acc3806, tag best-2026-11-19-r172, ledger row lesto_r172)

Want to see what these experiments produced? Lesto, the Gemma 4 inference engine for Apple silicon Macs, is on lestoengine.com

Made by Federico Andrioli, @fedeandri on X A research lab's own measurements, generated from its files. Data built