Repository navigation
fix(dsv41): the prompt indexer passes each row block's vis 16-byte aligned - #4
Conversation
…igned Before: indexer() scores a prompt chunk in blocks of rb rows and passes vis[r0:r1] as a view, ch.vis + r0 * 8. At an odd r0 that address is 8 bytes off 16. The kit has the scoring launches (_index_score_rows, and _index_score for blocks of 16 rows or fewer) with VIS 16-byte aligned only, and the keyed _index_score with an unaligned VIS only where n and nt are divisible by 16, so Set.find finds no variant and the request ends in MissingTritonVariant. rb is odd whenever floor(2^24 / n_comp) is: about half of all prompt lengths past 131,072 tokens fail at the candidate source (its 128 replayed rows make two blocks), and some shorter ones at layers 2, 8 and 14 (23,942 and 121,111 tokens, for two). After: an odd block's m int64 are copied in the stream's order (copyRows) to vis_blk, a 16-byte-aligned buffer, and its launches read them there. The same integers, read only; even blocks still pass the view. Every prompt length from 1 to 1,048,576 then has a captured variant for each indexer launch but 512 and 513 tokens, which need a _topk_sel the kit lacks.
|
Confirmed independently on 2× GB10 TP2 (native Zig, We adopted this PR's diff on our build and re-ran your failing lengths plus ours (120,180 / 131,200 / 131,540 / 135,484 / 142,830 / 149,797 + control): 7/7 pass, zero |
|
Thank you @lucas-peters — merged. And thank you @sayyidfareed for the independent zero-copy alternative in #8; it was a genuine choice. Why this one: it was verified on the served lane against the actual failing prompt lengths (500 → 200), co-verified with the kit's 512/513 fix (bertholomus/deepseek-v4.1-tensorfold-tp2-2xgb10#13), and it keeps the existing block schedule — the only change is copying a misaligned block to an aligned scratch buffer instead of asking for a variant the kit doesn't have. ELI5: the indexer's bookkeeping sat 8 bytes off the 16-byte grid the precompiled kernels expect, so some launches matched nothing and long prompts died with Verified here too: One honest note, from your own receipt: blocks that previously matched an unaligned fallback variant now match the aligned one — the arithmetic is the same (VIS is one scalar per row) but it wasn't compared bit for bit. Flagging it here so nobody is surprised. |
…igned (#4) Indexer: pass each row block's vis 16-byte aligned (visBlock: the view when on-grid, else a copyRows into ch.vis_blk). zig build test green (19/19 steps, 180/180 tests) on Zig 0.17.0 x86_64; kit unchanged. (cherry picked from commit b8ae0c7) (cherry picked from commit 977f6f95df25413cdc50da9bc8ffb260d7997f8f)
…columns over the nodes Every node of a run holds the same index keys and runs the same prompt chunk, so each one scored every column of the keyed indexer layers (the layers before the candidate source, ratio 2): the prompt's cost that grows with depth. TF_DS_IDX_SPLIT=1 (rows of 32,768 columns or more; a number sets the least width; unset or 0: as served): node g of W scores whole 64-column tiles [c0, c0 + n) of each row with the same launches on the same row blocks, keeps their k largest keys (topk_select_pruned's tile step, then torch's top-k), moves them to the row's columns (new kernel tf_ds_keys_rebase_kernel: the low word less c0, the score word kept, pads as they were), the nodes all-gather them and topk_select's torch steps take the k largest of the W k. Each of a row's k largest keys is among its node's k largest, so the same keys and the same columns out, by construction. idx_split.zig: span, nodeVis, nodeKeys, nodeTop, merge and rebaseKey's host model, with tests (every node's k largest keys, moved and merged, select the row's columns as topk_select over the whole row: 2 and 4 nodes, widths 4,096, 5,000 and 12,345, ties, -0, -inf and pads). nodeTop gives each row block's vis 16-byte aligned as the served loop does since TF #4. tri_index.zig: topkSelectTorch and topKeysPruned split out of topk_select. prompt.zig splitKeyed (the split's buffers only when set and world > 1); model.zig and the layer gate read the setting on every rank and prompt2d's settings check compares it. tf-dsv41-split-bench (split_bench_main.zig): the served selection and both splits on one GPU over synthetic FP4 keys, every output byte compared. GB10 (node 2, idle; 2026-10-17): every row equal at every size (n 9,113 to 524,288; whole chunks and the short last chunks of 18,226, 133,376 and 262,526 tokens); a keyed layer's 2048-row chunk, served vs each of 4 nodes before the all-gather: 20.2 -> 6.5 ms at 32K columns, 74.2 -> 22.5 at 128K, 139.6 -> 44.2 at 256K, 169.3 -> 53.5 at 300K, 260.8 -> 75.9 at 512K (2 nodes: 1.8-1.9x). TF_SPLIT_BENCH_VIEWS=1 shows the served loop before TF #4 stopping on the 18,226-token shape with MissingTritonVariant. Host tests 88/88 steps; aarch64 node build ok. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The four-node line that serves DeepSeek-V4.1-Flash-1017 on four GB10 nodes comes in as its own commits: the two-node port's fixes since v0.1.1, the four-node commits rebased onto them, TensorFold 1.0.12 merged under the family, and the fixes since. This merge keeps the branch a fast-forward of v0.1.1 (5940208). Against v0.1.1: - TensorFold 1.0.12 under the family (047441d). - The two-node port's fixes: a launch with no captured Triton variant runs the closest more general one; Pillow's child is started again if it dies; a request the pool cannot hold yet waits for a stream to end; TF_DS_RING_ZERO and TF_DS_REPLAY_FLOOR (both off by default). - Every rank checks its settings against rank 0's at the start; TENSORFOLD_SSE_KEEPALIVE (off by default); the loop guard's novelty signal (two-node recipe issue #18). - Pull request #4 (Lucas Peters): the prompt indexer passes each row block's vis 16-byte aligned. Pull request #18 (lepetitprince716-prog): the loader reads each layer's expert run from the rank cache whole. - TF_DS_IDX_SPLIT (off by default): the keyed indexer layers' long rows split by columns over the nodes. v0.1.1's four-node commits appear again in the merged line, rebased there (28dbfe1, the L2 prefetch settings, to 2591b86, the node inputs and kit tools). The merged tree is that line's, with v0.1.1's README fork note, NOTICE, ATTRIBUTION.md and the four-node paragraph of THIRD_PARTY_NOTICES.md carried over; the next commit brings them up to v0.2.0. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… TensorFold 1.0.12, two contributors The README's fork note names first the weights the branch serves since v0.2.0, bertholomus/DeepSeek-V4.1-Flash-1017-EXL3-4.0bpw (MIT), our EXL3 quant of deepseek-ai/DeepSeek-V4.1-Flash-1017, then the 2.9 bpw weights v0.1.x served. NOTICE lists every upstream file the branch changes against 1.0.12, the kept 1.0.2 kit packer and the two contributions (pull requests #4 and #18). ATTRIBUTION.md adds the 1017 checkpoint and our quant, TensorFold 1.0.12, Lucas Peters and lepetitprince716-prog, and @Capicua25x's report behind the loop guard's novelty signal. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Long prompts end in
MissingTritonVariantin_index_scoreor_index_score_rows:indexer()scores a prompt chunk in blocks ofrb = max(16, min(n, 2^26 / (4 * n_comp)))rows and passesvis[r0:r1]as a view. At an oddr0that view is 8 bytes off 16. The kit has the scoring launches (_index_score_rows, and_index_scorefor blocks of 16 rows or fewer) only withVIS16-byte aligned, and the keyed_index_scorewith an unalignedVISonly wherenandntare divisible by 16. SoSet.findhas nothing to run.rbis odd wheneverfloor(2^24 / n_comp)is. At the candidate source the bounded replay leaves 128 rows, which make two blocks once a prompt is past 131,072 tokens, so about half of all lengths past that fail there. Layers 2, 8 and 14 fail at some shorter lengths too (23,942 and 121,111 tokens were two of them in our log).Evidence
Setup: two GB10 nodes (Ubuntu 24.04, driver 595.71.05),
deepseek-v41-zigat 4e80f05, kit v0.6.1 (aot.jsonsha256092b6d27…), Mia-AiLab/DeepSeek-V4.1-Flash-EXL3-2.9bpw at 64ba41b6, served as in the recipe (--context 1048576 --parallel 4,TF_DS_REPLAY_FLOOR=1). Each request is one user message of random single-token words, exactly P prompt tokens (checked with/v1/tokenize),max_tokens: 1; the targets share one prefix and go in ascending order._index_score, layer 2, n 60,090_index_score, layer 20, n 131,200_index_score, layer 20, n 142,830_index_score_rows, layer 20, 17 rowsno captured Triton variantline.indexer()'s launches, checked againstaot.jsonwithaot.zig'smatchesandfitsrules, reproduces each of the 10 failures in our served log (function,n,nt, rows,VISalignment) and predicts all 455 logged successes. Over every prompt length from 1 to 1,048,576 it finds an indexer launch with no variant at 475,372 lengths before this change and at 2 after: 512 and 513 tokens, which need_topk_selN=KK=256, a kit gap, filled by kit: _topk_sel N=KK=256, for prompts of exactly 512 or 513 tokens deepseek-v4.1-tensorfold-tp2-2xgb10#13.zig build test19/19 steps succeeded,zig fmt --checkclean,tools/zig/lean_check.py1420 problems before and after (prompt.zig was already over 600 lines).Merge Danger
Door: two-way. A revert restores the views.
Blast Radius: the prompt chunks' indexer only; decode rounds do not call it. An odd block adds one
copyRowslaunch per indexer layer. Blocks that used to run a fallback variant (for example the keyed_index_score_rows142a77750b87, which assumes nothing ofVIS) now run a variant compiled for an alignedVIS.VISis read as one scalar per row, so the arithmetic is the same, but I did not compare those outputs bit for bit.deepseek-v41-zig-tp4has the same view (prompt.zig:958). It is not changed here, to keep one change per PR.