[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:
@@ -97,7 +97,8 @@ def test_triton_placeholder_language():
|
|||||||
lang = TritonLanguagePlaceholder()
|
lang = TritonLanguagePlaceholder()
|
||||||
assert isinstance(lang, types.ModuleType)
|
assert isinstance(lang, types.ModuleType)
|
||||||
assert lang.__name__ == "triton.language"
|
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.dtype is None
|
||||||
assert lang.int64 is None
|
assert lang.int64 is None
|
||||||
assert lang.int32 is None
|
assert lang.int32 is None
|
||||||
@@ -143,3 +144,4 @@ def test_no_triton_fallback():
|
|||||||
assert triton.__class__.__name__ == "TritonPlaceholder"
|
assert triton.__class__.__name__ == "TritonPlaceholder"
|
||||||
assert triton.language.__class__.__name__ == "TritonLanguagePlaceholder"
|
assert triton.language.__class__.__name__ == "TritonLanguagePlaceholder"
|
||||||
assert tl.__class__.__name__ == "TritonLanguagePlaceholder"
|
assert tl.__class__.__name__ == "TritonLanguagePlaceholder"
|
||||||
|
assert tl.constexpr(2**31 - 1) == 2**31 - 1
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class TritonPlaceholder(types.ModuleType):
|
|||||||
class TritonLanguagePlaceholder(types.ModuleType):
|
class TritonLanguagePlaceholder(types.ModuleType):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("triton.language")
|
super().__init__("triton.language")
|
||||||
self.constexpr = None
|
self.constexpr = lambda value: value
|
||||||
self.dtype = None
|
self.dtype = None
|
||||||
self.int64 = None
|
self.int64 = None
|
||||||
self.int32 = None
|
self.int32 = None
|
||||||
|
|||||||
@@ -2,22 +2,20 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
import torch
|
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
|
# Smallest positive value produced by Triton's fp32 `tl.rand`. Used by the
|
||||||
# retained Philox helper for rejection sampling.
|
# retained Philox helper for rejection sampling.
|
||||||
#
|
#
|
||||||
# Triton requires globals accessed from `@triton.jit` functions to be wrapped
|
# Triton requires globals accessed from `@triton.jit` functions to be wrapped
|
||||||
# in `tl.constexpr(...)`. We can only do that when Triton is actually
|
# in `tl.constexpr(...)`.
|
||||||
# available — on the CPU worker path `tl` is a placeholder whose `constexpr`
|
_TL_RAND_MIN = tl.constexpr(4.6566127342e-10)
|
||||||
# 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
|
|
||||||
|
|
||||||
# Offset salt keeping the draft's Gumbel noise disjoint from the target's.
|
# 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
|
# 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.
|
# 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.
|
# 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
|
@triton.jit
|
||||||
|
|||||||
Reference in New Issue
Block a user