Repository navigation
feat(hip): Inkling 2 Mini's per-stream state and prompt snapshots on one HIP rank - #5728
Merged
Merged
Conversation
AbrahamCete
force-pushed
the
feat/hip-inkling2-state
branch
from
November 30, 2026 21:15
ffef60a to
fca4a67
Compare
AbrahamCete
marked this pull request as ready for review
November 30, 2026 21:15
ashhart
force-pushed
the
feat/hip-inkling2-state
branch
from
December 1, 2026 02:14
fca4a67 to
cb82cb7
Compare
Owner
|
READY to land on this head. Reviewed at this head: Inkling 2 Mini's HIP stream state and snapshots are not yet used by serving. On a Strix Halo (gfx1151) the host steps passed and the device test passed 5 of 5: save, clobber and restore, in place and at another capacity, every byte equal. This head's CI passed.
|
hip_engine.zig is the HIP twin of loop_engine.zig's Model without the forward. Each stream owns a slot of five buffers: the visit cache that loop.CacheLayout sizes, four 32-byte rewind sites a visit (conv.hip's and ops.cu's RewindSite layout), the conv states' backup, a 16-row window history and the last prompt row's FP32 logits. HIP's draws keep no per-stream sampling rule, so stream_bytes has no rule buffer. addSlots writes each slot's site table and zeroes its conv states; reset zeroes the current slot's. The forward's shared scratch follows CUDA's buffer list, with hip_attention.zig's partial slots and the routed experts' activation and down rows, allocated once at init. Before any allocation the state refuses, by name and with a log line, a config without a loop, gates other than rank 64, global and sliding KV widths that differ (CacheLayout sizes every conv by the sliding width), a context of zero or past text_config.model_max_length (Mini names max_position_embeddings only under mtp_config, so the HIP host reads no window), and more than 16 streams. test-inkling2-hip-state-host, also part of test-inkling2-hip-host, runs it over a recording runtime: each stream's allocations at Mini's and tiny-inkling2-mini's shapes at 8K, 32K, 128K and 1M (25,087,464 B past the cache on Mini), the scratch, the site tables, the addSlots, reset and deinit counts, each refusal and its message, and cleanup after a failed allocation.
hip_snapshot.zig adapts loop.CacheLayout into kept_state.Visit slices and delegates kept-row counting and packed-order traversal to the shared kept_state.zig walk (the same walk CUDA's loop_engine.zig uses), then appends the slot's conv region. Model.save, restore and drop queue one device copy a piece on the stream, with CUDA's refusals by name (NotAtMark, StateOfAnotherModel, BadLoopSnapshot) and log lines. A snapshot is stored by position, so it restores into any slot whose context holds it. A save whose copy fails waits for the stream before it frees its buffer. Host tests: the walk's rings equal hip_attention.zig's, its bytes at Mini's and tiny-inkling2-mini's shapes, its pieces split at the ring wrap and tile the snapshot; save and restore issue exactly those copies; on host memory a restored slot equals a reference built from positions byte for byte, in place and at another capacity. inkling2-hip-state-test (built in test, run only on its own step) does the same on gfx1151 with tiny-inkling2-mini's and Mini's shapes: seeded slots saved, the snapshot compared with the walk's gather, the slot clobbered, restored and compared whole, and restored into a slot of another capacity.
ashhart
force-pushed
the
feat/hip-inkling2-state
branch
from
December 1, 2026 06:08
cb82cb7 to
fd1c780
Compare
Owner
|
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. |
AbrahamCete
added a commit
to AbrahamCete/TensorFold
that referenced
this pull request
Dec 1, 2026
…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.
This was referenced Dec 1, 2026
ashhart
pushed a commit
to AbrahamCete/TensorFold
that referenced
this pull request
Dec 1, 2026
…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.
ashhart
pushed a commit
that referenced
this pull request
Dec 1, 2026
…tract launchers Zig 0.17 requires each source file to belong to one module. After #5012, #4994, #5499 and #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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
TensorFold has Inkling 2 Mini's HIP text weights loader (#5031), serve-flag refusals (#5034), attention (#4633), loop kernels (#5012), and the shared
kept_state.zigwalk (#4724), but no per-stream state or prompt snapshot path on HIP. This adds HIP5b, the second slice of the HIP5 stack listed on #4274 (and Refs #4265). No forward pass, new kernels, or native registration yet.zig/src/families/inkling2/hip_engine.zigmirrors CUDA'sloop_engine.zigModelwithout the forward:loop.CacheLayout, four 32-byte rewind sites per visit (conv.hip/ops.cuRewindSitelayout), conv-state backup, 16-row window history, and the last prompt row's FP32 logits (no 32-byte per-stream sampling rule buffer on HIP).Model.init, withhip_attention.zigpartial slots and routed-expert activation/down rows.0or pasttext_config.model_max_length(Mini namesmax_position_embeddingsonly undermtp_config), and> 16streams.zig/src/families/inkling2/hip_snapshot.zigadaptsloop.CacheLayoutintokept_state.Visitslices and delegates kept-row byte counts and packed-order traversal directly to#4724's sharedkept_state.zigwalk (the same walk CUDA'sloop_engine.ziguses), followed by the slot's conv region.Model.save,restore, anddropqueue one device copy per piece on the HIP stream with CUDA's named refusals (NotAtMark,StateOfAnotherModel,BadLoopSnapshot) and error cleanup. Snapshots store positions, so they restore into any slot whose context holds them.zig/build/hip_contract.zigaddstest-inkling2-hip-state-host(also wired intotest-inkling2-hip-hostandtest),inkling2-hip-state-build, and the explicit GPU stepinkling2-hip-state-test.docs/design/inkling-2-mini.mddocuments the HIP stream state byte budgets,kept_state.zig-backed snapshot walk, context check, and test steps.Stack and scope
main25c3d447d. Commits:e11e08bb0feat(hip): Inkling 2 Mini's per-stream state on one HIP rankfca4a675dfeat(hip): Inkling 2 Mini's prompt snapshots on one HIP rank+1,346/-2in 6 files (572 lines implementation inhip_engine.zig+hip_snapshot.zig, 736 lines host + GPU tests inhip_engine_test.zig+hip_snapshot_test.zig, 24 lines build wiring, 16 lines design doc). Both commits form one cohesive state + snapshot work unit; rollback is cleanly bounded to these 6 files.Checks on this head
fca4a675d, onmain25c3d447d.python3 tools/zig/lean_check.py): 0 issues in all 6 touched files (88 pre-existing repo-wide across 9,180 files).zig fmt --check build.zig zigandgit diff --check origin/main..HEADclean.-Dhip=true):zig build -Dhip=true test-inkling2-hip-state-host: 21/21 passed (Mini andtiny-inkling2-minibyte budgets at 8K/32K/128K/1M, shared scratch, rewind site tables,addSlots/reset/deinit, every refusal, allocation-failure cleanup,kept_state.zigring wrap pieces, and host byte-for-byte restore in place and across capacities).zig build -Dhip=true test-inkling2-hip-host: 89/91 passed, 2 skipped (names_test.zigcheckpoint tests needing local env vars).zig build -Dhip=true test-inkling2-host: 69/74 passed, 5 skipped.zig build -Dhip=true test-inkling2-loop-hip-host: 33/33 passed.zig build -Dhip=true check-hip-kernel-contract-host: passed.gfx1151):zig build -Dhip=true -Dhip-arch=gfx1151 inkling2-hip-state-test: 5/5 passed (seeded Mini andtiny-inkling2-minislots saved, verified against host gather, clobbered, restored byte-for-byte in place and into another slot capacity).fca4a675d(previous headffef60aaepassed 5/5 checks).Receipt
n/a: no forward, server, or inference path reaches this state yet. The host recording tests (21/21) and
gfx1151device snapshot round-trip test (5/5) are the evidence.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (n/a: no forward/engine)--drafter, no slower than without it, greedy and sampled. (n/a: no forward/engine)