Repository navigation
fix(cluster): the leader's draw refuses non-finite logits - #658
Merged
Merged
Conversation
choose's sort has no consistent order once a logit is NaN; greedy rows and infinities are refused too, as in serial_host's choose and qwen27's argmax.
Owner
|
Thank you, @chaog992. A clear find, and the test pins it down exactly. Your commit We ran the parts you couldn't, on a Mac:
Your direct We added a CHANGELOG line saying no served model reaches the cluster's draw yet, so nobody reads it as a live crash fix. When a Metal or CUDA shard lands, this check will already be there. |
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
core/serial_host.zig served one request at a time through a driver of callbacks. Its last engine was the 27B's single-stream host, qwen27_host.zig, which no server had opened since 1.0.6 and ashhart#659 removed with the drafter's batch path, so only its own tests used it. It goes with them: serial_host_test.zig, serial_batch_test.zig and cache_mode_host_test.zig, 1,113 lines in all and 20 tests, every one in the binary rooted at engine_api.zig. No build step, tool or doc named it, and its choose()/Logits sampling helper had no caller either. cache_modes keeps its callers: Engine.submit validates spans and the 27B's host keeps reply states. Three mentions follow it: the rewind test's comment names the 27B's host, the 27B's slot prefill comment drops its pointer to the serial host's rule, and ashhart#658's CHANGELOG line compares with Qwen's draws alone.
Closed
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
ashhart#658 landed above as 2e6a3f511 (the author's commit, rebased onto this candidate). This keeps the PR's own head commit in the history, with no change to the tree.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
core/serial_host.zig served one request at a time through a driver of callbacks. Its last engine was the 27B's single-stream host, qwen27_host.zig, which no server had opened since 1.0.6 and ashhart#659 removed with the drafter's batch path, so only its own tests used it. It goes with them: serial_host_test.zig, serial_batch_test.zig and cache_mode_host_test.zig, 1,113 lines in all and 20 tests, every one in the binary rooted at engine_api.zig. No build step, tool or doc named it, and its choose()/Logits sampling helper had no caller either. cache_modes keeps its callers: Engine.submit validates spans and the 27B's host keeps reply states. Three mentions follow it: the rewind test's comment names the 27B's host, the 27B's slot prefill comment drops its pointer to the serial host's rule, and ashhart#658's CHANGELOG line compares with Qwen's draws alone.
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.
What this changes
Leader.drawinzig/src/cluster/backend.zighands a sampled row's logits straight tolanes.sampling.choose. Its sort comparator,byValueThenId, stops being a strict weak order once a value is NaN, andstd.mem.sortcan then compute an out-of-range index inside its block sort. Without this change, the new test panics there in Debug and ReleaseSafe. Other rows with a NaN or an infinity, greedy or sampled, still draw a token, sometimes the id of a NaN logit.drawnow refuses such a row witherror.NonfiniteLogitsbefore either path.serial_host.chooseand qwen27'sargmaxalready refuse these rows with the same error, and qwen3_5'sdrawwithNonfiniteQwenLogits. Finite rows draw as before.Nothing shipped reaches this yet: only the toy cluster in the tests builds a
Leader, and the cluster commands stop before any round. It matters once a Metal or CUDA backend implementscluster.backend.Shard.Receipt
d5126573, fixa6823950, Zig 0.17.0, Linux x86_64 under WSL2. No GPU or model is needed.backend_test.ziggets one test, run for NaN, +inf and -inf, greedy and with the file'shotsampling. Each case expectserror.NonfiniteLogitsfrom two kinds of row: a 2048-logit row with every other logit bad (the sort's failing path needs 1024 or more), and rows with one bad logit at either end. A row of finite extremes (±floatMax, a subnormal, -0.0) draws as before.zig build testnever builds the cluster module, andtest-clusteris macOS-only, so I ran the tests directly:-O ReleaseSafeor-O ReleaseFastbefore-Mroot.studio1tostudio4, and the assertions look fornode-d.TF_K3_DIR,TF_CLUSTER_PROBESorTF_CLUSTER_REPORT.backend.zig, in Debug. ReleaseSafe gives the same panic with inlined frames. ReleaseFast, the build default, segfaults.python3 tools/zig/lean_check.pyreports 1169 files and 534 problems on the base, and the same list with this change.zig fmt --check build.zig zigpasses.zig build testpasses 39/39 steps and 449/449 tests.aarch64-macos(-mcpu apple_m1 --test-no-exec). This is a compile check only.zig build test-cluster, since I have no Mac, and any served model.