Repository navigation
Inkling-2: Add DSpark kernels that draft all streams in one pass - #4858
ajensenwaud wants to merge 32 commits into
Conversation
The family's attention was a copy of prefill_attention.cu's vision_kernel, so the tower now calls vit.Attention.full at head dim 64, the instance and record Qwen3-ASR already brought to main.
grouped_body takes the member tiles a program as a template parameter. tf_exl3_grouped_wide_2 runs 32 members by 64 columns for prompt chunks; the existing instantiations compile to the same SASS on every SM.
nvcc 13.3 changed tf_exl3_grouped_2's sm_120 and sm_121 SASS when the wide instance followed it; defined first, every existing kernel compiles as before under 13.0 and 13.3.
The item plan was limited to mcg and slot rows written to ey. It now takes every codebook, writes scratch y when ey is 0, picks the wide kernel for 32-member items and the capped epilogue for act_mode 3.
The family's grouper and grouped projections were copies of core's. Inkling now runs exl3_experts.runWith on grouped.Router's item plan, 16-member items below 512 rows and the wide kernel from there; outputs are bit-equal to the kernels this replaces. Expert widths up to 8 bits are admitted, as core decodes them.
tf_ink2_gateup duplicated core's gate/up epilogue apart from the softcaps, which core now runs as act_mode 3. Its registration moves to tf_exl3_gateup_capped, with the swapped-caps control kept.
RADIO, MiniMax M3, Qwen 27 and Inkling 2 each kept their own copy of the placeholder span and the cut that maps a prompt pass onto it. They now share core.image_rows, started from RADIO's copy, and each family keeps only its own splice. The cut now works in usize and takes the offset before adding the buffer row, as RADIO's did. MiniMax M3 and Inkling 2 already cut in usize, so their results are unchanged. RADIO and Qwen 27 no longer overflow u32 on a span that ends past 2^32; nothing else changes.
Inkling 2's tf_ink2v_scale_add was a layer-scaled residual add, which is tf_vit_pointwise with a per-column scale between the activation and the add. vit.cu now has tf_vit_pointwise_gamma for that, and the tower calls it through vit.Kernels.pointwiseGamma. Its fp32 multiply, bf16 rounding and add are the same round-to-nearest steps the family kernel took, so the tower's results are unchanged. Every existing function in vit.cu and inkling2/vision.cu compiles to the same SASS on sm_80, 86, 89, 120 and 121 under nvcc 13.0 and 13.3. The contract now registers the core kernel, with the late-gamma control retargeted to it; its records come from cuobjdump -res-usage, and 13.2 stays pending.
The Metal and residency builds give qwen27 its own core roots, which lacked image_rows after the shared module moved into core.
Core builds exl3_experts.cu with contraction on, so the soft-capped SwiGLU's products and sum fused into FMAs, and Inkling 2 Small's tokens no longer matched the build it was validated on. Explicitly rounded operations give the SASS the old text has at the glue kernels' flags.
Inkling 2's DSpark SiLU was its own kernel for torch's g / (1 + expf(-g)). tf_swiglu_rows now takes that form as a template mode, exported as tf_swiglu_rows_expf, and the drafter calls it. Each element runs the same instructions as the family kernel did, and tf_swiglu_rows' SASS is unchanged.
The common-helper check matched only warp_sum and block_sum*, so local warpSum and blockSum copies passed unseen. It now matches either spelling. The four Inkling 2 copies it finds are listed with their reasons.
Inkling's pick was MiniMax's merge with a different fallback id, so both now instantiate one body in common/dspark_pick.cuh. MiniMax's tf_mm3_pick_merge compiles to the same SASS on every SM under nvcc 13.0 and 13.3. Inkling keeps 0x7fffffff when no value beats -Inf, and its compare and select chain is unchanged.
Without later_pending a 13.2 build read the DSpark launches against 13.0's numbers. The 13.3 receipts move to pending_133.zig, as the expert and vision records already do.
Each kernel of a draft pass gains a form that walks several streams in one launch: q/k prep, block attention and merge, the Markov head's context and recurrence, the per-stream pick and the step's vocabulary and rank merge. A stream's bits equal the one-stream kernels'.
d640ce5 to
e860edd
Compare
|
5060 Ti (sm_120) kernel-contract Clean pass: 62/62 kernels pass gates 1–4, 40/40 planted controls red, 0 missed, 0 limit problems. All of this PR's new all-stream draft kernels launch within driver limits and match their sm_120 records exactly: First sm_120 contract row I've run with zero limit problems — the records were measured for sm_120, not just GB10. |
|
Thanks @ajensenwaud. This is the batching layer over #4128, alongside #4127's shared experts; it does not enable Mini serving yet. We can take the narrow final slice onto the integrated work. Two fixes remain. The new Q/K, attention, context and recurrence cases also use only one stream. Please add distinct multi-stream tables and nonzero strides, comparing each stream's exact bytes/state with its own one-stream launch, with a planted table/stride fault. The posted totals and resource records are useful, but do not cover those cases yet.
|
qkMany now refuses what the one-stream launcher refuses, and both batched launchers read the host copy of the stream table so a row past the table, a layer without caches, a window longer than the ring or partials too small for the chunks are refused before a launch.
Q/K, attention, context and recurrence each run 3 to 6 streams with their own tables and padded strides, and every stream's bytes must equal its one-stream launch. Each has a control that feeds the batched launch a wrong table entry or stride.
|
On zig build test-inkling2-host test-inkling2-cuda-host test-gradient-serving test-kernel-symbols-host -Dfixed-cpu -j2 --summary all
zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary allThe host run passed 61 tests with four skips, and the aarch64 Linux CUDA contract runner compiled. The new fixtures compare Q/K, attention, context and recurrence bytes per stream against their respective one-stream launches and register separate table/stride controls. The earlier SM120 result covers the earlier head. For the new head, could the next device receipt include those four comparison cases and their four planted controls? The whole branch has 19 merge conflicts against Igor Lessio - AIFLOW LABS |
|
Thanks, Ash, and thanks @AIFlowML. Both asks are fixed in
No kernel changed, so the existing records stand. |
With several streams, Inkling 2's DSpark drafter runs its draft pass once per stream, because #4128's kernels take
one stream a launch. At eight streams that is about 250 launches a pass. This PR adds kernels that take every stream
in one launch.
What this changes
Each kernel of a draft pass gains a form that walks several streams, and a stream's bits equal those of the
one-stream kernel. The rank merge runs on the shared
dspark_picktemplate. Nothing serves them yet.Checks on this head
e860eddc1on mainea37382cb; lean checker 165 on the base, 165 on this head, 0 new.zig build test-inkling2-host test-inkling2-cuda-host test-gradient-serving test-kernel-symbols-host compile-cuda-tests -Dfixed-cpu: 24 of 24 steps, 59 of 63 tests, 4 skipped.zig fmt --check build.zig zig,git diff --check,cuda_common_check.pyandcuda_fragment_check.py: clean.Receipt
n/a: no served path reaches these kernels yet.
Kernel contract
8052cef29, which has the same DSpark kernel and contract files as this head:kernel-contract inkling2givesSUMMARY 62 kernels: 62 pass gates 1-4, 0 fail, 0 known findings; 40 controls: 40 red as planted, 0 missed; 0 limit problems.drafter weights), the batched pass cut an eight-stream draft pass from 34.4 to 12.6 ms, with identical drafts.