Skip to content

[Fusion] Manual ActivationQuantFusionPass initial application - #51415

Merged
mgoin merged 10 commits into
vllm-project:mainfrom
neuralmagic:manual-act-quant-fusion-llama
Sep 3, 2026
Merged

mgoin merged 10 commits into
vllm-project:mainfrom
neuralmagic:manual-act-quant-fusion-llama

Conversation

@mgoin

@mgoin mgoin commented Aug 7, 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.

mgoin and others added 2 commits June 26, 2026 19:15
Start the ActivationQuantFusionPass manual-fusion migration (RFC vllm-project#43224)
on the producer side of the QuantizedActivation contract (vllm-project#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>
@mgoin
mgoin requested review from noooop and russellb as code owners August 7, 2026 15:44

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

)


# (activation module type, consumer input_quant_key) -> fused producer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do you think we should build in some oracle for this selection up front where the actual implementation of the quantized activation function can be swapped?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah it is reasonable to suspect for future optimizations

def forward(self, x):
x, _ = self.gate_up_proj(x)
x = self.act_fn(x)
x = maybe_fused_act_quant(self.act_fn, x, self.down_proj)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that instead of passing self.down_proj: LinearBase, it might make more sense to expose a method from LinearBase that can be called here to extract what is needed

I think that will help make the interface clearer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Depending on the quantization used, we need to extract different things from the Linear layer. IMO it is more clear to my eye that this function might have an affect on self.down_proj within the context of the forward function, so I prefer just passing it in

@whkuo269

whkuo269 commented Aug 10, 2026

Copy link
Copy Markdown

Hi @mgoin, I’d like to help validate this manual activation+quant fusion work.

I’m planning to run TP=1/TP=2 correctness checks and A/B tests comparing the base commit and this PR with compiler activation-quant fusion enabled and disabled.

Please let me know if there’s a preferred test setup or specific coverage you’d find most useful.

Signed-off-by: ElizaWszola <ewszola@redhat.com>
Signed-off-by: ElizaWszola <ewszola@redhat.com>
Signed-off-by: ElizaWszola <ewszola@redhat.com>
Signed-off-by: ElizaWszola <ewszola@redhat.com>
Signed-off-by: ElizaWszola <ewszola@redhat.com>
@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #50876. Mergify cannot evaluate rules on this PR. Once #50876 is merged or closed, Mergify will resume processing this PR. ⚠️

@mgoin

mgoin commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #83767 for commit c7fc61612e3f.

Signed-off-by: ElizaWszola <ewszola@redhat.com>
@mgoin

mgoin commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

/ci run

1 similar comment
@mgoin

mgoin commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #84616 for commit cd7f019c21bf.

Signed-off-by: ElizaWszola <ewszola@redhat.com>
@mgoin

mgoin commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #86403 for commit 3b0c4ee7e60f.

@njhill

njhill commented Sep 4, 2026

Copy link
Copy Markdown
Member

@mgoin I bisected a CI IMA to this change: https://buildkite.com/vllm/ci/builds/87269/list?jid=01a06dce-0d6b-4b62-8db0-9853df2b22d9&tab=output

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

Labels

llama Related to Llama models quantization ready ONLY add when PR is ready to merge/full CI is needed torch.compile

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants