Repository navigation
feat(hip): Inkling 2's dense bf16 projections under HIP-DOT-Q4 - #5797
Conversation
|
Thanks @AbrahamCete. This gives the HIP column Inkling 2's dense projections under the same HIP-DOT-Q4 order as the experts. The contract is thorough: seven planted controls that each go red, the row-37 invariance cell, and records for all four chips. What I checked at
Asks:
Once these are in, it's ready for our device check. On a Radeon 8060S (gfx1151), we'll run
|
e2fc9ce to
8f40f56
Compare
|
Both points are addressed on head
Re-verified on
The PR description is updated to match |
|
READY to land on this head. Reviewed at this head: nothing served calls the new kernel, and the Inkling 2 HIP modules now share one family module, which also repairs main's HIP kernel-contract build. On a Radeon 8060S (gfx1151): the HIP kernel tests and the Inkling 2 HIP host and state tests pass, the inkling2 image's 27 kernels and the new inkling2_dense image's 8 kernels pass the full contract, and every planted control goes red. This head's CI passed. Thank you!
|
…tract launchers Zig 0.17 requires each source file to belong to one module. After ashhart#5012, ashhart#4994, ashhart#5499 and ashhart#5728, inkling2_hip, inkling2_loop_hip, inkling2_experts_hip and the stream state targets all imported config.zig directly, causing duplicate module ownership inside tf-hip-kernel-contract. Group the shared Inkling 2 family files (config, plan, names, names_test, loop, kept_state, hip_weights, config_test) into zig/src/families/inkling2/hip_family.zig and pass one inkling2_family module into the Inkling 2 HIP launcher and state modules.
…erial dot baseline Inkling 2 Mini's dense projections (q, k, v, rel, gate, sink, a global layer's k and v taps, wo and the router's scores) get their own strict HIP group, inkling2_dense, under a named baseline: HIP-DOT-Q4. Input e goes to chain (e / 32) mod 4; each chain starts at +0 and runs ascending, one fmaf(w, x, acc) a step on bf16 w and x widened exactly; the chains join as (c0 + c1) + (c2 + c3); the result is rounded once to bf16, or kept in f32 where a segment asks for it. tf_ink2_dense takes up to eight segments of one depth in a launch, so a layer's attention projections are one launch and wo and the router one each. A quad of lanes computes an output, lane j running chain j, and one weight read serves up to 16 rows, so no sum depends on how a call groups its rows. hip_dense.zig reads every width and depth from the parsed config and refuses by name what the kernel cannot serve: UnsupportedDenseDepth for a hidden_size, wo depth or launch depth that is not a multiple of 128, Inkling2DenseShape for rows, segment counts and empty segments outside the kernel's range, Inkling2DenseAlign for bases off 16 bytes. The contract runs Inkling 2 Mini's and tiny-inkling2-mini's sliding and global attention calls, wo and the router at 1 to 2,048 rows, each output's bits against a host model of HIP-DOT-Q4. Its cells separate the chain assignment, the join and fmaf from the plausible other orders, and an invariance cell runs one row alone against its row of a 64-row call. Seven controls go red at shapes: W32 lanes, one serial chain, contiguous quarters, a sequential join, rounded products, x one row late, and two segments' outputs swapped.
….hpp Define lo16, hi16 and q4Join once in zig/kernels/hip/inkling2/zmath.hpp and reuse them from dense.hip, tile.hpp, loop.hip and experts.hip so the Inkling 2 HIP groups share one bf16 pair decoder and one HIP-DOT-Q4 quad join.
1ed1386 to
95b593d
Compare
|
Thank you @AbrahamCete. 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
Inkling 2 Mini on HIP has 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 dense bf16 projection kernel (
q,k,v,rel,gate,sink, globalk/vtaps,wo, and the router scores). This adds theinkling2_densekernel group (tf_ink2_dense) under theHIP-DOT-Q4serial dot baseline, its host geometry/refusal launcher, its host and GPU contract suite, its four-chip launch records, and itsdocs/kernel-contract.mdentry. No forward pass, serving path, or inference caller calls it yet.This branch carries three commits:
1978eadffbuild(hip): share Inkling 2 family files in one module across HIP contract launchers: Zig 0.17 requires each source file to belong to one module. After perf(hip): Inkling 2's loop kernels (cross-pass message and message gate) at hidden 2,304 and 256 under named HIP baselines #5012, feat(hip): Inkling 2's routed experts under HIP-DOT-Q4, the HIP column's serial dot baseline #4994, feat(hip): Inkling 2's attention at each layer's bias extent, tiny-inkling2-mini's 128 and 256 beside Mini's 1,024 #5499, and feat(hip): Inkling 2 Mini's per-stream state and prompt snapshots on one HIP rank #5728,inkling2_hip,inkling2_loop_hip,inkling2_experts_hip, and the stream state targets (hip_engine,hip_snapshot) all importedconfig.zigdirectly, causing duplicate module ownership insidetf-hip-kernel-contract. This groups the shared family files (config,plan,names,names_test,loop,kept_state,hip_weights,config_test) intozig/src/families/inkling2/hip_family.zigand passes one sharedinkling2_familymodule into the Inkling 2 HIP launcher and state modules.8f40f56fafeat(hip): Inkling 2's dense bf16 projections under HIP-DOT-Q4, the serial dot baseline: addszig/kernels/hip/inkling2/dense.hip(tf_ink2_denseplus seven planted controls),zig/src/families/inkling2/hip_dense.zig+hip_dense_test.zig,zig/tests/hip/contract_inkling2_dense.zig+contract_inkling2_dense_ref.zig,zig/src/core/contract/hip_records_inkling2_dense.zig, build/registry wiring, anddocs/kernel-contract.md.1ed1386a7refactor(hip): share bf16 lo16/hi16 and HIP-DOT-Q4 quad join in zmath.hpp: moves the packed bf16 unpack helpers (lo16,hi16) and the four-chainHIP-DOT-Q4pairwise join (q4Join) intozig/kernels/hip/inkling2/zmath.hpp(namespace ink2z), replaces the four local copies acrossdense.hip,tile.hpp,loop.hip, andexperts.hip, and updateship_records_inkling2_experts.zigfortf_ink2_mxfp8_gudropping from 95 to 94 VGPRs ongfx1100,gfx1151, andgfx1201.inkling2_dense), Refs Inkling 2 Mini on HIP (gfx1151): serve the looped 26.4B checkpoint natively #4265 (HIP column). Remaining for HIP2:inkling2_logits(U2, stacked in feat(hip): Inkling 2's logits under HIP-DOT-Q4, HIP-SOFTCAP-Z and HIP-TOP1 #5800),inkling2_conv(U4), andinkling2_norms(U3), followed by the HIP5 forward/lane/serve stack and HIP6 DSpark.main(f17dedbd9, includes feat(hip): Inkling 2 Mini's per-stream state and prompt snapshots on one HIP rank #5728). Commits added:1978eadff,8f40f56fa, and1ed1386a7(28 changed files total:+1,570/-81).atc overlap --json: run againstmainf17dedbd9. Three"conflicts"entries appear on append-only registry and contract doc files against unrelated open PRs (hip: ModelOpt NVFP4 and FP8 checkpoints keep their codes and decode in flight #2490 onzig/build/hip.zigandzig/src/core/contract/hip_records_families.zig, and ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522 and Ling-3.1-flash on CUDA, on one or two GB10s #2340 ondocs/kernel-contract.md). Zero overlaps with any Inkling 2 HIP PR or competing implementation.Checks on this head
1ed1386a7(onmainf17dedbd9, after feat(hip): Inkling 2 Mini's per-stream state and prompt snapshots on one HIP rank #5728 merged).python3 tools/zig/lean_check.py, on the base and on this head: base88problems (inherited), head88problems,0new (python3 tools/zig/lean_new.py:lean: 88 problems, 88 on the base, 0 new).zig fmt --check build.zig zigandgit diff --check f17dedbd9..HEAD: passed (0issues).zig build -Dhip=true test-inkling2-dense-hip-host:19passed,0failed,0skipped (hip_dense_test.zig11/11,contract_inkling2_dense_ref.zig8/8).zig build -Dhip=true test-inkling2-hip-state-host: passed (0failed).zig build -Dhip=true test-inkling2-hip-host: passed (0failed;names_test.zigskips 2 local checkpoint env-var tests).zig build -Dhip=true test-inkling2-loop-hip-host:33passed,0failed,0skipped.zig build -Dhip=true test-inkling2-experts-hip-host:27passed,0failed,0skipped.zig build -Dhip=true check-hip-kernel-contract-host: compiled clean.zig build -Dhip=true test-kernel-symbols-host:6passed,0failed,0skipped.zig build -Dhip=true -Dhipcc=$HIPCC hip-kernel-contract-limits:32/32 PASSforinkling2_dense(8 symbols acrossgfx1030,gfx1100,gfx1151,gfx1201,0scratch bytes,0stale records) and120/120 PASSforinkling2_experts(30 symbols across all 4 chips afterq4Joinsharing,0scratch bytes,0stale records).tf-hip-kernel-contract image inkling2_dense smokeon Radeon 8060S (gfx1151): exit0(8/8kernels pass gates 1-4,14/14controls red as planted,0limit problems).tf-hip-kernel-contract image inkling2_dense fullon Radeon 8060S (gfx1151): exit0(8/8kernels pass gates 1-4,14/14controls red as planted,0limit problems).tf-hip-kernel-contract image inkling2_experts smokeon Radeon 8060S (gfx1151, regression afterzmath.hppdedup): exit0(29/29kernels pass gates 1-4,62/62controls red as planted,0limit problems).1ed1386a7(fmt,pytest,zig,benchmark-clients (ubuntu-latest),comfyui-moss-installer; 6 optional jobs skipped).gfx1030,gfx1100, andgfx1201: only agfx1151machine is available here; those three targets were compiled and audited against their.hsacometadata viahip-kernel-contract-limits.bench_openai.py,bench_concurrent.py,bench_cache.py): n/a, no forward pass or server path reachesinkling2_denseyet.Receipt
n/a: no forward, server, or inference path reaches
inkling2_denseyet. The host model tests (19/19), four-chip.hsacolimits audit (32/32 PASSdense,120/120 PASSexperts), andgfx1151GPU kernel contracts (inkling2_densesmoke + full andinkling2_expertssmoke, all exit0) are the evidence.inkling2_denseyet).f17dedbd9/ head1ed1386a7, 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-contractsha256a7cde3d60569439b25dc72abd898625af39a4a8b389b8fc7abd5f8fc5229f414; checkpoint: n/a (synthetic contract inputs covering Inkling 2 Mini andtiny-inkling2-minigeometries).inkling2_densekernel contract (tf_ink2_denseand 7 controls),zmath.hppshared helpers acrossdense.hip,tile.hpp,loop.hip, andexperts.hip, pluship_family.zigshared acrossinkling2,inkling2_loop,inkling2_experts, andhip_engine/hip_snapshot. GPU-executed ongfx1151; compiled and ELF-limit-audited ongfx1030,gfx1100,gfx1151, andgfx1201; not GPU-executed ongfx1030,gfx1100, orgfx1201(hardware unavailable).HIP-DOT-Q4host model incontract_inkling2_dense_ref.zigacross rows{1, 4, 8, 16, 64, 128, 2048}, including solo row-37 invariance against a 64-row call, plus bit-exactinkling2_expertsregression.Kernel contract, only when a GPU kernel is new or changed
tf_ink2_densein groupinkling2_dense(new baseline kernel for Inkling 2 dense bf16 projections underHIP-DOT-Q4; replaces no prior HIP kernel). Registered across 8 checkpoint calls: Inkling 2 Mini andtiny-inkling2-minisliding attention, global attention (withk/vtaps),wo, andf32router scores.inkling2_experts(tf_ink2_mxfp8_gu) keeps bit-exact behavior after sharingink2z::q4Joinand drops 1 VGPR (95 -> 94) ongfx1100,gfx1151, andgfx1201.tiny-inkling2-miniglobal layers (14 control runs total, all 14 red atshapes):tf_ink2_dense_ctl_w32(W32 lanes instead ofHIP-DOT-Q4chains)tf_ink2_dense_ctl_serial(single serialfmafchain)tf_ink2_dense_ctl_quarters(contiguous quarters per chain)tf_ink2_dense_ctl_seq_join(((c0 + c1) + c2) + c3sequential join)tf_ink2_dense_ctl_unfused(products rounded before add)tf_ink2_dense_ctl_row_late(xread one row late)tf_ink2_dense_ctl_neighbour(qandkwritten into each other's output)SUMMARYline and exit status:gfx1151inkling2_densesmoke (exit0):SUMMARY inkling2_dense HIP smoke: 8 kernels: 8 pass gates 1-4, 0 fail, 0 known findings; 14 controls: 14 red as planted, 0 missed; 0 limit problems; gates 6135 ms, limits 5 msgfx1151inkling2_densefull (exit0):SUMMARY inkling2_dense HIP full: 8 kernels: 8 pass gates 1-4, 0 fail, 0 known findings; 14 controls: 14 red as planted, 0 missed; 0 limit problems; gates 15645 ms, limits 5 msgfx1151inkling2_expertssmoke regression (exit0):SUMMARY inkling2_experts HIP smoke: 29 kernels: 29 pass gates 1-4, 0 fail, 0 known findings; 62 controls: 62 red as planted, 0 missed; 0 limit problems; gates 12352 ms, limits 46 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-DOT-Q4, no inference caller)--drafter, no slower than without it, greedy and sampled. (n/a: no inference caller)