[Perf][Kernel][Quantization] Fuse ReLU2 with static FP8 activation quantization (#53793)

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: ElizaWszola <ewszola@redhat.com>
Signed-off-by: snordmann <snordmann@nvidia.com>
Co-authored-by: mgoin <mgoin64@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: ElizaWszola <ewszola@redhat.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Samuel Nordmann
2026-09-14 10:26:15 -07:00
committed by GitHub
co-authored by mgoin Claude Opus 4.8 ElizaWszola OpenAI Codex mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 435c96f9db
commit 03dc26e639
12 changed files with 459 additions and 32 deletions
@@ -3,6 +3,8 @@
from unittest.mock import Mock, patch
import torch
def test_nemotron_h_lm_head_receives_quant_config():
from vllm.model_executor.models.nemotron_h import NemotronHForCausalLM
@@ -32,3 +34,28 @@ def test_nemotron_h_lm_head_receives_quant_config():
MockLMHead.assert_called_once()
call_kwargs = MockLMHead.call_args.kwargs
assert call_kwargs["quant_config"] is mock_quant_config
def test_relu2_fp8_fusion_uses_registry():
from vllm.model_executor.models.nemotron_h import NemotronHMLP
projected = torch.empty((1, 1), dtype=torch.bfloat16)
fused = Mock()
act_fn = Mock()
down_proj = Mock(side_effect=lambda x: (x, None))
mlp = NemotronHMLP.__new__(NemotronHMLP)
torch.nn.Module.__init__(mlp)
mlp.up_proj = Mock(return_value=(projected, None))
mlp.down_proj = down_proj
mlp.act_fn = act_fn
with patch(
"vllm.model_executor.models.nemotron_h.maybe_fused_act_quant",
return_value=fused,
) as maybe_fused:
result = mlp(Mock())
maybe_fused.assert_called_once_with(act_fn, projected, down_proj)
act_fn.assert_not_called()
assert result is fused