Repository navigation
cuda : fuse repeated residual MUL and ADD - #139
Draft
GenerelSchwerz wants to merge 13 commits into
Draft
GenerelSchwerz wants to merge 13 commits into
GenerelSchwerz wants to merge 13 commits into
Conversation
Carry the reviewed kernel sources from PR125, PR129 and PR132 as the matching control for the separate tensor-affine HC follow-up. Assisted-by: Codex
Preserve gate intermediates, original rounding and live HC outputs. Retain strict input alias checks and standard allocation dependencies. Assisted-by: Codex
Use the exact tested control sources from published PR130, PR129 and PR132. Assisted-by: Codex
Reuse the allocated affine match to find the planned HC_POST and retain prepared emission priority. Reject expanded normalization cuts whose terminal is not written by this kernel. Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explicit REPEAT -> MUL -> ADD currently launches REPEAT followed by the residual arithmetic kernel from PR138. This folds the three stages into one generic launch while still storing the repeated tensor, rounded product and final sum. Multiplication and addition remain separate round-to-nearest operations.
REPEAT accepts its existing advertised F32/F16 types. Either MUL operand can be repeated; arithmetic keeps the existing F32/F16/BF16 combinations. Dynamic four-axis repeats, source strides and either ADD order are handled without model names or fixed dimensions. Canonical prior-root VIEW/RESHAPE/PERMUTE/TRANSPOSE nodes may intervene. Strict physical checks include NONE inputs; allocation dependencies keep original inputs and intermediates alive through the final ADD. Longer HC/affine fusions keep priority. BF16 REPEAT, arbitrary intervening compute, unsupported layouts/types and concurrent paths keep their existing execution.
This is a 4-file leaf on PR138 commit
ce6ddc95589080cf0a0cf0c0fa42652fa962f940: 118 CUDA additions/8 deletions and 32 additions/5 deletions in the existing backend test. The reference-base diff includes prerequisite kernel-series work; review this leaf against that commit.Component evidence
Own-PR138 control versus candidate on RTX 5070 Ti (SM120a), driver 615.71.09. Six alternating pairs per timed case, 2,000 graph replays per arm. Inputs and every retained output are checked before/after timing. Shared build/GPU locks cover each whole suite; timing is serial and reviewer CPU work is stopped.
Validation and limits
These are isolated component results. Model C++ expressions do not prove graph adjacency: Qwen4exp's optional unfused post branch, Gemma3n and delta-net can have coefficient arithmetic between REPEAT and MUL. No default Flash Next, model-serving, MTP or universal speed claim. Full stream-reduction trees, concatenation and private dispatcher/allocation integration remain separate.
AI disclosure: Codex assisted with implementation, testing, review and this description under repository-owner authorization for this maintained fork. No upstream submission or merge.