Expand description
2026-09-25: Host reference for one row of argmax_bf16_batch_feed
(kernels/gb10/common/argmax_feed.cu), computed from the same BF16 bytes.
Owner: metrale-sampling. Invariants: none beyond the types. NaN input is outside the contract.
The kernel runs two reductions over a row and combines them:
p: the plain argmax, the same scan and tree reduction asargmax_bf16_batch. Each of theBLOCKthreads keeps the first strict maximum of its strided slice above the-1e30floor. At each merge of threadstandt + s,tkeeps its value unlesst + sholds a strictly larger one. Ties therefore follow the tree order, not the lowest index.plain_kernel_argmaxsimulates this, floor included.q: the row with the two masked ids set to-inf(asPostCloseThinkMaskdoes) and the last index holding the maximum, the tie rule of the temperature-0 host sampler (masked_last_wins).- The answer is
qwhenpis a masked id, elsep(feed_argmax). The synchronous decode step does the same: it takes the device argmax unless athink_endedrow’s argmax landed on a masked id, and then samples on the host.
feed_argmax_tests.rs checks q against the host sampler, p against
argmax_bf16 for rows with a unique maximum, and pins the tie cases.
Constants§
- BLOCK
- 2026-09-25: Threads per row block of the kernel; the tie order depends on it.
- NO_ID
- 2026-09-25: “No id” in a row mask.
- PLAIN_
FLOOR - 2026-09-25: The floor the plain kernel starts its running maximum at.
Functions§
- bf16_
to_ f32 - 2026-09-25: BF16 bits to f32, exact (what
__bfloat162floatcomputes). - feed_
argmax - 2026-09-25: One row of
argmax_bf16_batch_feed, from the BF16 bits. - feed_
argmax_ f32 - 2026-09-25:
feed_argmaxover an f32 row. - masked_
last_ wins - 2026-09-25:
q: the last index holding the maximum ofmasked_row, with the maximum starting at-inf; an empty row gives 0. - masked_
row - 2026-09-25: The row with the masked ids at
-inf; out-of-range ids are ignored. - plain_
kernel_ argmax - 2026-09-25:
p: the plain kernel argmax ofrow, tie order and floor included.