Repository navigation
Inkling 2's attention kernels under the kernel contract - #4125
Conversation
68c6bb7 to
2247c75
Compare
|
@ajensenwaud @ashhart I checked
The test merge into Igor Lessio - AIFLOW LABS |
|
Thank you @ajensenwaud. 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. |
1 similar comment
|
Thank you @ajensenwaud. 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. |
…ith its bound and probes
…ith its bound and probes
Move ashhart#4125's float64 attention reference from zig/tests/cuda into core.contract.inkling2_attn_ref so the HIP contract can hold its kernels to the same rounding points. A Call now names its query heads, key heads and fp32 chains (Chain.cuda by default, Chain.hip for scalar IEEE sums), and tauAt takes the model's n_floor (Mini's is 8,192). CUDA's defaults are unchanged: the CUDA tests only change their import, and a pinned test holds row() at CUDA's defaults to the bits the old reference gave (checked bit for bit against it on sliding and global rows before the move). Checks: zig test of core.contract (17 pass); zig build test-inkling2-cuda-host (10/10) and compile-cuda-tests on the tree.
A new inkling2 kernel group (strict IEEE build) with ashhart#4125's rounding points on HIP: tf_ink2_prep (q/k L2 clips, tau on global layers, the gamma-free v norm, k and v into each segment's ring), tf_ink2_rel_table, chunked attention for sliding (tf_ink2_attn) and global layers (tf_ink2_attn_fold, a split form a block a 1,024-key sub-chunk, and tf_ink2_attn_prompt), and the ordered merge that takes the sink and the gate raw. One wave holds a (row, head) pair over 64-key K/V tiles in LDS with scalar fp32 sums; every path runs the same per-pair steps, so split and prompt are bit-equal to the fold. The prompt kernel shares each tile among 8 pairs in one 37 KiB LDS stage while the next tile loads into registers. The kernels build for gfx1030, gfx1100, gfx1151 and gfx1201 (no scratch; records in hip_records_inkling2.zig). The launcher (families/inkling2/hip_attention.zig) keeps heads, key heads, floor and clips as runtime arguments and per-segment cache offsets, as ashhart#4125's; whole-stream rings versus 64-position pages for global KV stays open with the maintainer. The contract entry (tf-hip-kernel-contract image inkling2) holds them at Mini's 24/8 heads and n_floor 8,192 to core.contract's FP64 reference with HIP's chains, at served shapes to 1M keys on a ring that wraps; three streams in one launch are bit-equal to each stream alone (prep, sliding, fold, split). Eight controls go red at shapes, among them a window one key long, the sink and gate given after their sigmoid (ashhart#4387's glue) and a prep writing one stream's keys into another's. Checks on gfx1151 with ROCm 10.1's hipcc: image inkling2 smoke and full, 11 kernels pass gates 1-4, 8 controls red, 0 limit problems; hip-kernel-contract-limits passes all 24 inkling2 records (its 11 remaining problems are other groups' records); test-inkling2-hip-host, check-hip-kernel-contract-host; lean 165 on base and head, 0 new.
Move ashhart#4125's float64 attention reference from zig/tests/cuda into core.contract.inkling2_attn_ref so the HIP contract can hold its kernels to the same rounding points. A Call now names its query heads, key heads and fp32 chains (Chain.cuda by default, Chain.hip for scalar IEEE sums), and tauAt takes the model's n_floor (Mini's is 8,192). CUDA's defaults are unchanged: the CUDA tests only change their import, and a pinned test holds row() at CUDA's defaults to the bits the old reference gave (checked bit for bit against it on sliding and global rows before the move). Checks: zig test of core.contract (17 pass); zig build test-inkling2-cuda-host (10/10) and compile-cuda-tests on the tree.
A new inkling2 kernel group (strict IEEE build) with ashhart#4125's rounding points on HIP: tf_ink2_prep (q/k L2 clips, tau on global layers, the gamma-free v norm, k and v into each segment's ring), tf_ink2_rel_table, chunked attention for sliding (tf_ink2_attn) and global layers (tf_ink2_attn_fold, a split form a block a 1,024-key sub-chunk, and tf_ink2_attn_prompt), and the ordered merge that takes the sink and the gate raw. One wave holds a (row, head) pair over 64-key K/V tiles in LDS with scalar fp32 sums; every path runs the same per-pair steps, so split and prompt are bit-equal to the fold. The prompt kernel shares each tile among 8 pairs in one 37 KiB LDS stage while the next tile loads into registers. The kernels build for gfx1030, gfx1100, gfx1151 and gfx1201 (no scratch; records in hip_records_inkling2.zig). The launcher (families/inkling2/hip_attention.zig) keeps heads, key heads, floor and clips as runtime arguments and per-segment cache offsets, as ashhart#4125's; whole-stream rings versus 64-position pages for global KV stays open with the maintainer. The contract entry (tf-hip-kernel-contract image inkling2) holds them at Mini's 24/8 heads and n_floor 8,192 to core.contract's FP64 reference with HIP's chains, at served shapes to 1M keys on a ring that wraps; three streams in one launch are bit-equal to each stream alone (prep, sliding, fold, split). Eight controls go red at shapes, among them a window one key long, the sink and gate given after their sigmoid (ashhart#4387's glue) and a prep writing one stream's keys into another's. Checks on gfx1151 with ROCm 10.1's hipcc: image inkling2 smoke and full, 11 kernels pass gates 1-4, 8 controls red, 0 limit problems; hip-kernel-contract-limits passes all 24 inkling2 records (its 11 remaining problems are other groups' records); test-inkling2-hip-host, check-hip-kernel-contract-host; lean 165 on base and head, 0 new.
Move #4125's float64 attention reference from zig/tests/cuda into core.contract.inkling2_attn_ref so the HIP contract can hold its kernels to the same rounding points. A Call now names its query heads, key heads and fp32 chains (Chain.cuda by default, Chain.hip for scalar IEEE sums), and tauAt takes the model's n_floor (Mini's is 8,192). CUDA's defaults are unchanged: the CUDA tests only change their import, and a pinned test holds row() at CUDA's defaults to the bits the old reference gave (checked bit for bit against it on sliding and global rows before the move). Checks: zig test of core.contract (17 pass); zig build test-inkling2-cuda-host (10/10) and compile-cuda-tests on the tree.
A new inkling2 kernel group (strict IEEE build) with #4125's rounding points on HIP: tf_ink2_prep (q/k L2 clips, tau on global layers, the gamma-free v norm, k and v into each segment's ring), tf_ink2_rel_table, chunked attention for sliding (tf_ink2_attn) and global layers (tf_ink2_attn_fold, a split form a block a 1,024-key sub-chunk, and tf_ink2_attn_prompt), and the ordered merge that takes the sink and the gate raw. One wave holds a (row, head) pair over 64-key K/V tiles in LDS with scalar fp32 sums; every path runs the same per-pair steps, so split and prompt are bit-equal to the fold. The prompt kernel shares each tile among 8 pairs in one 37 KiB LDS stage while the next tile loads into registers. The kernels build for gfx1030, gfx1100, gfx1151 and gfx1201 (no scratch; records in hip_records_inkling2.zig). The launcher (families/inkling2/hip_attention.zig) keeps heads, key heads, floor and clips as runtime arguments and per-segment cache offsets, as #4125's; whole-stream rings versus 64-position pages for global KV stays open with the maintainer. The contract entry (tf-hip-kernel-contract image inkling2) holds them at Mini's 24/8 heads and n_floor 8,192 to core.contract's FP64 reference with HIP's chains, at served shapes to 1M keys on a ring that wraps; three streams in one launch are bit-equal to each stream alone (prep, sliding, fold, split). Eight controls go red at shapes, among them a window one key long, the sink and gate given after their sigmoid (#4387's glue) and a prep writing one stream's keys into another's. Checks on gfx1151 with ROCm 10.1's hipcc: image inkling2 smoke and full, 11 kernels pass gates 1-4, 8 controls red, 0 limit problems; hip-kernel-contract-limits passes all 24 inkling2 records (its 11 remaining problems are other groups' records); test-inkling2-hip-host, check-hip-kernel-contract-host; lean 165 on base and head, 0 new.
What this changes
Adds Inkling 2's attention kernels, with a relative-position bias, a sink and a sigmoid gate on every head, their launcher in a new
inkling2module, and their registration with the kernel contract. Nothing serves them until the family PR at the top of the stack.f0d5ddb74.atc overlap --json: incomplete (ATC's limits). Conflicts only in shared append lists (CHANGELOG.md, the CUDA build and kernel lists, contract joins and limits), with CUDA: #1764's BF16 prompt tile for Qwen ModelOpt, Nemotron and Dory, plus two exact Qwen prompt kernels (#1762) #2008, Unlimited-OCR-2 on CUDA: the family's steps on NVIDIA GPUs (sm_89 and up) #2077, moss image: serve pictures on CUDA (encoder, decoder and host for #1573) #2281, lanes: LFM3's row draw and Flash Next's host reference draw use core's sampling_row (#2460 item 3, step 2) #2679 and server: --vision-image-share fixed gives every image the same share of the visual-token budget (#2510) #2717.Checks on this head
2247c754b; lean checker 168 on the base, 168 on this head, 0 new.zig build test test-golden test-inkling2-cuda-host compile-cuda-tests: 10,925 of 11,016 tests, 91 skipped on mainc94e65d33; rebased ontof0d5ddb74, rechecked there: the CUDA tests compile and the family host tests pass;test-gradient-servingpasses withkernels.zigre-pinned.zig fmt --check build.zig zigandgit diff --check: clean. CI: pending.Receipt
n/a: no served path reaches these kernels yet.
Kernel contract
tf_ink2_prep(sliding and full),tf_ink2_rel_table,tf_ink2_attnandtf_ink2_attn_foldwithtf_ink2_merge, andtf_ink2_attn_prompt, which replaces fold and merge bit for bit. They use common'sqmm_fragmma and ldmatrix andtf_commoncp.async; nvcc 13.3 gives the same SASS as with local copies on sm_80, 86, 89, 120 and 121.4fda6a020, 19 November, with the same family and contract files:SUMMARY 55 kernels: 55 pass gates 1-4, 0 fail, 0 known findings; 35 controls: 35 red as planted, 0 missed; 0 limit problems, exit 0. This PR's share is 7 registrations and 5 controls.kernel-contracton that head and on main alone: 388 limit problems and 8 known findings on both, and no failure on the head that main does not show.