Repository navigation
Inkling 2 Mini on Metal: the forward on a concurrent encoder (bit-identical; plain decode +21%, 4 drafted streams +47%) - #5435
Conversation
07d7021 to
08b5511
Compare
08b5511 to
cbcec98
Compare
|
@sethforprivacy, the rebase onto
Next we review this head and run it on an M5 against
|
|
Thanks @sethforprivacy. #5435 is It doesn't merge onto today's main. The conflicts are in Exactness
Repo checks we ran on this branch:
The M5 check we'd like to see, main against this branch at default settings:
|
|
Thanks, @ashhart, and for catching the TFQ5/TFQ3 barrier. Agreed: this PR carries the encoder. #4523 is closed, and I don't plan to bring its five-command-buffer split back unless the M5 numbers show it's worth a PR of its own. I'll add the hazard test in the shape of #5674's: it records the forward's launches and fails when a launch in a concurrent span reads a buffer written earlier in that span, with a planted control that drops one barrier. It will cover a decode round, a verify window, a prompt chunk and each expert format. When you rebase onto TF_EXPLAIN, I'll write it against that head. After that come the M5 checks you listed: a 2K prompt plus 128 steps equal to the bit, with drafts on and off, including a TFQ3 or TFQ5 checkpoint; 20 identical runs of one long prompt; and decode and prompt rates at 1K and 8K. |
|
Thanks for agreeing to carry the encoder, and for catching the TFQ5/TFQ3 barrier before the hazard test existed. That catch is the argument for the test. One thing is yours: the hazard test itself, since it follows your design. The device cells are ours, on our M5 Ultra: a 2K prompt plus 128 decode steps bit for bit with drafts on and off (including a TFQ3 or TFQ5 checkpoint), 20 identical runs of one long prompt, and prompt and decode rates at 1K and 8K. The 24-prompt token set and the 4-chat hash cross-check are ours too. #4523 stays closed unless the numbers justify its command-buffer split.
|
…it for the concurrent encoder ashhart#5435 runs the forward on a concurrent encoder with a barrier between dependent launches; merged with main, the tree attention splits into prefix and partials calls, and a visit's segments go through forward_attention's attendEach, which keeps main's depth dispatch. attention.zig, forward.zig and forward_visit.zig keep main's notes with ashhart#5435's added, and each pin is the file's hash as it ends up.
cbcec98 to
74bc069
Compare
Synthena Initial Review — Performance receipt required (
|
…ches side by side The forward ran every launch in one serial encoder, so each waited for the one before it, though many read only what an earlier step wrote. It now runs on a concurrent encoder with a barrier after every step a later launch reads. Launches between two barriers run side by side: a visit's six input projections, its three norms, the three roles' gates and depth-mix reads, the K and V convolutions, and the K and V staging copies. Three helpers issued dependent launches back to back and relied on the serial encoder's order; they now put a barrier between them: the router's scores and selection (routerSplit), the split gates' norm, down and apply (gatesSplit), and the convolution staging before the dynamic convolutions (fusedAttention). On a serial encoder these barriers change nothing. The routed experts move to forward_experts.zig, so forward.zig stays within the 600-line rule. No kernel and no arithmetic changes: every reply is main's, bit for bit.
…it for the concurrent encoder ashhart#5435 runs the forward on a concurrent encoder with a barrier between dependent launches; merged with main, the tree attention splits into prefix and partials calls, and a visit's segments go through forward_attention's attendEach, which keeps main's depth dispatch. attention.zig, forward.zig and forward_visit.zig keep main's notes with ashhart#5435's added, and each pin is the file's hash as it ends up.
74bc069 to
f0af440
Compare
Synthena Initial Review — Needs maintainer review (
|
|
READY to land on this head. Device A/B on an M5 Ultra with this rebased head against its base on Inkling 2 Mini: tokens equal in every cell; decode +16.3% at 1 stream, +5.1% at 4 and +22.7% at 8 (37.1 to 43.2 and 105.8 to 129.9 tok/s), prompt +7% from 2,048 tokens, repetitions agreeing.
|
The part of #4448 that main has not taken yet, cut fresh from main: the Mini forward on a concurrent encoder. No kernel and no arithmetic change; every reply is main's, bit for bit.
What changes
The forward encoded every launch into one serial encoder, so each waited for the one before it, though many read only what an earlier step wrote. It now runs on a concurrent encoder with a barrier after every step a later launch reads. Launches between two barriers run side by side:
wq,wk,wv,wr,sink,gate),Everything else stays a chain, with a barrier after each step.
Three helpers issued dependent launches back to back and relied on the serial encoder's order; they now put a barrier between them:
glue.routerSplit: the scores, then the selection,loop.gatesSplit: the norm, the down projection, then the apply,forward_conv.fusedAttention: the staging, then the dynamic convolutions.On a serial encoder these barriers change nothing, so the other callers are unaffected.
routedExpertsmoves toforward_experts.zigunchanged apart from its barriers, soforward.zigstays within the 600-line rule (590 lines).#4448's other proposals stay out: the five command buffers (the forward now hands its last buffer to the sampler and backs up the convolution state in a blit first, and the encoder alone is the measured part), and the 32-key/adaptive attention chunks, which would change the order of the merges.
Bits
All on a Mac Studio M5 Ultra with 256 GB and the released checkpoint, served by
tensorfold-nativeon this branch against main at the same commit (6345c5bb8),--parallel 4 --context 16384 --prompt-cache-gib 0, greedy:--drafterdraft: falsebench_concurrent.py --levels 4 --alone --serialA missing barrier would show as a reply that changes between runs or under load; none did.
Speed
Same machine, same settings, the builds alternated:
bench_openai.py(fibonacci-raw / gpu-chat-no-think)--drafter, one stream--drafter, 4 chat prompts at onceWith the drafter at
--parallel 8 --max-tokens 32768 --prompt-cache-gib 16 --decode-share 0.5, 800 tokens each:The gain is largest where a step is one row's small launches (plain decode, several streams); a drafted round already has several rows a launch.
Checks on this head
zig build native -Dcpu=apple_m1compiles.tf-kernel-contract --only inkling2:127 kernels: 126 pass gates 1-4, 1 fail; 152 controls: 152 red as planted, 0 missed. The one failure,tf_inkling2_conv_dynamic_segs("a run changed its inputs"), fails the same way on main at6345c5bb8; no kernel is changed here.Mini Metal opt-in DSpark drafting preserves target tokens and rolls back exactlyatdrafted.drafted > 0, which fails the same way on main at6345c5bb8.zig fmt --check,git diff --checkclean; lean 93 on the base and 93 here, 0 new.Main has moved on by nine commits since
6345c5bb8; none toucheszig/src/families/inkling2/, and this branch merges onto current main cleanly.