Skip to content

Add a weight-stationary INT4 GEMM for small M#20154

Draft
digantdesai wants to merge 1 commit into
gh/digantdesai/58/headfrom
gh/digantdesai/59/head
Draft

Add a weight-stationary INT4 GEMM for small M#20154
digantdesai wants to merge 1 commit into
gh/digantdesai/58/headfrom
gh/digantdesai/59/head

Conversation

@digantdesai

Copy link
Copy Markdown
Contributor

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.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🔗 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 Failure

As of commit c7e303c with merge base dc55469 (image):

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant