Add a weight-stationary INT4 GEMM for small M#20154
Draft
digantdesai wants to merge 1 commit into
Draft
Conversation
Contributor
Author
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20154
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 4 Pending, 1 Unrelated Failure, 1 Unclassified FailureAs of commit c7e303c with merge base dc55469 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Jun 9, 2026
This was referenced Jun 9, 2026
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.
The INT4 dp4a kernel launched one block-row per activation row (grid.y = M) and
re-read the packed weights for every row, so weight traffic scaled with M. That
is fine for M=1 decode but makes a small-M forward (EAGLE speculative
verification over chain_len+1 tokens) cost ~M decodes.
Add an int4_w4a8_gemm_kernel that loads each weight chunk once and accumulates it
into all M output rows (grid.y = 1), so weight traffic is 1x regardless of M;
int4_plain_mm uses it for 2 <= M <= GEMM_MAX_M (8) and keeps the matvec for M=1.
MATVEC_MAX_M (the Python dispatch threshold) stays 4 by default so other models'
dynamic-prefill exports are unaffected; an export raises it locally. The
dispatch asserts MATVEC_MAX_M <= SHIM_GEMM_MAX_M so the Python and C++ limits
cannot silently diverge.
Authored with assistance from Claude Code.