Repository navigation
cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract - #5211
Conversation
ca620d5 to
9cacd6d
Compare
9cacd6d to
0e0286d
Compare
0e0286d to
7103160
Compare
7103160 to
24e7358
Compare
|
Thanks, @Bizuayeu. The valid-input list construction is clear, and the CUDA byte checks and planted controls cover the normal window and top-k boundaries well. One malformed-count case still breaks the list's safety invariant. If Please make both the CUDA and host merge stop at the valid nonnegative prefix before copying and counting picks. Add fail-before host and CUDA cases where an oversized count exceeds a short valid prefix, and assert that every entry before the count is structurally valid. The current oversized fixture uses a full pick row, and structural checks skip malformed-count rows, so neither catches this case. No rebase is requested, and no device run is promised here.
|
24e7358 to
55a5d64
Compare
Thanks, fixed in
The receipts are in the description. I left the stack above as it is, for your rebase. |
|
Thanks, @Bizuayeu. The nonnegative-prefix fix and the new malformed-count host and CUDA cases address the last review in full. One separate host validation bug remains:
|
55a5d64 to
c07fcb5
Compare
Thanks, fixed in
The kernel, its contract and records are unchanged from |
c07fcb5 to
ba13f19
Compare
ba13f19 to
1841733
Compare
bfd11be to
de7cf53
Compare
…the kernel contract ERNIE 5.5's DSA layers attend over each row's indexer picks and its 128-position sliding window, laid out by vLLM-ERNIE's merge_swa_topk as one list a row. tf_ernie55_window_merge (a new ernie5_5_index image) writes that list for the sparse MLA from topk_rows' out and picked: the row's picks up to picked, held to [0, k] and ending at the first -1, then positions seq - min(seq, 128) .. seq - 1, then -1, with the row's count. The count comes from picked rather than from the position, and the picks stop at their first -1, so an entry the MLA reads is never a -1, even where picked counts past the picks a row holds. window.zig is the host's list; its tests hold it to the vendor's rule where picked is the indexer's count, and to the stop where picked is past a row's valid picks. The contract (ernie5_5-index, also in kernel-contract) asks for the host's lists to the byte, and every row's entries to be rows below seq, ascending to seq - 1 with its picks below the window, from decode rows at the first position and deep in context, across seq = 128 and seq = k + 128, to prompt chunks and the 1M context's last rows. A negative picked and two oversized ones, past a row of k picks and past a shorter row, are planted. The two controls, every row taking all k picks and the window's oldest position dropped, go red. Nothing launches it yet. gradient-serving.tsv re-pins zig/src/cuda/kernels.zig.
de7cf53 to
2b516d2
Compare
|
Thank you @Bizuayeu. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
What this changes
A new
ernie5_5_indeximage withtf_ernie55_window_merge: the list of keys each of ERNIE 5.5's DSA rows attends over, its indexer's top-k picks and then its 128-position sliding window, as vLLM-ERNIE'smerge_swa_topklays them out for its sparse MLA ([topk[:n] | seq-w .. seq-1 | -1 ...], with w = min(seq, 128)). It readstopk_rows' out andpicked(#5051) and writes thetokens[rows, w] andcounts[rows] thatmla.zig's sparseOntakes, row r at positionpos[0] + ras the MLA has it. One choice differs from the vendor's kernel: n is the row'spicked, held to [0, k] and then to the picks before the row's first -1, not min(max(seq - 128, 0), k) from the position, because the MLA reads every entry before a row's count as a cache row (common/mla.cuh), so no -1 may fall inside the list. Wherepickedis that count (the indexer told the row's positions older than the window), the lists are the vendor's. Nothing launches it yet, so served output is unchanged.zig/src/families/ernie5_5/window.zigis the host's list, andcheckits shape test (sizes held in i32,rowscompared withmaxInt(i32) / wso thatrows * wcannot wrap).window_test.zigholds it to the vendor's rule, written as its Triton kernel computes each column, over every row of 4,355 from the first position (across seq = 128 and seq = k + 128 at the released k = 2,048, and at a small k and window); rows from a later position;pickedheld to [0, k]; a count past a row's valid picks, which stops at the first -1 (the review's case, with every entry before each count checked to be nonnegative); and the shapes it refuses, among them 2^63 + 1 rows of 2, whoserows * wwould wrap (the second review's case).The contract (
zig/tests/cuda/contract_ernie5_5_index.zig,tf-cuda-test ernie5_5-index, also inkernel-contract) asks for the host's lists to the byte, and for every row, rows told a negative count or one past k included: as many entries as its valid picks and window, each a row below seq, strictly ascending, its picks below the window, the last seq - 1, and -1 after. The shapes: 16 rows from seq 120 (across the window, with fewer picks than k; the first, where gate 1 runs and the controls are checked), a decode row at seq 1 and one at seq 100,000, 16 rows across seq = k + 128, a 512-row prompt chunk from the start, 256 rows from seq 4,000, and 4 rows from seq 1,048,576, with row 0 at seq 1, 127, 128 and 129 for the edges. A negativepickedand two oversized ones are planted: k + 7 on a row of k picks, and k + 7 on a row with fewer valid picks than k (its picks end in -1 before k). The output is integers:.accum = .noneand.out = .raw, so no FP64 bound and no gate 4. There are two planted controls: every row taking all k picks, and the window's oldest position dropped.The records (
ernie5_5_records.zig), the image incuda_kernels.zigandkernels.zig, the runner'sernie5_5_index_cudamodule,docs/kernel-contract.md, andgradient-serving.tsv's re-pin ofzig/src/cuda/kernels.zig.Issue: Refs ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926: the window merge of the DSA layers in the slicing there (ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926 (comment)), under the gate set for each ERNIE kernel (ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926 (comment): "Each kernel also comes one to a PR, registered with the kernel contract, with its rounding points and sum order written down, an FP64 bound for that order and planted controls.").
Base: main
8b1eaff2c7, as rebased here (24e735876a). This head is that commit with the review's fix (cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211 (comment)) andwindow.check's division (cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211 (comment)) amended: against24e735876a, 6 files, 54 insertions and 22 deletions (index.cu,window.zig,window_test.zig, the contract, the records anddocs/kernel-contract.md). 17 files, 468 insertions, 3 deletions.atc overlap --jsonandconflict_delta, both run before the rebases (the files this commit touches are the same): atc 0.9.4 withATC_READ_ONLY=1and cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202's head as the base (so this commit alone), run in this tree on 2026-11-26 at 14:40 UTC with--base 65eca9a14d:complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), 35 pull requests in its working tree's rows, 5conflicts, 5cleanand 25unknown.conflict_delta(each open pull request merged bygit merge-treewith cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202's head and with this head, conflicting files and hunks compared): over the 396 open pull requests on 2026-11-26 (all but cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202 and my cuda glm: mHC's pre-side bodies move to common/mhc.cuh, the finish taking the mix's RMS step from its caller #5164), this commit adds a conflict to none; the pin line ingradient-serving.tsvit re-pins is the one cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202 already shares with CUDA: native TFQ3 (3/4/5-bit 2D-FWHT) runtime + drafters for Qwen3.8-27B, GLM-5.3-Flash, and Flash Next #4986, Inkling-2-Mini: Serve on two GB10s with images and 1M context window #5059 and cuda: sparse gather attention over listed cache rows (Kolibri 1.1, slice 1 of #4846) #5166.Checks on this head
c07fcb5e32cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract. It is55a5d64aa5withwindow.check's size test made a division and its fail-before host case (2 files,window.zigandwindow_test.zig). The GB10 and WSL runs below are on55a5d64aa5, whose kernel, contract and records this head keeps (the GB10 beside24e735876a, built the same way), and the last Windows line is on this head; the earlier runs on0e0286db5cand7103160ea0, before the fix, are in the last lines.tools/pr_check.py --base 8b1eaff2c7 --pr 5211, this commit against main, Windows): 123 problems on both, 0 new; 0 errors. The 123 are inherited from main.24e735876aand then this head, each in its own worktree with an empty global cache,zig build compile-cuda-tests fatbins kernel-contract-fatbins -Dnvcc=... -Dsm=80,86,89,120,121: 0 errors each. On the GPU,tf-cuda-test kernel-contract-limits zig-out/fatbingives this head's fivetf_ernie55_window_mergelinesPASS ... (record current)(24 registers at sm_80, 86 and 89, 40 at sm_120 and 121, 4 static shared bytes, bound 256), and its other lines are24e735876a's, line for line (191 problems each);tf-cuda-test ernie5_5-indexpasses gates 1-3 (gate 3 at 12 shapes, each exact by its own check; gate 4 n/a, no sums) with both controls red as planted, andkernel-contract ernie5_5passes both ERNIE kernels with all four controls red (below). On the same host,zig build test-ernie5_5-host26 of 28 passed, 2 skipped;test-kernel-contract46 of 46 steps, 356 of 356 tests;test-gradient-serving1 of 1.24e735876a'sindex.cu(the kernel before the fix, rebuilt in this tree):tf-cuda-test ernie5_5-indexfails, as it must, at gates 1 and 3: "at 16x120x2048: list entry 10880 is -1, window.merge gives 0", the first entry of row 5 (seq 125, no valid picks, told k + 7);SUMMARY ernie5_5 index: 1 kernels, 0 pass gates 1-4, 1 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed, exit 1.window_test.zigcase with24e735876a'swindow.zigfails, the merge giving the review's row,[5, -1, 7, 8, 9], and[-1, 4, 8, 9, 10]for the second (25 of 28 passed, 2 skipped, 1 failed); on55a5d64aa5test-ernie5_5-hostpassed 26 of 28, 2 skipped. The newcheckcase (2^63 + 1 rows of 2, k 0, window 1) with55a5d64aa5'swindow.zigpanics withinteger overflow(26 of 29 passed, 2 skipped, 1 crashed); on this headtest-ernie5_5-hostpasses 27 of 29, 2 skipped.55a5d64aa5: the shared-copy and fragment checks (61 local copies, 0 violations; 2 fragments, 18 includes, 0 misses);zig build compile-cuda-tests12 of 12 steps;test-kernel-contract46 of 46 steps, 343 of 343 tests;test-gradient-serving4 of 4 steps;pr_check0 errors. On this head:zig fmt --checkandzig ast-checkon the two changed files;zig build test-ernie5_5-host27 of 29, 2 skipped;pr_check --base 8b1eaff2c7 --pr 52110 errors (123 problems on both, 0 new).55a5d64aa5:git diff --checkclean;zig build compile-cuda-tests12 of 12 steps;test-ernie5_5-host26 of 28, 2 skipped;test-kernel-contract46 of 46 steps, 356 of 356 tests;test-gradient-serving1 of 1;tools/zig/check_cuda_sources.pyonindex.cuwith clang++ 6 of 6;host_tests_testOK; CI's pytest from the root (-q -rs) 861 passed, 116 skipped, 827 subtests passed, the same skips as main8b1eaff2c7's (861 passed, 116 skipped, 827 subtests passed).24e735876a:fmt,pytest,zig-macos-dev-tools,release-paths (ubuntu-24.04)and bothbenchmark-clientsjobs passed;zigfailed attools/zig/env_names.pyon files this pull request does not touch (docs/environment-names.md:TF_INKLING2_DRAFT_HEAD_Q4has no row; nine names inzig/src/server/confidential.zig).0e0286db5c(main77eae824e4), the GB10 contract and limits (22 registers at sm_80, 86 and 89, 40 at sm_120 and 121, 0 static shared bytes) and WSL 2's steps and CI's pytest, the same skips as main's; CI on7103160ea0(main469f1f7fd8) green.Receipt
tf_ernie55_window_merge, so no served token or byte can change. On the GB10, against24e735876abuilt the same way, the fatbins that differ areernie5_5_index(its 15 functions: the merge and its two controls at five SMs),contract_controls(one function,tf_ctl_moe_router_tiles_rowat sm_89: the router-tiles entries whose compiles give more than one form, cuda: the shared router tiles read their shared-memory rows as 32-bit words #5360), andglm_glueandglm_index, whose functions are all equal.55a5d64aa5on main8b1eaff2c7(this head adds the host'scheckdivision); Zig 0.17.0, nvcc 13.0.88; one GB10 (sm_121); no checkpoint (synthetic picks).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a (no served path).tools/bench_openai.py: n/a (no served path).Kernel contract, only when a GPU kernel is new or changed
tf_ernie55_window_merge(new; replaces none), records for sm_80, 86, 89, 120 and 121 inzig/src/core/contract/ernie5_5_records.zig: 24 registers at sm_80, 86 and 89 and 40 at sm_120 and 121, 4 static shared bytes (the block's count of valid picks), bound 256.tf_ctl_ernie55_window_merge_all_picks(every row takes all k picks), red atshapes("at 16x120x2048: list entry 0 is -1, window.merge gives 0"), andtf_ctl_ernie55_window_merge_short_window(the window's oldest position dropped), red atshapes("list entry 0 is 1, window.merge gives 0").SUMMARYline and exit status:SUMMARY ernie5_5 index: 1 kernels, 1 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed, exit 0;kernel-contract ernie5_5:(filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 4 controls: 4 red as planted, 0 missed; 0 limit problems, exit 0. CUDA only (no HIP, Metal or XPU image).Checklist
-Dnvccthe CUDA steps are not built, as for every image)."draft": false, a resumed prompt equals a fresh one, and concurrent equals solo (no served path changes).--drafter, no slower than without it, greedy and sampled (no served path changes).