Files
sglang/python/sglang/srt/speculative/spec_info.py
2025-09-28 21:06:59 -07:00

38 lines
1020 B
Python

from enum import IntEnum, auto
class SpeculativeAlgorithm(IntEnum):
NONE = auto()
EAGLE = auto()
EAGLE3 = auto()
STANDALONE = auto()
NGRAM = auto()
def is_none(self):
return self == SpeculativeAlgorithm.NONE
def is_eagle(self):
return self == SpeculativeAlgorithm.EAGLE or self == SpeculativeAlgorithm.EAGLE3
def is_eagle3(self):
return self == SpeculativeAlgorithm.EAGLE3
def is_standalone(self):
return self == SpeculativeAlgorithm.STANDALONE
def is_ngram(self):
return self == SpeculativeAlgorithm.NGRAM
@staticmethod
def from_string(name: str):
name_map = {
"EAGLE": SpeculativeAlgorithm.EAGLE,
"EAGLE3": SpeculativeAlgorithm.EAGLE3,
"STANDALONE": SpeculativeAlgorithm.STANDALONE,
"NGRAM": SpeculativeAlgorithm.NGRAM,
None: SpeculativeAlgorithm.NONE,
}
if name is not None:
name = name.upper()
return name_map[name]