Skip to content

Inkling-2: Add fused EXL3 projections for a layer's inputs - #4874

Open
ajensenwaud wants to merge 4 commits into
ashhart:mainfrom
ajensenwaud:ink-k-proj
Open

ajensenwaud wants to merge 4 commits into
ashhart:mainfrom
ajensenwaud:ink-k-proj

Conversation

@ajensenwaud

@ajensenwaud ajensenwaud commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Before attention, every Inkling 2 layer projects its normed input five ways: q, gate, r, k and v. Main's EXL3 group launch takes at most three layers that read the same input rows, so these five projections need several launches. This PR adds a group launch that takes all five.

What this changes

Adds tf_exl3_rot_group5 and six tf_exl3_group5_* kernels to exl3_linear.cu, the family launcher proj_group.zig, and their contract registrations. Each member keeps its own input rows and runs main's linear_body on its own blocks, so its output has the bits of its own launch. Nothing serves them yet.

Checks on this head

  • Head a9889b94d on main 68ff0ad8e; lean checker 165 on the base, 165 on this head, 0 new. tools/pr_check.py: 0 errors.
  • zig build test-cuda-host test-inkling2-cuda-host test-inkling2-host test-gradient-serving test-kernel-symbols-host test-exl3-cuda-host -Dfixed-cpu: 500 of 500 steps, 9,090 of 9,138 tests, 48 skipped, from a fresh cache, on e77a9ad57.
  • zig fmt --check build.zig zig, git diff --check, cuda_common_check.py and cuda_fragment_check.py: clean.

Receipt

n/a: no served path reaches these kernels yet.

Kernel contract
  • Registered: the seven new kernels as replacements of each member's rot_in and linear_body, through an extension hook on contract_exl3.Case. Each form has a planted control.
  • GB10 (sm_121), 24 November, on e77a9ad57, which has this head's patch on main 9fa8863bc: kernel-contract inkling2 exl3 gives SUMMARY 80 kernels: 80 pass gates 1-4, 0 fail, 0 known findings; 49 controls: 49 red as planted, 0 missed; 18 limit problems.
  • The 18 limit problems are main's own: main shows the same 18 under the same filter.
  • SASS: the 134 existing functions of the exl3_linear image compile to identical SASS on nvcc 13.0 and 13.3 for sm_80, 86, 89, 120 and 121.
  • Gate 5: records for nvcc 13.0 and 13.3 on the same five SMs; 13.2 stays pending.

Adds tf_exl3_rot_group5 and tf_exl3_group5_* to exl3_linear.cu: up to
five layers of one K, each with its own input rows, as one rotation
launch and one linear launch. The family's launcher is proj_group.zig.
The kernels are registered with the contract through contract_exl3's
Case as replacements of each member's rot_in and linear_body.
@joshuaswarren

Copy link
Copy Markdown
Contributor

5060 Ti (sm_120) kernel-contract exl3 on head a9889b9 — built off-card on aarch64 Spark (nvcc 13.0, zig baseline aarch64).

  • 28/28 kernels pass gates 1–4 (repeat/shapes/sums/nonfinite all green)
  • 13/13 planted controls red, 0 missed
  • All seven new kernels pass gate 5 with real records: tf_exl3_rot_group5 (22 regs) and the six tf_exl3_group5_* family members (128–181 regs, 16–32 KB shared) match their sm_120 records exactly
  • 7 limit problems, none in the new code: the pre-existing tf_exl3_prompt_{gu,down,_k6} records still read 0,0 on sm_120 (they were never measured there — same finding as on GLM CUDA: pipeline four-bit EXL3 prompt expert tiles on SM121 #4701), and tf_ctl_exl3_grouped_old_{0,1,2} show +64 B shared vs record (nvcc 13.0 vs recorded toolchain drift)

rc=1 is the limit-problem exit; the new group launch is clean on sm_120.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud. The five-way group reuses the existing rotation and linear bodies without changing their arithmetic, and no serving path calls it yet. It complements #4127's shared experts; it does not replace Mini's mixed-format projections. We'll apply this narrow addition on top of the integrated #4127 on our side, rather than stacking the old #4127 branch again.

This is ready for the final kernel comparison. The posted results support the new forms, with existing limit failures and the pending compiler records kept separate. Before landing, retain the final shared-image identity and exact member-by-member results, including distinct member inputs and FP32 outputs, which the current cases do not cover. The changelog overlap is mechanical and can be handled during integration.

  • Synthena

With an Ext, each member now reads its own input rows, and a case can ask for fp32 outputs. Main's own group cases keep one shared input and bf16, so their inputs are unchanged.
Adds fp32-output cases for the six group5 kernels and three controls that swap two members' inputs or outputs. The cases' host tests now run in test-inkling2-cuda-host.
@AIFlowML

Copy link
Copy Markdown
Contributor

I tested a9889b94da on d1ff890729, keeping main's changelog in scratch at the only conflict. On M5 Max, the focused Inkling, EXL3, kernel-symbol and gradient checks passed 1,283 tests with 19 skips. The native adapter and the CUDA runner cross-compiled for ARM64 Linux.

zig build test-inkling2-cuda-host test-inkling2-host test-gradient-serving test-kernel-symbols-host test-exl3-cuda-host check-native-cuda-host -Dfixed-cpu -j2 --summary all
zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary all

One test-runner cleanup gap remains in contract_inkling2_group5.zig. Set.add loads self.lin before the fallible group initialization and list appends. Its caller unwinds the earlier sets on failure but does not call group5.deinit on that error path. Give add an error cleanup for the linear module and any initialized group/cases, and restore the list to its entry length if an append fails. This is a source finding. CUDA validation after #4127 integration, including distinct member inputs and FP32 outputs, remains open.

Igor Lessio - AIFLOW LABS

Set.add left the linear module loaded, the group and its cases made, and
its list entries in place when a later step failed. It now frees them
and restores the list to its entry length.
@AIFlowML

Copy link
Copy Markdown
Contributor

Follow-up on 227b00d27. The cleanup I flagged is now in place. On failed group initialization or append, Set.add releases the objects it acquired and restores the entry count. I verified those error paths in source.

I trial-merged the revised head into d1ff890729 in scratch, keeping main's changelog at the only conflict. The command below passed 99 tests with four skips, including the three new group5 registration tests. The separate EXL3 target passed 1,187 with 15 skips, and the aarch64 Linux CUDA contract runner compiled successfully.

zig build test-inkling2-cuda-host test-inkling2-host test-gradient-serving test-kernel-symbols-host check-native-cuda-host -Dfixed-cpu -j2 --summary all
zig build test-exl3-cuda-host -Dfixed-cpu -j2 --summary all
zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary all

I did not inject a GPU setup failure or rerun the device gates. The published GB10 measurement remains the device evidence.

Igor Lessio - AIFLOW LABS

@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Thanks, Ash, and thanks @AIFlowML. These are in 227b00d27.

  • Member results. Each of the five members now reads its own input rows and weights. Gate 3 compares every member's bytes with that member launched alone through main's rot_in and linear_body. Six new cases run the group kernels with fp32 outputs. On a GB10, all 13 group cases pass gates 1-4 bit-equal.
  • Controls. Three new planted faults swap two members' inputs, in the linear launch and in the rotation, or swap two members' fp32 outputs. All five group controls go red.
  • Shared image. exl3_linear is the only image this PR touches. On nvcc 13.0 and 13.3, all 134 of main's functions keep byte-identical SASS on sm_80, 86, 89, 120 and 121. The seven added functions match their records.
  • Cleanup. Set.add now frees the linear module, the group and any cases it made when a later step fails, and restores the list to its entry length.

Under the inkling2 exl3 vit act minimax filter, the head adds no failure that your #4127 head does not already show. No kernel changed, so the earlier records stand. The GB10 run was on 23ad96cd8, and the cleanup commit after it touches only the error path.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks, @ajensenwaud. The distinct member inputs, FP32 comparisons and swap controls close the earlier coverage asks. Set.add now also releases its acquisitions and restores the list on error. The measured kernel code is unchanged by that cleanup. This is ready for the bounded kernel comparison; please retain the final shared-image identity, old-function comparison and per-member results before landing, with pending compiler records kept separate. Changelog integration stays with us.

  • Synthena

This branch has not been deployed

No deployments
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