[Platform] Fill in the missing backend parameter for torch.compile (#51781)
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
@@ -126,7 +126,7 @@ class DiffusionGemmaProcessingInfo(Gemma4ProcessingInfo):
|
||||
return super().get_mm_max_tokens_per_item(seq_len, mm_counts)
|
||||
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _softcap_logits(logits: torch.Tensor, cap: float) -> torch.Tensor:
|
||||
# fp32 before tanh for numerical stability (matches HF DiffusionGemma).
|
||||
# Compiling fuses the cast/div/tanh/mul into one elementwise kernel over
|
||||
@@ -454,7 +454,7 @@ class DiffusionGemmaForConditionalGeneration(
|
||||
raise ValueError(f"Unsupported modality: {modality}")
|
||||
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _compute_num_rejected(
|
||||
num_logits: torch.Tensor,
|
||||
num_sampled: torch.Tensor,
|
||||
@@ -466,7 +466,7 @@ def _compute_num_rejected(
|
||||
return torch.where(is_denoise, query_lens, num_rejected)
|
||||
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _compiled_sample_step(
|
||||
# Logits from the model [num_decode * CL, vocab]
|
||||
logits: torch.Tensor,
|
||||
|
||||
@@ -61,7 +61,11 @@ def get_rope_shape_decorate(func):
|
||||
|
||||
|
||||
@get_rope_shape_decorate
|
||||
@torch.compile(dynamic=True, disable=current_platform.simple_compile_backend == "tpu")
|
||||
@torch.compile(
|
||||
dynamic=True,
|
||||
backend=current_platform.simple_compile_backend,
|
||||
disable=current_platform.simple_compile_backend == "tpu",
|
||||
)
|
||||
def get_rope_shape(org, interpolation_mode, shape):
|
||||
return (
|
||||
F.interpolate(
|
||||
|
||||
@@ -19,6 +19,7 @@ from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.activation import ReLUSquaredActivation
|
||||
from vllm.model_executor.layers.layernorm import RMSNorm
|
||||
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.transformers_utils.configs.parakeet import ExtractorConfig, ParakeetConfig
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -186,7 +187,7 @@ class ParakeetExtractor:
|
||||
)
|
||||
return self._apply_mel_filters(stft, mel_filters)
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _apply_mel_filters(
|
||||
self, stft_output: torch.Tensor, mel_filters: torch.Tensor
|
||||
) -> torch.Tensor:
|
||||
@@ -195,7 +196,7 @@ class ParakeetExtractor:
|
||||
mel_spec = torch.log(mel_spec + LOG_ZERO_GUARD_VALUE)
|
||||
return mel_spec.permute(0, 2, 1)
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _apply_preemphasis(
|
||||
self, input_features: torch.Tensor, audio_lengths: torch.Tensor
|
||||
) -> torch.Tensor:
|
||||
@@ -213,7 +214,7 @@ class ParakeetExtractor:
|
||||
input_features = input_features.masked_fill(~timemask, 0.0)
|
||||
return input_features
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _normalize_mel_features(
|
||||
self, mel_features: torch.Tensor, audio_lengths: torch.Tensor
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
|
||||
@@ -26,6 +26,7 @@ from vllm.model_executor.models.parakeet import ParakeetExtractor
|
||||
from vllm.multimodal.inputs import AudioItem
|
||||
from vllm.multimodal.processing.processor import PromptUpdateDetails
|
||||
from vllm.multimodal.video_prune.evs import compute_retained_tokens_count
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.tokenizers.hf import HfTokenizer
|
||||
|
||||
from .internvl import calculate_internvl_targets, get_internvl_target_ratios
|
||||
@@ -56,7 +57,7 @@ def calculate_timestamps(
|
||||
return timestamps
|
||||
|
||||
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def _bicubic_resize_and_normalize(
|
||||
tensor: torch.Tensor,
|
||||
size: tuple[int, int] | None = None,
|
||||
|
||||
@@ -338,7 +338,7 @@ class TopKTopPSampler(nn.Module):
|
||||
|
||||
# Note: this is a workaround for
|
||||
# https://github.com/pytorch/pytorch/pull/151218
|
||||
@torch.compile(dynamic=True)
|
||||
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
|
||||
def compiled_random_sample(logits: torch.Tensor) -> torch.Tensor:
|
||||
probs = logits.softmax(dim=-1, dtype=torch.float32)
|
||||
q = torch.empty_like(probs)
|
||||
|
||||
Reference in New Issue
Block a user