[Bugfix][CPU] Fix DeepSeek V4.1 import without Triton (#57654)

Signed-off-by: Jiang Wu <245355730+JiangLLM@users.noreply.github.com>
Co-authored-by: Jiang Wu <245355730+JiangLLM@users.noreply.github.com>
This commit is contained in:
Jiang Wu
2026-09-19 05:46:13 +00:00
committed by GitHub
co-authored by Jiang Wu
parent a8d1aa9c99
commit 6af44e2887
3 changed files with 8 additions and 8 deletions
+3 -1
View File
@@ -97,7 +97,8 @@ def test_triton_placeholder_language():
lang = TritonLanguagePlaceholder()
assert isinstance(lang, types.ModuleType)
assert lang.__name__ == "triton.language"
assert lang.constexpr is None
assert lang.constexpr(2**31 - 1) == 2**31 - 1
assert lang.constexpr(1.5) == 1.5
assert lang.dtype is None
assert lang.int64 is None
assert lang.int32 is None
@@ -143,3 +144,4 @@ def test_no_triton_fallback():
assert triton.__class__.__name__ == "TritonPlaceholder"
assert triton.language.__class__.__name__ == "TritonLanguagePlaceholder"
assert tl.__class__.__name__ == "TritonLanguagePlaceholder"
assert tl.constexpr(2**31 - 1) == 2**31 - 1
+1 -1
View File
@@ -124,7 +124,7 @@ class TritonPlaceholder(types.ModuleType):
class TritonLanguagePlaceholder(types.ModuleType):
def __init__(self):
super().__init__("triton.language")
self.constexpr = None
self.constexpr = lambda value: value
self.dtype = None
self.int64 = None
self.int32 = None
+4 -6
View File
@@ -2,22 +2,20 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import torch
from vllm.triton_utils import HAS_TRITON, tl, triton
from vllm.triton_utils import tl, triton
# Smallest positive value produced by Triton's fp32 `tl.rand`. Used by the
# retained Philox helper for rejection sampling.
#
# Triton requires globals accessed from `@triton.jit` functions to be wrapped
# in `tl.constexpr(...)`. We can only do that when Triton is actually
# available — on the CPU worker path `tl` is a placeholder whose `constexpr`
# attribute is `None`, and `tl.constexpr(...)` would crash at import time.
_TL_RAND_MIN = tl.constexpr(4.6566127342e-10) if HAS_TRITON else 4.6566127342e-10
# in `tl.constexpr(...)`.
_TL_RAND_MIN = tl.constexpr(4.6566127342e-10)
# Offset salt keeping the draft's Gumbel noise disjoint from the target's.
# Verification is a probability-ratio test, not a Gumbel coupling, so a proposal
# and the residual it is resampled from must not share a noise vector.
# Positions are int64 and never approach 2**30, so the streams cannot collide.
_DRAFT_NOISE_SALT = tl.constexpr(1 << 30) if HAS_TRITON else (1 << 30)
_DRAFT_NOISE_SALT = tl.constexpr(1 << 30)
@triton.jit