Support DeepSeek V3.2 Exp (#11061)
Co-authored-by: Stefan He <11166516+hebiao064@users.noreply.github.com> Co-authored-by: Liangsheng Yin <95566987+hnyls2002@users.noreply.github.com> Co-authored-by: Baizhou Zhang <56809903+fridge003@users.noreply.github.com> Co-authored-by: DarkSharpness <76582120+darksharpness@users.noreply.github.com> Co-authored-by: ZhengdQin <46387172+zhengdqin@users.noreply.github.com> Co-authored-by: DarkSharpness <2040703891@qq.com> Co-authored-by: hnyls2002 <lsyincs@gmail.com> Co-authored-by: Zhengda Qin <zhengdqin@gmail.com> Co-authored-by: Liangsheng Yin <hnyls2002@gmail.com> Co-authored-by: HAI <hixiao@gmail.com> Co-authored-by: Baizhou Zhang <sobereddiezhang@gmail.com>
This commit is contained in:
co-authored by
Stefan He
Liangsheng Yin
Baizhou Zhang
DarkSharpness
ZhengdQin
DarkSharpness
hnyls2002
Zhengda Qin
Liangsheng Yin
HAI
Baizhou Zhang
parent
292a867ad9
commit
efbc687c28
@@ -471,7 +471,7 @@ def is_pin_memory_available() -> bool:
|
||||
|
||||
class LayerFn(Protocol):
|
||||
|
||||
def __call__(self, layer_id: int, prefix: str) -> torch.nn.Module: ...
|
||||
def __call__(self, idx: int, prefix: str) -> torch.nn.Module: ...
|
||||
|
||||
|
||||
def make_layers(
|
||||
@@ -482,7 +482,7 @@ def make_layers(
|
||||
prefix: str = "",
|
||||
return_tuple: bool = False,
|
||||
offloader_kwargs: Dict[str, Any] = {},
|
||||
) -> Tuple[int, int, torch.nn.ModuleList]:
|
||||
) -> Tuple[torch.nn.Module, int, int]:
|
||||
"""Make a list of layers with the given layer function"""
|
||||
# circula imports
|
||||
from sglang.srt.distributed import get_pp_indices
|
||||
|
||||
@@ -123,6 +123,38 @@ def get_hf_text_config(config: PretrainedConfig):
|
||||
return config
|
||||
|
||||
|
||||
# Temporary hack for DeepSeek-V3.2 model
|
||||
def _load_deepseek_v32_model(
|
||||
model_path: str,
|
||||
trust_remote_code: bool = False,
|
||||
revision: Optional[str] = None,
|
||||
**kwargs,
|
||||
):
|
||||
# first get the local path
|
||||
local_path = download_from_hf(model_path)
|
||||
# then load the config file in json
|
||||
config_file = os.path.join(local_path, "config.json")
|
||||
if not os.path.exists(config_file):
|
||||
raise RuntimeError(f"Can't find config file in {local_path}.")
|
||||
|
||||
with open(config_file, "r") as f:
|
||||
config_json = json.load(f)
|
||||
|
||||
config_json["architectures"] = ["DeepseekV3ForCausalLM"]
|
||||
config_json["model_type"] = "deepseek_v3"
|
||||
|
||||
tmp_path = os.path.join(local_path, "_tmp_config_folder")
|
||||
os.makedirs(tmp_path, exist_ok=True)
|
||||
|
||||
unique_path = os.path.join(tmp_path, f"deepseek_v32_{os.getpid()}")
|
||||
with open(unique_path, "w") as f:
|
||||
json.dump(config_json, f)
|
||||
|
||||
return AutoConfig.from_pretrained(
|
||||
unique_path, trust_remote_code=trust_remote_code, revision=revision, **kwargs
|
||||
)
|
||||
|
||||
|
||||
@lru_cache_frozenset(maxsize=32)
|
||||
def get_config(
|
||||
model: str,
|
||||
@@ -144,9 +176,17 @@ def get_config(
|
||||
client.pull_files(ignore_pattern=["*.pt", "*.safetensors", "*.bin"])
|
||||
model = client.get_local_dir()
|
||||
|
||||
config = AutoConfig.from_pretrained(
|
||||
model, trust_remote_code=trust_remote_code, revision=revision, **kwargs
|
||||
)
|
||||
try:
|
||||
config = AutoConfig.from_pretrained(
|
||||
model, trust_remote_code=trust_remote_code, revision=revision, **kwargs
|
||||
)
|
||||
except ValueError as e:
|
||||
if not "deepseek_v32" in str(e):
|
||||
raise e
|
||||
config = _load_deepseek_v32_model(
|
||||
model, trust_remote_code=trust_remote_code, revision=revision, **kwargs
|
||||
)
|
||||
|
||||
if (
|
||||
config.architectures is not None
|
||||
and config.architectures[0] == "Phi4MMForCausalLM"
|
||||
|
||||
Reference in New Issue
Block a user