forked from Karylab-cklius/vllm
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
752a3a5044 | ||
|
|
3c31722d6d | ||
|
|
702f4814fe | ||
|
|
dd10e03f95 | ||
|
|
3d1c21a6fc | ||
|
|
e89b9c26d9 |
@@ -9,7 +9,7 @@ torchaudio==2.11.0
|
||||
# These must be updated alongside torch
|
||||
torchvision==0.26.0 # Required for phi3v processor. See https://github.com/pytorch/vision?tab=readme-ov-file#installation for corresponding version
|
||||
torchcodec >= 0.14
|
||||
PyNvVideoCodec==2.1.0
|
||||
PyNvVideoCodec==2.0.4
|
||||
# FlashInfer should be updated together with the Dockerfile
|
||||
flashinfer-python==0.6.13
|
||||
flashinfer-cubin==0.6.13
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -186,9 +186,10 @@ def FusedMoE(
|
||||
has_bias: Whether expert layers have bias terms
|
||||
is_sequence_parallel: Whether sequence parallelism is enabled
|
||||
reduce_results: Whether to all-reduce the final output. Setting this
|
||||
to False (to fuse the all-reduce downstream) is only honored on the
|
||||
late-AR path.
|
||||
expert_mapping: Expert parameter mapping for weight loading
|
||||
to False (to fuse the all-reduce downstream) is only honored on
|
||||
the late-AR path.
|
||||
ckpt_names: Checkpoint parameter name tuple (gate_proj, down_proj,
|
||||
up_proj) used for weight loading
|
||||
n_shared_experts: Number of shared experts to fuse into the routed
|
||||
grouped GEMM (ROCm; requires aiter FSE or the router-append path)
|
||||
router_logits_dtype: Data type for router logits buffers
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,10 +8,14 @@ from typing import Literal, overload
|
||||
|
||||
from vllm.distributed.kv_events import BlockStored, KVCacheEvent
|
||||
from vllm.logger import init_logger
|
||||
from vllm.utils.math_utils import cdiv
|
||||
from vllm.v1.core.kv_cache_coordinator import get_kv_cache_coordinator
|
||||
from vllm.v1.core.kv_cache_metrics import KVCacheMetricsCollector
|
||||
from vllm.v1.core.kv_cache_utils import KVCacheBlock
|
||||
from vllm.v1.kv_cache_interface import (
|
||||
AttentionSpec,
|
||||
CrossAttentionSpec,
|
||||
EncoderOnlyAttentionSpec,
|
||||
KVCacheConfig,
|
||||
get_kv_cache_spec_kind,
|
||||
get_kv_cache_spec_sliding_window,
|
||||
@@ -593,6 +597,26 @@ class KVCacheManager:
|
||||
"""Get the block ids of a request."""
|
||||
return self.get_blocks(request_id).get_block_ids()
|
||||
|
||||
def get_block_ids_for_computed_tokens(
|
||||
self,
|
||||
request_id: str,
|
||||
num_computed_tokens: int,
|
||||
) -> tuple[list[int], ...]:
|
||||
"""Get block ids covering the request's computed tokens."""
|
||||
block_ids = self.get_block_ids(request_id)
|
||||
clipped_block_ids: list[list[int]] = []
|
||||
for group, ids in zip(self.kv_cache_config.kv_cache_groups, block_ids):
|
||||
spec = group.kv_cache_spec
|
||||
if not isinstance(spec, AttentionSpec) or isinstance(
|
||||
spec, (CrossAttentionSpec, EncoderOnlyAttentionSpec)
|
||||
):
|
||||
clipped_block_ids.append(ids)
|
||||
continue
|
||||
|
||||
num_valid_blocks = cdiv(num_computed_tokens, spec.block_size)
|
||||
clipped_block_ids.append(ids[:num_valid_blocks])
|
||||
return tuple(clipped_block_ids)
|
||||
|
||||
def cache_blocks(self, request: Request, num_computed_tokens: int) -> None:
|
||||
"""Cache the blocks for the request, if enabled.
|
||||
|
||||
|
||||
@@ -872,12 +872,10 @@ class Scheduler(SchedulerInterface):
|
||||
if num_new_tokens == 0:
|
||||
break
|
||||
|
||||
# Handles an edge case when P/D Disaggregation
|
||||
# is used with Spec Decoding where an
|
||||
# extra block gets allocated which
|
||||
# creates a mismatch between the number
|
||||
# of local and remote blocks.
|
||||
limit_lookahead_tokens = load_kv_async and self.use_eagle
|
||||
# During async KV load, no forward pass is run yet.
|
||||
# Allocate speculative lookahead slots later to avoid
|
||||
# mismatching local and remote block counts.
|
||||
limit_lookahead_tokens = load_kv_async and self.num_lookahead_tokens > 0
|
||||
effective_lookahead_tokens = (
|
||||
0 if limit_lookahead_tokens else self.num_lookahead_tokens
|
||||
)
|
||||
@@ -2371,7 +2369,10 @@ class Scheduler(SchedulerInterface):
|
||||
num_prompt_tokens=request.num_prompt_tokens,
|
||||
)
|
||||
|
||||
block_ids = self.kv_cache_manager.get_block_ids(request.request_id)
|
||||
block_ids = self.kv_cache_manager.get_block_ids_for_computed_tokens(
|
||||
request_id=request.request_id,
|
||||
num_computed_tokens=request.num_computed_tokens,
|
||||
)
|
||||
|
||||
if not isinstance(self.connector, SupportsHMA):
|
||||
# NOTE(Kuntai): We should deprecate this code path after we enforce
|
||||
|
||||
@@ -11,7 +11,7 @@ from __future__ import annotations
|
||||
import time
|
||||
from collections.abc import Iterable, Sequence
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from typing_extensions import override
|
||||
|
||||
@@ -115,7 +115,7 @@ class P2PSecondaryTierManager(SecondaryTierManager):
|
||||
port: int = 7777,
|
||||
backends: list[str] | None = None,
|
||||
num_threads: int = 4,
|
||||
**kwargs,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Initialize the P2P secondary tier manager.
|
||||
|
||||
|
||||
@@ -49,7 +49,13 @@ def _torch_cuda_wrapper():
|
||||
torch.cuda.current_stream = partial(torch.xpu.current_stream)
|
||||
torch.cuda.stream = partial(torch.xpu.stream)
|
||||
torch.cuda.set_stream = partial(torch.xpu.set_stream)
|
||||
torch.cuda.Event = partial(torch.xpu.Event)
|
||||
|
||||
# torch.xpu.Event does not accept the ``blocking`` kwarg that
|
||||
# torch.cuda.Event supports, so drop it here.
|
||||
def _xpu_event(*args, blocking=None, **kwargs):
|
||||
return torch.xpu.Event(*args, **kwargs)
|
||||
|
||||
torch.cuda.Event = _xpu_event
|
||||
if supports_xpu_graph():
|
||||
torch.cuda.graph = partial(torch.xpu.graph)
|
||||
torch.cuda.CUDAGraph = torch.xpu.XPUGraph
|
||||
|
||||
Reference in New Issue
Block a user