Repository navigation
Conversation
95f77be to
3668301
Compare
3668301 to
23a8aa9
Compare
23a8aa9 to
9e33989
Compare
9e33989 to
a83f76f
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. Window-shape validation also multiplies rows and width before checking their bound. Please use a division-based overflow guard and add the overflowing-shape refusal case. In the tests, clear the contract's No rebase is requested, and no device run is promised here.
|
Thanks. That fix, its malformed-count host and CUDA cases and The two test fixes are in no branch yet. I have each as one commit on the current heads: |
|
Thanks, @Bizuayeu. You’re right: the nonnegative-prefix merge, overflow guard and malformed-row checks are already on main. We’ll preserve them when restacking. Please push the prepared We’ll handle the stack; no rebase is needed from you. Current-tree CUDA qualification remains pending.
|
Thanks. Pushed |
|
Thanks, @Bizuayeu. The Main already contains the nonnegative-prefix merge, malformed-prefix regressions and division-based overflow guard. The cumulative branch still has their older versions, so the planned restack must retain main's corrections and carry the cleanup follow-up before qualification. No duplicate patch or rebase is requested from you here. Current-tree CUDA qualification remains pending. The earlier receipts do not establish it for the final integrated tree.
|
544ed10 to
a106f24
Compare
…under the kernel contract ERNIE 5.5's indexer scores each query against keys made from wk's k: LayerNorm(128, eps=1e-6) with k_norm's weight and bias, then RoPE on the first 64 dims in NeoX's halves, pairs i and i + 32, at the config's rope_theta (the DSA layers' plain RoPE; YaRN is the HCA layers'). tf_ernie55_index_key (in the ernie5_5_index image) makes a key a warp: the LayerNorm in fp32, the mean then the squares about it, y = fma(xc / sqrt(var + eps), w, b), then the turn at the fp32 angle inv[i] times the position with sincosf, and one rounding to bf16 (vLLM rounds to bf16 after the LayerNorm and again after the rope). The vendor's Hadamard on q and k before its FP8 quantization is left out: with bf16 keys it changes no score in exact arithmetic. key.zig is the host's float64 key; its tests hold it to vLLM's F.layer_norm and NeoX halves. The contract (ernie5_5-index, also in kernel-contract) asks each key within its float64 bound, from prompt chunks and a decode row at the first position to decode rows past sincosf's fast range and at the 1M context's end; gate 4's rows of 254 to 260 in steps of 2 keep fp32 sums exact while fp16 and bf16 sums lose the steps. The k rows sit 192 apart with NaN past 128, so a read past the key shows. Three controls go red: GPT-J's pairs, the LayerNorm without its bias, and the next position's angle. Nothing launches it yet.
…eing and reallocating it reference freed extra and allocated it again; had that allocation failed, extra would still have held the freed slice, freed a second time by the next reference or by deinit. It is now empty between the two.
a106f24 to
717adbe
Compare
…cation fails window_test.zig's run allocates cnt after tok; an errdefer now frees tok if that second allocation fails, as the review of ashhart#5243 asked. Test code only.
…cation fails window_test.zig's run allocates cnt after tok; an errdefer now frees tok if that second allocation fails, as the review of #5243 asked. Test code only.
|
#5538's head |
|
Thanks, @Bizuayeu. Agreed: #5538 carries this pull request. I checked its head What I confirmed on this head (
One gap remains on this head. Thank you for keeping such a long stack easy to follow.
|
What this changes
tf_ernie55_index_key, in theernie5_5_indeximage: the keys ERNIE 5.5's DSA indexer scores against, as vLLM-ERNIE'sErnie5_5Indexermakes them fromwk's k:k_norm(LayerNorm(128, eps=1e-6), with its weight and bias), then RoPE on the first 64 dims in NeoX's halves, pairs i and i + 32 (get_rope(128, is_neox_style=True)withpartial_rotary_factor64 / 128), at the config'srope_theta(8e6; the DSA layers, their indexer and MTP use plain RoPE, and YaRN is the HCA layers' alone,mla_rope_parametersin the vendor's config). A warp makes a key: the LayerNorm in fp32 (the mean, then the squares about it, each lane's four values in order and then the butterfly),y = fma(xc / sqrt(var + eps), w, b), then each pair turned at the fp32 angleinv[i] * poswithsincosfand explicit round-to-nearest products and sums, and one rounding to bf16. Row r reads k atksapart and writes its key atosapart, at positionpos[0] + r, astf_mla_ropeaddresses its rows; where the key run starts is the caller's. Nothing launches it yet, so served output is unchanged.Two choices differ from the vendor:
One rounding to bf16 at the end. vLLM's LayerNorm returns bf16 for its bf16 input, and its rope turns that with a cos and sin table held in the model's dtype; here nothing between the LayerNorm and the turn is rounded, following "our own code adds no rounding" (ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926 (comment)).
No Hadamard. The vendor applies
hadamard_rowsto q and k before its FP8 or MXFP4 quantization; with bf16 keys and queries (the first slices keep a bf16 KV cache), an orthonormal transform of both changes no score in exact arithmetic, so the FP64 reference is the same with or without it.zig/src/families/ernie5_5/key.zigis the host's float64 key (its sums through asum.ofthe contract's simulations share).key_test.zigholds it to vLLM's forms, written asF.layer_normandApplyRotaryEmb's NeoX halves compute them, at positions 0, 1, 4,095 and 1,048,575 and on a row with no variance; and the shapes it refuses.The contract (
zig/tests/cuda/contract_ernie5_5_index.zig,tf-cuda-test ernie5_5-index, also inkernel-contract) asks each key within its FP64 bound: the sums at depth 11 (contract_layer_norm's magnitudes, turned), each output's own roundings on top (y's 4 units of the normalized term and 1 of y, thensincosf's 2 ulp, the two products and the sum as 8 units of the terms). The k rows sit 192 apart, as the vendor's fusedwkandweights_projleave them, with NaN past the first 128, so a read past the key shows. The shapes: 16 rows from position 120 (the first, where gates 1 and 4 run and the controls are checked), a decode row at position 0, a 512-row chunk from 3,999, a decode row at 199,999 (pastsincosf's fast range) and 4 rows ending at the 1M context's last position. Gate 4 runs rows of 254 to 260 in steps of 2: every sum and square is exact in fp32 in any order, and fp16 and bf16 sums of 128 lose the steps. Three planted controls: GPT-J's pairs (2i, 2i + 1), as the MLA's own rope turns them; the LayerNorm without its bias; and the next position's angle.The record (
ernie5_5_records.zig),cuda_index.zig's launch,docs/kernel-contract.mdand the usage line.Questions for you:
tf_glm_index_write(glm_glue_index.cuh) has the same outline: a warp a row, the LayerNorm, then rope on the first 64 dims. It differs in its pairs (2i, 2i + 1), in following Triton's operations (sqrt_approx,div_full), in writing the gate row too and in addressing its row atpos[0] + r. So I wrote ERNIE's in the family. Should the two share a body in core first instead, per your answer 1 in ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926?7103160ea0, the DSA key lists, which adds theernie5_5_indeximage) on main469f1f7fd8. cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202 landed, and both were rebased onto main with their CHANGELOG lines moved into Unreleased, their code unchanged (the same patch ids); this pull request's own commit is the second on the branch: 10 files, 437 insertions, 9 deletions. Once cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211 lands, it rebases onto main.atc overlap --json, run before the rebase (the files this commit touches are the same): atc 0.9.4 withATC_READ_ONLY=1and cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's head as the base (so this commit alone), run in this tree on 2026-11-26 at 17:05 UTC with--base 9cacd6d07f:complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), 21 pull requests in its working tree's rows, 5conflicts, 5cleanand 11unknown.conflict_delta, run before the rebase: each open pull request merged bygit merge-treewith cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's head and with this head, conflicting files and hunks compared: over the 396 open pull requests on 2026-11-26 at 17:04 UTC (all but cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202 and cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211), this commit adds a conflict to none.Checks on this head
a106f24ea2, on mainc365e1e397), on a GB10 (sm_121): the tree cleaned (git clean -xdf) with an empty global cache,zig build compile-cuda-tests fatbins kernel-contract-fatbins -Dnvcc=... -Dsm=80,86,89,120,121(nvcc 13.0.88): 0 errors. On the GPU,tf-cuda-test ernie5_5-index: SUMMARY ernie5_5 index: 2 kernels, 2 pass gates 1-4, 0 fail, 0 known findings; 5 controls: 5 red as planted, 0 missed;tf-cuda-test kernel-contract ernie5_5: SUMMARY 6 kernels: 6 pass gates 1-4, 0 fail, 0 known findings; 9 controls: 9 red as planted, 0 missed; 0 limit problems. Against mainc365e1e397, built and run the same way:kernel-contract-limitsgives both the same 205 stale records and the same RED and FAIL lines, apart from this tree's 5tf_ernie55_index_keylines (PASS ... (record current)); the only fatbin that differs isernie5_5_index, whose SASS, compared function by function, adds 3 functions at each of the 5 SMs (tf_ctl_ernie55_index_key_gptj_pairs,tf_ctl_ernie55_index_key_no_bias,tf_ernie55_index_key) and changes none of the parent's; no image is added or removed. Host (zig build -Dfixed-cpu):test-ernie5_5-host32/34 tests passed (2 skipped),test-gradient-serving1/1 tests passed,test-kernel-contract368/368 tests passed. The items below are from before your rebase.a83f76fea1):544ed10f0dcuda ernie5_5: the DSA index keys' contract empties extra between freeing and reallocating it, as asked (cuda ernie5_5: the DSA indexer's keys, k's LayerNorm then NeoX RoPE, under the kernel contract #5243 (comment)); test code only,compile-cuda-tests12 of 12 steps on Windows,tools/pr_check.pyagainst the branch's base on main (568f489a34) 0 new, 0 errors.9e339899f7cuda ernie5_5: the DSA indexer's keys, k's LayerNorm then NeoX RoPE, under the kernel contract. The stack was rebased onto main77eae824e4after cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract #5202 landed (only the CHANGELOG line moved) and again onto469f1f7fd8(only cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's pin line, re-pinned; this commit changed nothing in the rebase). The GB10 and WSL runs below are on23a8aa97a4, this commit on77eae824e4, with cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's head there built and run the same way just before it; on this head,pr_check(Windows).tools/pr_check.py --base 7103160ea0 --pr 5243, this commit against cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's): 123 problems on both, 0 new; 0 errors. The 123 are inherited from main.zig-outremoved,zig build compile-cuda-tests fatbins kernel-contract-fatbins -Dnvcc=... -Dsm=80,86,89,120,121: 0 errors. On the GPU,tf-cuda-test kernel-contract-limits zig-out/fatbingives the fivetf_ernie55_index_keylinesPASS ... (record current)(30, 34, 32, 34 and 34 registers at sm_80, 86, 89, 120 and 121, 0 static shared bytes, bound 32), and its other lines are cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's, line for line, with cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's tree built the same way just before;tf-cuda-test ernie5_5-indexpasses the key kernel's gates 1-4 (gate 1: 384 non-finite and 640 finite outputs in their float64 classes; gate 2: five runs byte-identical; gate 3: 5 shapes within the FP64 bound, the worst at 0.995 of it; gate 4: exact sums at k 128, where fp16 sums would miss by 731x and bf16 by 7,645x) and cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's merge as before, with all five controls red (below);kernel-contract ernie5_5passes the three ERNIE kernels with all seven controls red;zig build test-kernel-contract350 of 350 passed;test-ernie5_5-host27 of 29, 2 skipped;test-gradient-serving1 of 1.index.cu's PTX (on95f77bede4, the same source): 33 compiles at each of compute_80 and compute_86 with address randomization on and off, one form at each.pr_checkon this head, 0 errors; before the rebase (the same files),zig fmt --checkandzig ast-checkon the 7 changed Zig files,zig build test-ernie5_5-host22 of 24 passed, 2 skipped (main's),zig build compile-cuda-tests12 of 12 steps andtest-gradient-serving4 of 4 steps.git diff --checkclean;zig build compile-cuda-tests12 of 12 steps;test-gradient-serving4 of 4 steps;test-ernie5_5-host27 of 29, 2 skipped;test-kernel-contract46 of 46 steps (337 tests run);tools/zig/check_cuda_sources.pyonindex.cuwith clang++ 6 of 6;host_tests_testOK; CI's pytest from the root (-q -rs) 856 passed, 116 skipped, 827 subtests passed on each tree, the same skips as main's.3668301bbd:fmt,zig,zig-b,zig-windows,zig-macos-dev-tools,pytest(857 passed, 115 skipped, 827 subtests passed; the run in WSL 2 above has 856 and 116, and the CI log does not print skip reasons),release-paths (ubuntu-24.04),comfyui-moss-installerand bothbenchmark-clientsjobs passed;host-nightly-linuxandhost-nightly-macoswere skipped. The annotations are GitHub's Node.js 20 deprecation warnings and a macOS runner queue notice.Receipt
tf_ernie55_index_key, so no served token or byte can change. On the GB10, against cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's tree built the same way: the only fatbin that differs isernie5_5_index, by this commit's 15 functions (tf_ernie55_index_keyand its two controls at five SMs); the 15 it shares with cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's build have the same SASS, compared function by function, and no image is added.kernel-contract-limitsgives both trees the same 186 stale records and the same RED and FAIL lines, apart from this tree's fivetf_ernie55_index_keylines.23a8aa97a4on cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211's0e0286db5con main77eae824e4(this head is the same change on469f1f7fd8); Zig 0.17.0, nvcc 13.0.88; one GB10 (sm_121); no checkpoint (synthetic rows;rope_thetaand the shapes from the released config).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_index_key(new; replaces none), records for sm_80, 86, 89, 120 and 121 inzig/src/core/contract/ernie5_5_records.zig.tf_ctl_ernie55_index_key_gptj_pairs(GPT-J's pairs), red atshapes("at 16x121x128 output 0 is -1.093750e0 where float64 gives -6.215702e-1: 194.30 of its bound");tf_ctl_ernie55_index_key_no_bias(no bias), red atshapes(16.29 of its bound); andtf_ernie55_index_keytold the next position, red atshapes(146.42 of its bound).SUMMARYline and exit status:SUMMARY ernie5_5 index: 2 kernels, 2 pass gates 1-4, 0 fail, 0 known findings; 5 controls: 5 red as planted, 0 missed, exit 0;kernel-contract ernie5_5:(filtered) SUMMARY 3 kernels: 3 pass gates 1-4, 0 fail, 0 known findings; 7 controls: 7 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).