Skip to content

Inkling-2-Mini: Add loop message and gate kernels - #4746

Open
ajensenwaud wants to merge 2 commits into
ashhart:mainfrom
ajensenwaud:ink-k-loop
Open

ajensenwaud wants to merge 2 commits into
ashhart:mainfrom
ajensenwaud:ink-k-loop

Conversation

@ajensenwaud

@ajensenwaud ajensenwaud commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Inkling 2 Mini runs layers 6 to 17 three times, and from the second pass on each of those layers mixes in a message
from the pass before. TensorFold has no CUDA kernels for that step with the fixed sum order a batch-invariant engine
needs. This PR adds them.

What this changes

Adds the loop step's kernels, their launcher and their contract registrations: the cross-pass message attention,
the four rank-64 message gates and their norms. A row gives the same bits in any window or prompt chunk. Nothing
serves them yet.

Checks on this head

  • Head de885595d; lean checker 165 on the base, 165 on this head, 0 new.
  • zig build over 19 host steps, Inkling 2's and test-cuda-host among them, -Dfixed-cpu: 547 of 547 steps, 9,413 of 9,451 tests, 38 skipped.
  • zig fmt --check build.zig zig, git diff --check, test-kernel-symbols-host, cuda_common_check.py and cuda_fragment_check.py: clean.

Receipt

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

Kernel contract
  • Registered: the eight kernels in loop.cu, each with a float64 reference written from transformers'
    Inkling2LoopMessageGate and Inkling2LoopMessageAttentionResidual, and a planted control after each group.
  • GB10 (sm_121), 25 November, on this head: kernel-contract inkling2 exl3 vit act gives SUMMARY 146 kernels: 144 pass gates 1-4, 2 fail, 0 known findings; 103 controls: 103 red as planted, 0 missed; 27 limit problems. Main under the same words gives the same two failures, both in GLM's wide-expert tests, and the same 27 limit problems.
  • Gate 5: records for nvcc 13.0 and 13.3 on sm_80, 86, 89, 120 and 121; 13.2 stays pending.
  • They compile to the same SASS as in the InkSpark-Mini recipe's build (https://github.com/ajensenwaud/inkspark-mini-2dgx).

@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud for the loop kernels and the thorough contract coverage. One small cleanup: the loop kernel set's init marks its module loaded and then appends registrations without a cleanup on error, and the caller does not clean up the loop set either, so an allocation failure leaves the module loaded. Please add the matching cleanup, as the attention set does.

  • Synthena

@ajensenwaud

Copy link
Copy Markdown
Contributor Author

OK, will do. Thanks, @ashhart.

@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Done in 8b460625a. The loop set now marks itself loaded only after its registrations are set, and cleans up on a failed append, as the attention set does; the family set cleans it up too. The ops set had the same gap, so it gets the same fix.

@AIFlowML

Copy link
Copy Markdown
Contributor

I tested de885595d4 on d1ff890729. There are three merge conflicts. The scratch resolution kept both third-party notices, added the loop image to current main's CUDA limits table, and refreshed the gradient-serving pin for the combined cuda/kernels.zig.

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

On M5 Max, 90 host tests passed with four skips. The native adapter and full CUDA contract runner both cross-compiled for ARM64 Linux. I also confirmed the loop set and its caller retain the requested cleanup after the rebase. The current-tree GPU rerun remains open, including the same-filter main comparison for the reported GLM and launch-limit findings.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud. The loop set now cleans up if registration fails, its parent owns the cleanup, and the analogous ops fix is present. That closes the requested ownership issue.

This looks ready to land after our metadata and limit-table integration. The earlier contract failures remain recorded with their baseline scope; this cleanup does not need another unchanged arithmetic run.

  • Synthena

The cross-pass message attention, the four rank-64 message gates and
their norms, each with a float64 reference and a planted control. Their
nvcc 13.0 records keep 13.2 pending, with the 13.3 receipt beside them.
Both sets marked themselves loaded before their registrations were set
and appended without an errdefer, so a failed append left the module
loaded. They now follow the attention set, and the family set cleans
up the loop set as it does the others.
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

@ajensenwaud, a correction to our note above: provenance also has to be settled before this can land, and we should have said so.

This PR's notice says loop.cu and loop_ops.zig compute the loop layers of Transformers' modeling_inkling2_loop.py. For Inkling 2 Mini, the plan on #4274 builds from the published config, tensor headers and model card. The reference implementation's code is a fidelity comparison point, not a source.

Could you say how these kernels were written:

  • from the model's published math, with Transformers used only to compare outputs; or
  • by following its code?

We've rebased the branch onto today's main either way, so nothing is lost while this is sorted out.

  • Synthena

@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Thanks, Ash. The answer is closer to the second.

  • Source. The loop's maths was read from Transformers' modeling_inkling2_loop.py at 046bdb8cc2ce. That covers the message attention, the rank-64 gates, their norms and the two points where the reference rounds to bf16.
  • Code. No code was copied. The CUDA kernels were written for TensorFold, and their tiling and fixed sum order are our own.
  • Check. The kernels were checked against a float64 transcription of those modules on the real weights, with planted controls.

The notice already names the file and its Apache-2.0 licence. If the Mini plan needs these kernels written from the published maths alone, I can do that rewrite. Alternatively, #5059 can move onto main's loop kernels and this PR can close.

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.

3 participants