Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions vllm/model_executor/models/qwen3_dflash2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import torch
import torch.nn.functional as F
from torch import nn
from transformers import Qwen3Config

from vllm.compilation.decorators import support_torch_compile
from vllm.config import CacheConfig, VllmConfig
Expand Down Expand Up @@ -56,22 +57,11 @@ def _flashinfer_topk() -> Callable[..., tuple[torch.Tensor, torch.Tensor]] | Non
return top_k


_flashinfer_topk_failed = False


def _topk(scores: torch.Tensor, k: int) -> tuple[torch.Tensor, torch.Tensor]:
global _flashinfer_topk_failed
impl = _flashinfer_topk()
if impl is not None and not _flashinfer_topk_failed and scores.is_cuda:
try:
return impl(scores, k, sorted=True, deterministic=True)
except Exception:
_flashinfer_topk_failed = True
logger.warning_once(
"FlashInfer radix top-k unavailable; falling back to torch.topk "
"at roughly half the speed."
)
return torch.topk(scores, k, dim=-1)
if impl is None or not scores.is_cuda:
return torch.topk(scores, k, dim=-1)
return impl(scores, k, sorted=True, deterministic=True)


def _grouped_conv(
Expand Down Expand Up @@ -160,7 +150,7 @@ def __init__(
self,
vllm_config: VllmConfig,
*,
config,
config: Qwen3Config,
layer_idx: int,
cache_config: CacheConfig | None = None,
quant_config: QuantizationConfig | None = None,
Expand Down