Skip to content

train 1124030407: #4633 (CI only) - #4832

Closed
ashhart wants to merge 8 commits into
mainfrom
lead/train-1124030407
Closed

ashhart wants to merge 8 commits into
mainfrom
lead/train-1124030407

Conversation

@ashhart

@ashhart ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #4633 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.

AbrahamCete and others added 8 commits November 24, 2026 03:04
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.
The verifier's pins for core.contract.inkling2_attn_ref at CUDA's
defaults: keys past the bias extent, a full sliding window, the exact
(gate 4) branch, a NaN q and a +inf sink, gate 4's replay in fp32 and
bf16, and tau at Small's floor. The bits come from the base file
(5c1fea6:zig/tests/cuda/contract_inkling2_attn_ref.zig).

Checks: zig test of core.contract, 18 pass.
The verifier's edge cases for the HIP contract: global (fold) rows at
positions 0 to 1,024 held to float64 rather than only bit-compared, a
lone sliding row at 0, prep at pos + 1 = 8,193 and 8,194 just past
Mini's floor, and a NaN sink and a NaN gate planted beside gate 1's
infinities.
attend() now refuses a layer whose ring is not whole 64-key tiles
(error.Inkling2RingTiles: a tile's load never wraps), or is shorter
than its window plus the call's rows less one (error.Inkling2RingShort:
the rows' new keys would overwrite keys an earlier row still reads),
before any launch. The contract's rings (3,072 sliding, 4,096 global)
and Layer.sliding/global already meet both.

Checks: test-inkling2-hip-host 8/8 (two new tests, red before the
check), check-hip-kernel-contract-host.
The float64 bound allows P's bf16 rounding either way, so a kernel
that kept P unrounded stayed green. Two registrations (sliding, fold)
now make every output exact: rows below position 64 (one tile), q 0,
no sink, a gate whose sigmoid is 1, integer values in [-16, 16], bias
2 at distance 0 and the rest drawn so each bf16(exp2f) sits over 2^-21
from a tie. Every P is then at least 2^-5, both of its sums are exact
in fp32, and each output must equal bf16(fp32(sum P v / sum P)) bit for
bit. A host test shows an unrounded P moves 19,232 of 49,152 outputs.

docs/kernel-contract.md states the cases and the ring refusals, and
gives the prompt kernel's LDS as 37,120 bytes (36.25 KiB).

Checks on gfx1151: image inkling2 full, 13 kernels pass gates 1-4, 8
controls red, 0 limit problems. With the verifier's m1_p_unrounded
mutation, smoke goes red on exactly these two cases (11 of 13 pass).
test-inkling2-hip-host, check-hip-kernel-contract-host,
test-inkling2-cuda-host, compile-cuda-tests; lean 165, 0 new.
… stated

Rows.streams has no default any more: a caller states how many
segments `segs` holds, so a multi-stream call that forgets it no
longer compiles into the one-stream prompt kernel, which reads only
segs[0] and ignores the tiles. A call with no streams is refused
(error.Inkling2Streams). `slots` is now the partials the buffers hold,
and attend() refuses fewer than rows x heads x stride before any launch
(error.Inkling2PartialRoom); a split still needs 16 times that. The
contract's calls pass their real room, so their paths are unchanged.

A global position past the ring is not refused: the contract's
4,096-slot ring over 1M keys wraps on purpose. Layer.global and the
contract docs say the engine glue keeps a global layer's positions
inside its ring.

Checks: test-inkling2-hip-host 11/11 (two new tests, red before the
change); test-inkling2-cuda-host and compile-cuda-tests; on gfx1151,
image inkling2 full: 13 kernels pass gates 1-4, 8 controls red, 0 limit
problems. Lean 165 on base and head, 0 new.
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Landed: #4633 as main ef4dd75. This PR only carried their CI.

@ashhart ashhart closed this Nov 24, 2026
@ashhart
ashhart deleted the lead/train-1124030407 branch November 24, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants