Repository navigation
Host draw: greedy and masked rows scan 64-logit blocks and skip mask words that allow nothing - #2846
Merged
Merged
Conversation
Owner
Author
|
Both test-wiring points from the independent read are settled in
|
ashhart
force-pushed
the
lead/host-simd-draw
branch
from
November 14, 2026 20:10
784e3ab to
e0869bd
Compare
4 tasks done
7 of 8 tasks
ashhart
force-pushed
the
lead/host-simd-draw
branch
2 times, most recently
from
November 21, 2026 14:02
3e64ed1 to
bcb93d3
Compare
This was referenced Nov 21, 2026
…hat allow nothing (#2832) sampling_row.scan replaces the scalar first pass of the greedy and masked draw: every block's exponents are checked finite before any mask test, a block whose two mask words are zero is not ranked, and an allowed key replaces the best only when strictly larger, taking the block's first lane at that key, so ties keep the lowest id and both zeros rank equal. The sampled pass walks set mask bits in id order, so the same candidates reach the fp64 sampler in the same order. The bf16 order keys move here from qwen3_5/draw_topk.zig. Main's draw stays as the test oracle in sampling_row_test.zig.
…g in, and ranks only allowed logits (#2832) After the unchanged finite check, a 32-logit block whose mask word is zero is skipped, the full-selection skip ranks only the allowed lanes, and consider runs for set bits in id order. Each skipped call would have returned at its mask check, so the selection is unchanged. Structured sampled rows at top_k 1..128 take this path, including rows where fewer than top_k ids are allowed. key and keys now come from core's sampling_row (an order-equivalent encoding), and their order test moved there with them.
… row on the CPU (#2832) Greedy, masked and sampled rows through qwen3_5/draw.zig at ReleaseFast, with a checksum of every drawn token so two builds' tokens can be compared. Not part of test or any CI shard; it runs only when asked for.
…rd core's bf16 keys (#2832) The "bounded BF16 keys" filter matched nothing once that test moved to core's sampling_row with the keys. The bounded keyed draws compare the top-k path against the value-sorted reference, so the step again fails when the keys order -0 and +0 apart.
ashhart
force-pushed
the
lead/host-simd-draw
branch
from
November 21, 2026 23:53
bcb93d3 to
f1e12cf
Compare
ashhart
added a commit
to BadAd84/TensorFold
that referenced
this pull request
Nov 21, 2026
ashhart
added a commit
that referenced
this pull request
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rows drawn on the host scanned the whole vocabulary one logit at a time: greedy structured-output rows on CUDA Qwen 3.5, masked rows on Qwen3.8-27B Metal, every greedy row on the small Metal models, and (through
draw_topk.select) structured sampled rows withtop_k1-128. Mask words that allow nothing were still walked logit by logit.What changes:
core/lanes/sampling_row.zig: the host row draw scans 64-logit blocks and skips a block whose mask word allows nothing.qwen3_5/draw_topk.zig: the bounded top-k path gets the same skip and ranks only allowed logits. (Structured sampled rows withtop_kup to 128 go throughdraw_topk.select, notsampling_row, so both paths needed it; Gemma 4 and Step-5 share them too.)test-host-draw-timing, outsidetestand every CI shard.Exactness: every logit is still checked for NaN and infinity before any block is skipped, as on main; ties go to the lowest id with +0 and -0 equal; mask words past the end of the mask allow nothing and no mask allows everything; sampled draws see the same candidates in the same order. Main's draw is kept as a test-only reference.
Checks: seven tests against that reference cover random rows at 248,320 and odd sizes, ties, ±0, subnormals, every NaN/infinity encoding inside fully masked blocks, and all-masked, one-bit, random and partial-last-word masks; fifteen planted bugs each turned a test red. Eight host steps including
test-cuda-host(399/399 steps),compile-cuda-tests -Dtarget=aarch64-linux-gnu,zig fmt --checkand the lean count pass.CPU timing (M3 Ultra, ReleaseFast, one thread, µs per 248,320-logit row, three alternating rounds; token checksums equal in every case):
top_k20, 16 ids allowedtop_k0, 16 ids allowedtop_k20, no maskStill to run before landing: served A/Bs with token hashes equal to main: the Metal 2B (greedy and sampled at 1 and 4 streams), Qwen3.8-27B with structured output on Metal and a GB10 (1 and 4 streams, one cell mixing a masked stream with unmasked ones), and the 35B-A3B structured on a GB10.
For #2832.