2026-01-17 11:49:18 +08:00
|
|
|
#
|
|
|
|
|
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
# This file is a part of the vllm-ascend project.
|
|
|
|
|
#
|
|
|
|
|
import torch_npu
|
|
|
|
|
from vllm.logger import logger
|
|
|
|
|
|
2026-01-24 20:34:29 +08:00
|
|
|
from vllm_ascend._310p.model_runner_310p import NPUModelRunner310
|
2026-01-17 11:49:18 +08:00
|
|
|
from vllm_ascend.worker.worker import NPUWorker, init_workspace_manager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NPUWorker310(NPUWorker):
|
|
|
|
|
def init_device(self):
|
|
|
|
|
self.device = self._init_device()
|
2026-02-07 09:28:37 +08:00
|
|
|
torch_npu.npu.set_compile_mode(jit_compile=False)
|
2026-01-17 11:49:18 +08:00
|
|
|
|
|
|
|
|
init_workspace_manager(self.device, num_ubatches=1)
|
|
|
|
|
|
|
|
|
|
self.model_runner = NPUModelRunner310(self.vllm_config, self.device)
|
|
|
|
|
|
2026-03-02 20:09:15 +08:00
|
|
|
def save_sharded_state(
|
|
|
|
|
self,
|
|
|
|
|
path: str,
|
|
|
|
|
pattern: str | None = None,
|
|
|
|
|
max_size: int | None = None,
|
|
|
|
|
) -> None:
|
|
|
|
|
from vllm_ascend._310p.sharded_state_loader_310p import ShardedStateLoader310
|
|
|
|
|
|
|
|
|
|
ShardedStateLoader310.save_model(
|
|
|
|
|
self.model_runner.model,
|
|
|
|
|
path,
|
|
|
|
|
pattern=pattern,
|
|
|
|
|
max_size=max_size,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ShardedStateLoader310.generate_quant_description(self.model_runner.model, path)
|
|
|
|
|
|
2026-01-17 11:49:18 +08:00
|
|
|
def _warm_up_atb(self):
|
2026-01-26 14:12:33 +08:00
|
|
|
# 310p device do not support torch_npu._npu_matmul_add_fp32 atb ops
|
2026-01-26 14:33:21 +08:00
|
|
|
logger.info("Skip warm-up atb ops for 310P device.")
|