Skip to content

[Kernel] Manual activation+quant fusion via QuantizedActivation - #46864

Closed
mgoin wants to merge 1 commit into
mainfrom
manual-act-quant-fusion-llama
Closed

mgoin wants to merge 1 commit into
mainfrom
manual-act-quant-fusion-llama

Conversation

@mgoin

@mgoin mgoin commented Jun 26, 2026

Copy link
Copy Markdown
Member

Starts the ActivationQuantFusionPass manual-fusion migration (RFC #43224, specific tracker #43501) on the producer side of the QuantizedActivation contract (#44260).

Adds maybe_fused_act_quant: given an activation and the linear it feeds, it emits a QuantizedActivation via the fused silu_and_mul_quant kernel when the linear advertises a consumable input_quant_key, and falls back to the plain activation otherwise. Llama's MLP forward calls it for down_proj — the model-code change is one line. When manual fusion fires the silu_and_mul pattern is already consumed, so the compiler ActivationQuantFusionPass finds nothing and the two never double-fuse. Only (SiluAndMul, kFp8StaticTensorSym) is registered for now; other schemes/activations are one table row each.

Not a duplicate: builds on the landed contract (#44260) and is the activation-quant counterpart to the AR+RMSNorm manual fusion in #45855; no open PR covers the producer side.

Test

Smoke tested on RedHatAI/Llama-3.2-1B-Instruct-FP8 (default compiled + CUDA-graph path): all 16 mlp.down_proj layers take the fused branch (input_quant_key == kFp8StaticTensorSym) and generations are coherent — the QuantizedActivation flows through the compiled down_proj.forward into apply_weights with no graph break. TP2 coherence and an A/B vs. the compiler pass are follow-ups.

AI assistance (Claude) was used; all changed lines are human-reviewed.

Start the ActivationQuantFusionPass manual-fusion migration (RFC #43224)
on the producer side of the QuantizedActivation contract (#44260). Adds
maybe_fused_act_quant: given an activation and the linear it feeds, it
emits a QuantizedActivation via the fused silu_and_mul_quant kernel when
the linear advertises a consumable input_quant_key, and falls back to the
plain activation otherwise. Llama's MLP forward calls it for down_proj;
the change to model code is one line.

When manual fusion fires the silu_and_mul pattern is already consumed, so
the compiler ActivationQuantFusionPass finds nothing and the two never
double-fuse. Only (SiluAndMul, kFp8StaticTensorSym) is registered for now.

Smoke tested on RedHatAI/Llama-3.2-1B-Instruct-FP8 (default compiled +
CUDA-graph path): all down_proj layers take the fused branch and
generations are coherent. AI assistance (Claude) was used; all changed
lines are human-reviewed.

Signed-off-by: mgoin <mgoin64@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@mergify mergify Bot added the llama Related to Llama models label Jun 26, 2026
@mgoin mgoin changed the title [Kernel] Manual activation+quant fusion via QuantizedActivation (Llama) [Kernel] Manual activation+quant fusion via QuantizedActivation Jun 26, 2026
@mergify mergify Bot added the quantization label Jul 23, 2026
@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @mgoin.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Sep 3, 2026
@mgoin mgoin closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant