A high-throughput and memory-efficient inference and serving engine for LLMs
fix: guard flash-attn rotary import (#42679)
Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
Yufeng He committed
Jun 11, 2026 at 20:43 UTC
1f60771c744811e027f1309b9093cded7521d953
1 file changed
+7
-5
vllm/model_executor/layers/rotary_embedding/common.py
+7
-5
@@ -2,7 +2,8 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import math
5
-from importlib.util import find_spec
5
+from contextlib import suppress
6
+from importlib import import_module
7
8
import torch
9
@@ -135,10 +136,11 @@ class ApplyRotaryEmb(CustomOp):
136
self.enable_fp32_compute = enable_fp32_compute
137
138
self.apply_rotary_emb_flash_attn = None
138
- if not current_platform.is_cpu() and find_spec("flash_attn") is not None:
139
- from flash_attn.ops.triton.rotary import apply_rotary
140
-
141
- self.apply_rotary_emb_flash_attn = apply_rotary
139
+ if not current_platform.is_cpu():
140
+ with suppress(ModuleNotFoundError):
141
+ self.apply_rotary_emb_flash_attn = import_module(
142
+ "flash_attn.ops.triton.rotary"
143
+ ).apply_rotary
144
145
@staticmethod
146
def forward_static(