Compare commits

...
2 Commits
Author SHA1 Message Date
Hugo Centenoandkhluu 752a3a5044 [Bugfix] Guard mixed-dtype allreduce RMSNorm quant fusions (#48330)
Signed-off-by: hcenteno <hugo.centeno@estudiantat.upc.edu>
(cherry picked from commit 5f8e73cb8b)
2026-07-12 16:40:12 -07:00
Isotr0pyandkhluu 3c31722d6d [Bugfix] Avoid blocking model launching when no system ffmpeg available for TorchCodec (#47888)
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
(cherry picked from commit 5e975eae1a)
2026-07-12 16:39:54 -07:00
4 changed files with 65 additions and 5 deletions
@@ -222,6 +222,25 @@ class TestAllReduceRMSNormStaticQuantFP8Model(torch.nn.Module):
]
class TestAllReduceGemmaRMSNormStaticQuantFP8Model(
TestAllReduceRMSNormStaticQuantFP8Model
):
def __init__(
self,
hidden_size=16,
token_num=16,
eps=1e-6,
dtype: torch.dtype = torch.float16,
):
super().__init__(hidden_size, token_num, eps, dtype)
self.norm = [GemmaRMSNorm(hidden_size, eps) for _ in range(4)]
for norm in self.norm:
norm.weight.requires_grad_(False)
def ops_in_model_before(self):
return [torch.ops.vllm.all_reduce.default]
class TestAiterAllReduceRMSNormGroupQuantFP8Model(torch.nn.Module):
"""Exercises the new ROCm AITER AR+RMS+per-group-FP8-quant patterns.
@@ -416,6 +435,15 @@ class TestAllReduceFusedAddRMSNormStaticQuantFP4Model(torch.nn.Module):
reason="Not supported on ROCm platform",
),
),
pytest.param(
TestAllReduceGemmaRMSNormStaticQuantFP8Model,
True,
False,
marks=pytest.mark.skipif(
current_platform.is_rocm(),
reason="Not supported on ROCm platform",
),
),
pytest.param(
TestAllReduceRMSNormStaticQuantFP8Model,
False,
@@ -606,7 +634,10 @@ def all_reduce_fusion_pass_on_test_model(
)
backend.check_before_ops(model.ops_in_model_before(), fully_replaced=False)
backend.check_after_ops(model.ops_in_model_after())
if test_model_cls is TestAllReduceGemmaRMSNormModel:
if test_model_cls in (
TestAllReduceGemmaRMSNormModel,
TestAllReduceGemmaRMSNormStaticQuantFP8Model,
):
fused_op = torch.ops.vllm.flashinfer_trtllm_fused_allreduce_norm.default
fused_nodes = list(find_op_nodes(fused_op, backend.graph_post_pass))
assert fused_nodes
@@ -752,7 +752,12 @@ class AllReduceFusedAddRMSNormStaticQuantFP8Pattern(BasePattern):
return allreduce[4], allreduce[2]
pm.register_replacement(
pattern, replacement, self.get_inputs(), pm.fwd_only, pm_pass
pattern,
replacement,
self.get_inputs(),
pm.fwd_only,
pm_pass,
extra_check=_norm_input_weight_dtype_match,
)
@@ -941,7 +946,12 @@ class AllReduceFusedAddRMSNormStaticQuantNVFP4Pattern(BasePattern):
return allreduce[4], allreduce[2], allreduce[5]
pm.register_replacement(
pattern, replacement, self.get_inputs(), pm.fwd_only, pm_pass
pattern,
replacement,
self.get_inputs(),
pm.fwd_only,
pm_pass,
extra_check=_norm_input_weight_dtype_match,
)
+3 -2
View File
@@ -15,7 +15,7 @@ import torch
from vllm import envs
from vllm.logger import init_logger
from vllm.utils.import_utils import PlaceholderModule
from vllm.utils.import_utils import PlaceholderModule, check_torchcodec_available
from vllm.utils.mem_constants import MiB_bytes
from vllm.utils.registry import ExtensionManager
@@ -33,7 +33,7 @@ except ImportError:
try:
from torchcodec.decoders import VideoDecoder
except ImportError:
except (ImportError, RuntimeError):
VideoDecoder = PlaceholderModule("torchcodec").placeholder_attr( # type: ignore[assignment]
"decoders.VideoDecoder"
)
@@ -956,6 +956,7 @@ class VideoBackend(
assert not frame_recovery, (
"frame_recovery is only available for `opencv` backend"
)
check_torchcodec_available()
decoder = cls.make_torchcodec_decoder(
data,
num_ffmpeg_threads=num_ffmpeg_threads,
+18
View File
@@ -552,3 +552,21 @@ def has_cutedsl() -> bool:
def has_humming() -> bool:
"""Whether the optional `humming` package is available."""
return _has_module("humming")
def check_torchcodec_available():
"""Whether the optional `torchcodec` package is available."""
try:
import torchcodec # noqa: F401
except RuntimeError as e:
# torchcodec will raise RuntimeError during import instead
# of ImportError when system ffmpeg unavailable, with a
# message that can leak sensitive system information.
# Trim it down to avoid it.
marker = (
"The following exceptions were raised as we tried to load libtorchcodec:"
)
message = str(e)
if marker in message:
raise RuntimeError(message.split(marker, 1)[0].rstrip()) from None
raise e