Repository navigation
Conversation
37b8357 to
e2b9fb5
Compare
|
Thanks, @Bizuayeu, for the clear implementation and the detailed contract coverage. The pooling, RMSNorm, RoPE placement, final BF16 rounding and planted controls are easy to follow. Nothing invokes this compressor in serving yet, so the existing served-token path is unchanged. One item remains before landing. (Current main also conflicts with this in There is also a small stride-validation gap. The rest of the read-only HCA review found no pooling, norm, RoPE or rounding defect.
|
e2b9fb5 to
9d7cbf5
Compare
Done on The new test beside the shape checks: I've left the rebase to you, as you offered. |
9d7cbf5 to
3bf3867
Compare
|
Thanks, @Bizuayeu. The HCA increment shows no additional static blocker: score-plus-APE pooling, the 512-channel RMSNorm, GPT-J rotation at each block's first position, stride guards and planted controls are internally consistent. Two inherited blockers remain. Host and CUDA window merging still clamp The mHC mix also still substitutes unrounded FP32 coefficients and a custom reduction for the pinned TF32/DeepGEMM arithmetic. Please reproduce the pinned rounding and reduction exactly in kernel and oracle, or provide byte-exact same-engine evidence for the alternative without tolerance. Add a planted The inherited hardening fixes also remain: guard window-shape multiplication with division, clear the contract's No rebase is requested, and no device run is promised here.
|
Thanks. The mixes stay fp32 products on purpose: your reviews of #5301 found that the right choice, "Keeping the mHC mixes as fp32 products, rather than rounding inputs to TF32 the way the vendor's GEMM does, is the right choice here" (#5301 (comment)) and "no change is needed to the FP32-product choice" (#5301 (comment)), and the kernel and the oracle here are that choice. Should I keep it, or move the kernel and the oracle to the vendor's TF32 inputs and DeepGEMM's reduction order, with the planted The On this branch two more are mine: its compressor contract's |
|
Thank you, Bizuayeu. The HCA compressor retains the requested score-plus-APE pool, RMSNorm, block-first-position RoPE, stride guards, and planted controls. The stride-validation request is met. The inherited window and mHC blockers remain: both window implementations still admit an internal One HCA-specific cleanup issue you identified remains: the compressor contract frees Please push that HCA allocation fix and stop both window merges at the first negative pick with malformed-prefix structural regressions. No rebase or device run is requested until these source fixes are in.
|
Thanks. Pushed The window merges' stop at the first negative pick is #5211's, on main, with its host and CUDA malformed-prefix regressions and the window-shape division guard; as you wrote on #5243 (#5243 (comment)), your restack carries it here. The |
|
Thanks, @Bizuayeu. The compressor contract clears The TF32 rewrite request is withdrawn. Keep the agreed FP32 products. Before qualification, the planned restack still needs main's window-prefix and overflow corrections, the index cleanup from #5243, the token-buffer follow-up #5535, and this HCA cleanup commit preserved together. No duplicate fix or rebase is requested from you here. Current-tree CUDA qualification remains pending.
|
386508a to
de75602
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.
…, under the kernel contract tf_ernie55_mhc_post, in the ernie5_5_mhc image, adds a layer's bf16 output to its row's 4 residual streams as vLLM's mhc_post does for ERNIE 5.5: stream o = post[o] x + sum_i comb[i][o] res[i], with post and comb from the pre side, from the product, then the input streams in order in fma, rounded to bf16 once. GLM's post body sits in its own glue, so ERNIE's is a family kernel. The streams are checked against float64 (ernie5_5/mhc.zig), with gate 4 on integer terms that fp32 holds in any order, cancelling to +-1/2, whose fp16 and bf16 roundings do not; two controls: comb read transposed, and the layer output added without post.
…r the kernel contract tf_ernie55_hc_head, in the ernie5_5_mhc image, folds ERNIE 5.5's 4 residual streams into the one row the final RMSNorm takes, as vLLM's hc_head does: its 4 mixes against fn's float32 rows and the streams' squares, summed as the pre side sums them, the plain RMS 1 / sqrt(mean + eps) (vLLM's hc_head keeps it, where ERNIE's pre side takes 1 / (sqrt(mean) + eps)), pre = sigmoid(m r scale + base) + hc_eps, then sum_s pre_s x_s rounded to bf16 once. The row is checked against float64 (ernie5_5/mhc.zig), from the pre side's rows; gate 4 runs pre at 1/2 on one stream. Two controls: ERNIE's pre-side mix RMS, and the mixes without hc_head's scale.
… under the kernel contract tf_ernie55_mhc_pre_broadcast, in the ernie5_5_mhc image, is ERNIE 5.5's first-layer mHC pre as vLLM-ERNIE's broadcast forms it: the embedding row e as each of the 4 streams, its 24 mixes against fnb (fn's 4 column blocks summed at load, float32), the mix RMS 1 / (sqrt(mean) + eps) over e's own 4096 squares, then the pre side's pre, post, comb (Sinkhorn) and normed collapse, and e written into the 4 residual streams. The pre side's sums, its mixes' outputs and its norm become three inline functions the two kernels share; the pre side's usage is unchanged at the five SMs. Each output is checked alone against float64 (ernie5_5/mhc.zig, whose host test holds the broadcast to the pre side of e's 4 copies, bit for bit); gate 4 runs pre at 1/2 on half-integer rows. Two controls: the mix RMS's mean over pre's 4 x 4096 values, and e written into stream 0 alone.
…d RoPE, under the kernel contract tf_ernie55_hca_compress, in a new ernie5_5_hca image, forms each compressed row of ERNIE 5.5's HCA layers from its block of 128 tokens as vLLM's C128 compressor does: for each of the 512 channels, the softmax over the tokens of score + ape pooling the fp32 kv (the block's max, then expf of each difference summed and kv e accumulated in fma, the tokens in order, one division); the row's RMSNorm 1 / sqrt(mean + eps) times its weight; and GPT-J's pairs on the last 64 dims turned at the block's first position with YaRN's frequencies at compress_rope_theta; rounded to bf16 once. The rows are checked against float64 (ernie5_5/hca.zig, whose host test holds it to the vendor's two-stage pool); gate 4 sets every exponent to 0, with odd kv whose second half cancels the first. Two controls: the pool without ape, and the rope at the block's last position. hca.check also refuses strides whose furthest offsets, (128 rows - 1) ts + 1023 and (rows - 1) os + 511 floats, would pass the kernel's i64, so the launch's casts to its i64 arguments cannot trap.
…eeing 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.
de75602 to
6b67658
Compare
|
#5538's head |
|
Thank you, @Bizuayeu. Confirmed: the compressor contract clears So we'll land #5538 and close this one as included. Nothing more is needed from you here.
|
What this changes
tf_ernie55_hca_compress, in a newernie5_5_hcaimage: the compressor of ERNIE 5.5's HCA layers (37 of its 43, every layer but the six DSA ones), as vLLM's C128 compressor forms each compressed row from its block of 128 tokens, one row a block of 256 threads (two channels a thread). From the tokens' fp32 kv and score (the projection's output,kv_score), for each of the 512 channels alone: s_i = score_i + ape_i (ape indexed by the token's offset in the block, one fp32 add as vLLM's state stores it), M = max_i s_i, then e_i =expf(s_i - M)summed andkv_i e_iaccumulated in fma with the tokens in order, and one division; the row's RMSNorm1 / sqrt(mean + eps)(a thread's two squares, the warp's butterfly, the 8 warps in order) times the norm's weight; and GPT-J's pairs (448 + 2l, 449 + 2l) turned at the block's first position 128j with YaRN's frequencies atcompress_rope_theta, the angle the fp32 product of the frequency and the position, as vLLM'scos_sin_cacheholds it. The row is rounded to bf16 once, at the end. Nothing launches it yet, so served output is unchanged.One choice differs from the vendor's kernels: vLLM's pool takes each warp's max of 16 tokens and rescales the warps' sums by
exp2((m_w - M) log2e)with fast-mathexp2, and its norm and rope run in a second kernel; here one kernel takes the block's max first and oneexpfa token, so the bits are this kernel's own order, written above.zig/src/families/ernie5_5/hca.zigis the host's float64 compressor (its sums through thesum.ofthe contract's simulations share).hca_test.zigholds it to the vendor's two-stage pool, written as its kernel computes it (8 warps of 16 tokens, each warp's max and sums, rescaled by the max of maxes), the RMSNorm and the rope at the block's first position, plus pools that pick out one token by ape and the shapes it refuses.hca.checkrefuses strides whose furthest offsets, (128 rows - 1) ts + 1023 and (rows - 1) os + 511 floats, would pass the kernel's i64, so the launch's casts to its i64 arguments cannot trap; its test checks strides past i64 and one step past the bound at one and two rows.The contract (
zig/tests/cuda/contract_ernie5_5_hca.zig,tf-cuda-test ernie5_5-hca, also inkernel-contract) checks each row (bf16) against float64. The bound takes the pool's sums at depth 128 through the division and the norm, with their magnitude each channel's weighted mean of |kv| and its pool; the kernel's own roundings (the add of ape, the exponent's difference,expf's 2 ulp, the division, the norm's root and products,sincosf's 2 ulp and the turn's products) are added per output, as the DSA indexer keys' contract does. The shapes are 4 rows from block 3, the first block (where the rope turns nothing), a 64-row prompt chunk and the 1M context's last two blocks. Gate 4 sets every score to 4 - ape, so each exponent is 0 and every e is 1, with odd kv from 32,769 to 65,503 whose second half cancels the first but for a rest of 301 to 1,023 on the last token: every sum is exact in fp32 in any order, fp16's partial sums overflow and bf16's lose the rest. Two planted controls: the pool without ape, and the rope at the block's last position (128j + 127).The record (
ernie5_5_records.zig),cuda_hca.zig's launch, the image incuda_kernels.zigandkernels.zig, the runner's module,docs/kernel-contract.md, the usage line, and thegradient-serving.tsvpin forkernels.zig.Issue: Refs ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926: the HCA 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)).
Stacked on: cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324 (
9d16097ee1, the mHC broadcast) on cuda ernie5_5: hc_head, the last layer's 4 streams into one row, under the kernel contract #5318 (2fe3d3b370) on cuda ernie5_5: the mHC post side, a layer's output into its 4 streams, under the kernel contract #5311 (ff7009442a) on cuda ernie5_5: the mHC pre side, a row's mixes, Sinkhorn and the collapse's RMSNorm, under the kernel contract #5301 (01f035e6f4) on cuda ernie5_5: the DSA indexer's keys, k's LayerNorm then NeoX RoPE, under the kernel contract #5243 (9e339899f7) on cuda ernie5_5: the DSA key lists, top-k picks then the window, under the kernel contract #5211 (7103160ea0) on main469f1f7fd8, since it adds lines beside theirs in the family's lists; this pull request's own commit is the seventh on the branch: 17 files, 681 insertions, 3 deletions. Once they land, it rebases onto main.atc overlap --json: atc 0.9.4 withATC_READ_ONLY=1and cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's head (377da88efa, an earlier head of the same change) as the base (so this commit alone), run in this tree on 2026-11-27 at 07:01 UTC with--base 377da88efa:complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), 33 pull requests in its working tree's rows, 5conflicts, 5cleanand 23unknown.conflict_delta: each open pull request merged bygit merge-treewith cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's head (377da88efa) and with this head, conflicting files and hunks compared: over the 393 open pull requests on 2026-11-27 at 05:22 UTC, this commit adds a conflict to none.Checks on this head
370ac14616, on cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's7f36b770a8), 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-hca: SUMMARY ernie5_5 hca: 1 kernels, 1 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed;tf-cuda-test ernie5_5-mhc: SUMMARY ernie5_5 mhc: 9 kernels, 9 pass gates 1-4, 0 fail, 0 known findings; 8 controls: 8 red as planted, 0 missed;tf-cuda-test kernel-contract ernie5_5: SUMMARY 13 kernels: 13 pass gates 1-4, 0 fail, 0 known findings; 17 controls: 17 red as planted, 0 missed; 0 limit problems. Against cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's head7f36b770a8, 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_hca_compresslines (PASS ... (record current)); the one fatbin change is the added imageernie5_5_hca; the other 204 are the parent's to the byte. Host (zig build -Dfixed-cpu):test-ernie5_5-host42/44 tests passed (2 skipped),test-gradient-serving1/1 tests passed,test-kernel-contract368/368 tests passed. The items below are from before your rebase.3bf38677c2):9e4765a41dcuda ernie5_5: the HCA compressor's contract empties extra between freeing and reallocating it, as asked (cuda ernie5_5: the HCA compressor, a block's softmax pool, RMSNorm and RoPE, under the kernel contract #5326 (comment)); test code only,compile-cuda-tests12 of 12 steps on Windows,tools/pr_check.pyagainst the branch's base on main (043ee2bf60) 0 new, 0 errors.9d7cbf5ec8cuda ernie5_5: the HCA compressor, a block's softmax pool, RMSNorm and RoPE, under the kernel contract. It ise2b9fb5d63with the stride bounds inhca.checkand their test (cuda ernie5_5: the HCA compressor, a block's softmax pool, RMSNorm and RoPE, under the kernel contract #5326 (comment)); the kernel and its image are unchanged, and the contract's shapes are far inside the new bounds, so the GPU runs below stand. The GB10 gate below ran on9f75f66fb5and the WSL runs on8b8b10c459, this commit on the stack's earlier heads on main77eae824e4with gate 4's first fill; the GB10 contract ran again onaef4c9954d, this commit with the fill fixed on main469f1f7fd8. The kernel and host source is the same in all of them. Since, it was rebased onto cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324 and its CHANGELOG line took this pull request's number, and then took the stride bounds; on this head, the Windows checks.tools/pr_check.py --base 9d16097ee1 --pr 5326, this commit against cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's): 123 problems on both, 0 new; 0 errors. The 123 are inherited from main.9f75f66fb5checked out with an empty global cache and the tree's own cache andzig-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_hca_compresslinesPASS ... (record current)(32 registers at sm_80, 40 at the others, 32 static shared bytes, bound 256), and its other lines are cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's commit's (the same 186 stale records and RED and FAIL lines); the imageernie5_5_hcais added and every other fatbin equals cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's commit's.hca.cu's PTX: 33 compiles at each of compute_80, 86, 120 and 121 with address randomization on and off, one form at each. That run's gate 4 was red: its first fill (kv to 8,191, a rest of 1 to 7) left bf16 33.8x outside a bound that adds the kernel's own roundings, short of the 100x the gate asks. With the fill above, onaef4c9954d,tf-cuda-test ernie5_5-hcapasses gates 1-4: gate 1, 1,026 non-finite and 1,534 finite outputs in their float64 classes; gate 2, five runs byte-identical; gate 3, 4 shapes within the FP64 bound, the worst at 0.985 of it; gate 4, exact sums at k 128, where fp16 sums overflow and bf16 sums miss by 307x. Both controls are red (below).kernel-contract ernie5_5passes the thirteen ERNIE kernels with all 17 controls red, and that build's 191 stale records are main91dbadce65's, line for line.zig fmt --checkandzig ast-checkon the two Zig files the bounds touch (one2b9fb5d63, on the 13 changed Zig files);zig build test-ernie5_5-host40 of 42 passed, 2 skipped, and withe2b9fb5d63'shca.zigthe new test fails (39 of 42);zig build compile-cuda-tests12 of 12 steps,test-kernel-contract46 of 46 steps, 353 of 353 tests,test-gradient-serving1 of 1;pr_check: 0 errors.8b8b10c459in a clone of the stack, after cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's commit (so unchanged test modules are not run again):git diff --checkclean;zig build compile-cuda-tests12 of 12 steps;test-gradient-serving1 of 1;test-ernie5_5-host39 of 41, 2 skipped;test-kernel-contract46 of 46 steps, 338 of 338 tests;tools/zig/check_cuda_sources.pyonhca.cuwith clang++ 6 of 6;host_tests_testOK; CI's pytest from the root (-q -rs) 856 passed, 116 skipped, 827 subtests passed, the same skips as main's. The same steps onaef4c9954d, this commit's code on main469f1f7fd8:git diff --checkclean;compile-cuda-tests12 of 12 steps;test-gradient-serving1 of 1;test-ernie5_5-host39 of 41, 2 skipped;test-kernel-contract46 of 46 steps, 341 of 341 tests; clang++ 6 of 6;host_tests_testOK; pytest 861 passed, 116 skipped, 827 subtests passed, the same skips as main's.zig/build/cuda.zig,zig/build/cuda_kernels.zigandgradient-serving.tsv).Receipt
tf_ernie55_hca_compress, so no served token or byte can change. On the GB10, against cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's commit's tree built the same way, the imageernie5_5_hcais added and every other fatbin is byte-identical.9f75f66fb5(the GB10 gate) and8b8b10c459(WSL) on the stack's earlier heads on main77eae824e4, andaef4c9954d(the GB10 contract) on main469f1f7fd8; this head is the same change on cuda ernie5_5: the mHC broadcast, the first layer's pre from one row, under the kernel contract #5324's9d16097ee1; Zig 0.17.0, nvcc 13.0.88; one GB10 (sm_121); no checkpoint (synthetic blocks;compress_rope_theta,rope_scalingandrms_norm_epsfrom 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_hca_compress(new; replaces none), records for sm_80, 86, 89, 120 and 121 inzig/src/core/contract/ernie5_5_records.zig(32 registers at sm_80 and 40 at the others, 32 static shared bytes, bound 256; a 40-byte stack frame,sincosf's large-angle reduction, as the DSA indexer keys' kernel has).tf_ctl_ernie55_hca_compress_no_ape(the pool without ape), red atshapes("at 4x3x128 output 0 is 2.480469e-1 where float64 gives -1.455253e-1: 660.00 of its bound");tf_ctl_ernie55_hca_compress_last_position(the rope at the block's last position, 128j + 127), red atshapes(74.69 of its bound).SUMMARYline and exit status: onaef4c9954d,SUMMARY ernie5_5 hca: 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 13 kernels: 13 pass gates 1-4, 0 fail, 0 known findings; 17 controls: 17 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).expfa token, the vendor's two-stage fast-mathexp2aside).--drafter, no slower than without it, greedy and sampled (no served path changes).