update (#2978)
Some checks failed
Deploy GitHub Pages / deploy (push) Has been cancelled

This commit is contained in:
bukejiyu
2025-07-24 00:16:42 +08:00
committed by GitHub
parent 85a78d695d
commit bfeb664ab8
3 changed files with 57 additions and 28 deletions

View File

@@ -32,6 +32,20 @@ from fastdeploy.model_executor.models.tp_utils import (
from fastdeploy.platforms import current_platform
def load_reordered_experts(model_path: str, key_name: str):
from safetensors import safe_open
with open(os.path.join(model_path, "model.safetensors.index.json"), "r") as f:
weight_list = json.load(f)["weight_map"]
safetensor_path = os.path.join(model_path, weight_list[key_name])
with safe_open(safetensor_path, framework="np", device="cpu") as f:
if key_name in f.keys():
weight = f.get_tensor(key_name)
weight = paddle.Tensor(weight, zero_copy=True)
weight = weight._copy_to(paddle.framework._current_expected_place(), False)
return weight
def load_ep_checkpoint(model_path: str, fd_config: FDConfig, return_numpy: bool = False):
"""
load ep checkpoint