Skip to content

train 1125111745: #4529 #4699 #4919 (CI only) - #5035

Closed
ashhart wants to merge 26 commits into
mainfrom
lead/train-1125111745
Closed

ashhart wants to merge 26 commits into
mainfrom
lead/train-1125111745

Conversation

@ashhart

@ashhart ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #4529 #4699 #4919 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.

ashhart and others added 26 commits November 25, 2026 11:17
Main's zig/src/families/flashnext/cuda_batch.zig was 599 lines and #4529 adds six. Its scratch-size
test moves unchanged into cuda_paging_batch_test.zig, which it already imported; the private unused
ple import and the unreferenced proj_row constant (cuda_batch_state.zig keeps its own) go. No code
that runs changes; the gradient-serving pin is re-hashed.
…s; contract pins for the base and attention kernels
…s streams, and one in all when they are greedy
…window costs and a hold timed at load, up to the whole block
…e step against the recurrent kernel and the pick against a scan
Integrate PR #4699's DSpark kernel, weight-packing, online-softmax multi-stream
attention, batched GPU chain sampling, host SIMD draw, and shared depth pricing
optimizations cleanly onto #4465 (03bb79e):
- Transpose folded phi ([256, 201024]) and load-time split/transposed RNN
  weights (rnn_kappa, rnn_rec) for coalesced GPU loads.
- Replace score-buffer DSpark attention with zero-scratch 768-thread online
  softmax with M5 tensor-unit and TF_SIMD_FRAGS=1 pre-M5 paths, plus tiled
  base and two-stage group softmax/argmax logits.
- Wire batched multi-stream absorb/hold, chances with softmax reach, two-pass
  GPU top-k sampling, host SIMD top-k/greedy draws, and shared-batch target
  pricing while preserving #4465 invariants (DSP_SCALE, FP32 kappa,
  plain_guard = false, dspark.warm/measure, and firstLogprobRow).

Refs #4652
…he DSpark block)

#4699's rebase commit adds the "metal inkling2 dspark " block to resolve() followed by an extra `}`,
which closes the function early, so the file fails zig ast-check and the Metal contract limits
cannot build. The extra brace goes; the block and the rest of resolve() are unchanged.
…ark.zig under 600 lines

With #4699's overhaul and main's DSpark lane snapshots (#4542) both in it, dspark.zig came to 639
lines. Main's resolveTailTap, its test and the tap-row size check move unchanged to dspark_snap.zig,
which dspark.zig imports and whose test it references. A failed tail restore and resetLane share one
clearLane there, which also clears the overhaul's sampled flag. No launch or bit changes.
…anks routes once

- The four expert dot kernels run one lane to one output weight row: a simdgroup covers 32 consecutive rows, a threadgroup eight simdgroups, and the activation row is read in uniform 16-byte loads. The NVFP4 and MXFP8 weights are decoded from 16-byte words, two elements at a time, through FP16 bit patterns that equal the reference's E2M1 and E4M3 values and scale exactly; the MXFP8 path falls back to the reference decode for scales outside the exact range and for NaN codes.
- Sum order preserved: each output is still one serial chain over its row's columns in index order, starting at zero, adding the BF16 weight times the BF16 activation product one term at a time with the same rounding points and no fused multiply-add, so every output bit equals the previous kernel's.
- tf_ink2_combine launches 256 outputs a threadgroup. A threadgroup ranks the token's routes by (expert, route slot) once, drops experts outside the layer, and every output adds weight times down in that order from zero, which is the ascending-expert, ascending-slot order the old per-output scan visited. Same chain, same rounding.
- Contract: dot kernels and combine at 256 threads; the combine control now plants route-slot order; the gate/up control plants a dropped pair swap.
…byte loads; router picks in parallel

- tf_inkling2_router, tf_inkling2_conv_dynamic and tf_inkling2_logits keep one thread to one dot product but load eight BF16 columns of both rows at a time, four loads ahead of each step.
- Sum order preserved: each dot is the same serial chain over columns 0..2303, product then add, with the rounding to BF16 or softcap after it as before.
- The router ranks its 128 keys (score plus bias) in parallel: rank 0 to 7 by key descending, then expert index ascending, is exactly the set the serial first-greatest scan picks, and the ascending-expert normalization sum is unchanged. A NaN key makes the scan order dependent, so any NaN key runs the original serial scan. The control now plants the dropped bias.
- The zeta chain (64 ranks, 4,608 columns) and the forget and gain chains (64 ranks a channel) load eight BF16 weights at a time and batch the loads ahead of each step.
- Sum order preserved: each zeta, forget and gain value is the same serial chain over its columns in index order, product then add, zeta rounded to BF16 as before, no fused multiply-add.
Every thread scans all 128 keys, so thread 0 alone stores any_nan before the barrier; the serial fallback is unchanged. The contract's router check adds six rows with NaN keys at varied experts, fifty launches each equal to the serial scan and to the first launch's bytes, with two planted controls: no fallback, and a flag from expert 0's key only.
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Landed: #4529 #4699 #4919 as main 128d968. This PR only carried their CI.

@ashhart ashhart closed this Nov 25, 2026
@ashhart
ashhart deleted the lead/train-1125111745 branch November 25, 2026 12:22
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.

4 participants