Repository navigation
feat(hip): Inkling 2's embedding norm and attention residuals under HIP-RMS-W32, HIP-RETRIEVE-W32, HIP-NORM-W and HIP-AR-SHARES - #5813
Conversation
78203fa to
2f20cb0
Compare
|
Thanks for the final HIP2 kernel group and the byte-identity proof for the shared header. Decision: ready for our review. No device cells are owed by anyone - the gfx1151 run is yours and is the accepted form for HIP, the other chips' What stands: the three kernels (
|
…ling2/w32.hpp, with their host model The Inkling 2 norms and attention residuals reuse the loop kernels' named baselines. inkling2/w32.hpp holds their device steps over inkling2/zmath.hpp's lo16/hi16: element e to lane (e / 8) % 32, each lane's chain ascending from +0 by fmaf, the xor butterfly 1, 2, 4, 8, 16, and rho's inverse 1 / sqrt(s / n + eps) with a correctly rounded square root and division. inkling2/loop.hip now includes inkling2/w32.hpp instead of duplicating those helpers (identical gfx1151 .text disassembly). contract_inkling2_norms_w32.zig restates them on the host with the loop contract's definitions of sumIn, w32Sum, inverseAt and depthW32, and with its dot and rho cells: the dot cell sums to 1 under W32, 0 in one serial chain and 2 with the butterfly reversed; the rho cell's squares sum to 2^24 + 31 x hidden / 32 under W32 and to 2^24 in one serial chain. test-inkling2-norms-hip-host runs them.
…IP-RMS-W32, HIP-RETRIEVE-W32, HIP-NORM-W and HIP-AR-SHARES The inkling2_norms group (inkling2/norms.hip, a block a row) serves three kernels. tf_ink2_embed norms each token's table row by embed_norm. tf_ink2_ar writes the raw f32 attention residual of up to eight completed blocks and a bf16 or f32 partial against one to three f32 queries. tf_ink2_mix writes that residual normed by each query's weight in bf16, and with no query norms the partial alone, which serves layer 0's attention and the gated rows. HIP-RMS-W32 and HIP-RETRIEVE-W32 are the loop kernels' W32 sums, through inkling2/w32.hpp and their host model. HIP-NORM-W is bf16(w * (x * inv)), two f32 multiplies and one round. HIP-AR-SHARES takes the max from -inf, Zig's f32 exp of each difference, their sum from +0 and each quotient, then h = (+0 + w_0 z_0) + w_1 z_1 ..., unfused, in ascending source order. hip_norms.zig reads hidden_size, rms_norm_eps and the residual's sources from the config and refuses a hidden size that is not a multiple of 256 by name (UnsupportedNormsHidden); the launches also refuse more than eight blocks (UnsupportedNormsSources), more than three queries (UnsupportedNormsQueries), bad shapes and unaligned bases. The contract checks every output's bits against the host model at Mini's and tiny-inkling2-mini's shapes, 1 to 2,048 rows and one to nine sources, plus a cell at rms_norm_eps 0.25. It plants 35 controls, each red at shapes. Records cover all four chips.
…orms on inkling2_family
2f20cb0 to
735b6cd
Compare
Synthena Initial Review — Needs changes (
|
|
Addressed in fast-forward commit
No |
|
READY to land on this head. Re-check of this head: the geometry() unreachable is now an explicit UnsupportedNormsSources refusal with a host test. HIP evidence is the author's gfx1151 contract run (21/21 kernels, 35/35 controls red); no inference caller on main reaches it yet.
|
What this changes
Inkling 2 Mini on HIP has dense projections (#5797), logits (#5800), short convolutions/rewind/router (#5809), attention (#4633, #5499), loop kernels (#5012), routed experts (#4994), text weights (#5031), serve-flag refusals (#5034), and per-stream state/snapshots (#5728), but no HIP embedding norm or attention-residual mixing kernels. This adds the final HIP2 kernel group,
inkling2_norms(tf_ink2_embed,tf_ink2_ar,tf_ink2_mix), under four named baselines (HIP-RMS-W32,HIP-RETRIEVE-W32,HIP-NORM-W,HIP-AR-SHARES), shares the W32 device helpers (inkling2/w32.hpp, reused byloop.hipand auto-tracked byhip_headers.zig) and the W32 host model (contract_inkling2_w32.zig, reused bycontract_inkling2_loop_ref.zig), wireship_norms.zigdirectly oninkling2_family, and adds host and GPU contract suites, four-chip launch records, anddocs/kernel-contract.mdentries. No forward pass, serving path, or inference caller calls it yet.Rebased onto
main11729eec9(after #5809 merged at7df094676, keepingmain'ship_headers.zigauto-collector), this PR adds four commits (18changed files):e17851cd3feat(hip): carry HIP-RMS-W32 and HIP-RETRIEVE-W32's W32 sums into inkling2/w32.hpp, with their host model: addszig/kernels/hip/inkling2/w32.hpp(usingink2z::lo16/hi16frominkling2/zmath.hppfor bf16 chunk loads, plusld4,invSqrt,inverse,butterfly,squares, anddot), switcheszig/kernels/hip/inkling2/loop.hipto reuseinkling2/w32.hpp(.textand.notesections ofloop.hipare byte-identical before vs after across all four chips:gfx1030,gfx1100,gfx1151,gfx1201), and adds the W32 host model and order cells.b8fd87ef1feat(hip): Inkling 2's embedding norm and attention residuals under HIP-RMS-W32, HIP-RETRIEVE-W32, HIP-NORM-W and HIP-AR-SHARES: addszig/kernels/hip/inkling2/norms.hip(tf_ink2_embed,tf_ink2_ar,tf_ink2_mix, and 19 planted controls),zig/src/families/inkling2/hip_norms.zig+hip_norms_test.zig(config-driven geometry and refusals:UnsupportedNormsHidden,UnsupportedNormsSources,UnsupportedNormsQueries),zig/tests/hip/contract_inkling2_norms{,_plan,_ref,_ref_test}.zig,zig/src/core/contract/hip_records_inkling2_norms.zig, build/registry wiring, anddocs/kernel-contract.md.735b6cd37refactor(hip): share W32 host reference with loop and wire inkling2_norms on inkling2_family: renames the W32 host model tozig/tests/hip/contract_inkling2_w32.zigand shares it withcontract_inkling2_loop_ref.zig(removing ~120 duplicated lines), and wireship_norms.zigandhip_norms_test.zigdirectly oninkling2_family(droppingnorms_denseinhip_contract.zig).ca65baf1efix(hip): refuse zero or excess residual blocks in hip_norms.geometry: addresses review feedback by replacingdivCeil ... catch unreachableinhip_norms.geometrywith explicitUnsupportedNormsSourcesrefusals (block == 0andblocks > max_blocks) + host unit test, and updatesdocs/kernel-contract.mdto namecontract_inkling2_w32.zig(no.hip/.hppchanges).inkling2_norms, final HIP2 slice), Refs Inkling 2 Mini on HIP (gfx1151): serve the looped 26.4B checkpoint natively #4265 (HIP column). Next after HIP2: the HIP5 forward/lane/serve stack and HIP6 DSpark.main11729eec9(contains merged feat(hip): Inkling 2's short convolutions, rewind and router under named baselines #58097df094676). Commits this PR adds:e17851cd3,b8fd87ef1,735b6cd37, andca65baf1e(18changed files).Checks on this head
ca65baf1e(fast-forward host/doc fix over735b6cd37onmain11729eec9; no.hip/.hppfiles changed).python3 tools/zig/lean_check.py:88problems across9,759files (0new overmain;zig/build/hip.zigis595lines).python3 tools/zig/env_lookups.py: passed (0issues).zig fmt --check build.zig zigandgit diff --check origin/main..HEAD: passed (0issues).zig build -Dhip=true -Dhipcc=/bin/false test-inkling2-norms-hip-host test-inkling2-loop-hip-host check-hip-kernel-contract-hostonca65baf1e(and full 7-suite host run includingtest-inkling2-conv-hip-host test-hip-headers test-create-defaults-host test-kernel-symbols-hoston735b6cd37): passed (0failed).zig build hip-kernel-contract-limits -Dhip=true -Dhip-arch=gfx1151 -Dhipcc=$HIPCC:inkling2_norms88/88 PASS,0fail (0scratch bytes,0stale records acrossgfx1030/gfx1100/gfx1151/gfx1201).loop.hipcode-object parity before vs afterw32.hppextraction (clang-offload-bundler --unbundle+llvm-objcopy --dump-section .text+llvm-readelf --notes):.textand.notebyte-identical across all four chips (gfx1030,gfx1100,gfx1151,gfx1201).tf-hip-kernel-contract image inkling2_norms smokeon Radeon 8060S (gfx1151): exit0(21/21kernels pass gates 1-4,35/35controls red as planted,0limit problems).tf-hip-kernel-contract image inkling2_norms fullon Radeon 8060S (gfx1151): exit0(21/21kernels pass gates 1-4,35/35controls red as planted,0limit problems).tf-hip-kernel-contract image inkling2_loop smokeon Radeon 8060S (gfx1151):7/7kernels pass gates 1-4,21/21controls red as planted (328 ms; the 21 live limit mismatches are pre-existing toolchain drift onmain, unchanged byw32.hpp).735b6cd37(zig,fmt,pytest,verify); will re-run after fast-forward pushingca65baf1e.gfx1030,gfx1100, andgfx1201: only agfx1151machine is available here; all four chips'.hsacometadata passedhip-kernel-contract-limits(88/88 PASS,0scratch bytes,0stale records) andloop.hip.text/.noteparity held across all four chips.bench_openai.py,bench_concurrent.py,bench_cache.py): n/a, no forward pass or server path reachesinkling2_normsyet.Receipt
n/a: no forward, server, or inference path reaches
inkling2_normsyet. The host tests (-Dhipcc=/bin/false), four-chip.hsacolimits audit (88/88 PASS), four-chiploop.hip.text/.notebyte-identity check, andgfx1151GPU kernel contracts (inkling2_normssmoke + full, both exit0, plusinkling2_loopsmoke7/7gates +21/21controls red) are the evidence.inkling2_normsyet).main11729eec9(includes merged feat(hip): Inkling 2's short convolutions, rewind and router under named baselines #58097df094676), headca65baf1e(GPU contract runs from735b6cd37; zero.hip/.hppchanges inca65baf1e), Zig0.17.0, ROCm TheRock10.1.0(HIP version: 7.16.26385-0000000,AMD clang version 24.0.0git), Ubuntu26.04.1 LTS(kernel7.0.0-44-generic), Radeon 8060S (gfx1151),tf-hip-kernel-contractsha256daf5767c620bc3d89c994482e0a8085a5f26c0a4ba416e402fc2e5d14278ca73; checkpoint: n/a (synthetic contract inputs covering Inkling 2 Mini,tiny-inkling2-mini, and anrms_norm_eps = 0.25cell).inkling2_norms(tf_ink2_embed,tf_ink2_ar,tf_ink2_mix, and 19 control kernels) andinkling2/loop.hip(w32.hppheader share, byte-identical.textand.noteacross all four chips). GPU-executed ongfx1151; compiled and ELF-limit-audited ongfx1030,gfx1100,gfx1151, andgfx1201; not GPU-executed ongfx1030,gfx1100, orgfx1201(hardware unavailable).contract_inkling2_w32.zigandcontract_inkling2_norms_ref.zig(HIP-RMS-W32,HIP-RETRIEVE-W32,HIP-NORM-W,HIP-AR-SHARES) across 1 to 2,048 rows, 1 to 9 sources, 1 to 3 queries, bf16 and f32 partials, andrms_norm_eps = 0.25, including solo row-37 invariance against a 64-row call.Kernel contract, only when a GPU kernel is new or changed
tf_ink2_embed,tf_ink2_ar, andtf_ink2_mixin groupinkling2_norms(new baseline kernels underHIP-RMS-W32,HIP-RETRIEVE-W32,HIP-NORM-W, andHIP-AR-SHARES; replace no prior HIP kernels). Registered across 21 entries: 9 for Inkling 2 Mini (hidden = 2,304, 5 sources), 9 fortiny-inkling2-mini(hidden = 256, 4 sources), and 3 atrms_norm_eps = 0.25(embed,ar,mix).eps_fixedatrms_norm_eps = 0.25), all 35 red atshapes:tf_ink2_embed(3 controls):tf_ink2_embed_ctl_serial_rho,tf_ink2_embed_ctl_norm_bf16,tf_ink2_embed_ctl_eps_fixed.tf_ink2_ar(9 controls):tf_ink2_ar_ctl_rsqrt,tf_ink2_ar_ctl_serial_rho,tf_ink2_ar_ctl_serial_dot,tf_ink2_ar_ctl_butterfly_desc,tf_ink2_ar_ctl_unfused_sq,tf_ink2_ar_ctl_fused_shares,tf_ink2_ar_ctl_sources_desc,tf_ink2_ar_ctl_expf,tf_ink2_ar_ctl_eps_fixed.tf_ink2_mix(7 controls):tf_ink2_mix_ctl_serial_rho,tf_ink2_mix_ctl_butterfly_desc,tf_ink2_mix_ctl_h_bf16,tf_ink2_mix_ctl_skip_source,tf_ink2_mix_ctl_norm_bf16,tf_ink2_mix_ctl_no_norm,tf_ink2_mix_ctl_eps_fixed.SUMMARYline and exit status:gfx1151inkling2_normssmoke (exit0):SUMMARY inkling2_norms HIP smoke: 21 kernels: 21 pass gates 1-4, 0 fail, 0 known findings; 35 controls: 35 red as planted, 0 missed; 0 limit problems; gates 125 ms, limits 14 msgfx1151inkling2_normsfull (exit0):SUMMARY inkling2_norms HIP full: 21 kernels: 21 pass gates 1-4, 0 fail, 0 known findings; 35 controls: 35 red as planted, 0 missed; 0 limit problems; gates 1104 ms, limits 14 msgfx1151inkling2_loopsmoke (gates/controls PASS, 21 pre-existingmainlimit mismatches):SUMMARY inkling2_loop HIP smoke: 7 kernels: 7 pass gates 1-4, 0 fail, 0 known findings; 21 controls: 21 red as planted, 0 missed; 21 limit problems; gates 328 ms, limits 21 msgfx1030,gfx1100,gfx1201(compiled and verified with0limit problems viahip-kernel-contract-limits; not GPU-executed due to no local hardware).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (n/a: no inference caller)HIP-RMS-W32,HIP-RETRIEVE-W32,HIP-NORM-W,HIP-AR-SHARES, no inference caller)--drafter, no slower than without it, greedy and sampled. (n/a: no inference caller)