[Misc] Add ACL_OP_INIT_MODE env var and set default to 1 (#597)

### What this PR does / why we need it?
Fix the bug in torch 2.5.1 that raising segment fault when enable
`pin_memory` while creating a tensor using `torch.tensor`.

### Does this PR introduce _any_ user-facing change?

### How was this patch tested?

---------

Signed-off-by: shen-shanshan <467638484@qq.com>
This commit is contained in:
Shanshan Shen
2025-06-06 20:22:51 +08:00
committed by GitHub
parent 11a7df4270
commit 5d0e9fd19a
2 changed files with 11 additions and 0 deletions

View File

@@ -112,6 +112,15 @@ env_variables: Dict[str, Callable[[], Any]] = {
"VLLM_ASCEND_MODEL_EXECUTE_TIME_OBSERVE":
lambda: bool(int(os.getenv("VLLM_ASCEND_MODEL_EXECUTE_TIME_OBSERVE", '0'))
),
# VLLM_ASCEND_ACL_OP_INIT_MODE:
# 0: default, normal init.
# 1: delay init until launch aclops.
# 2: forbid aclops init and launch.
# Find more details at https://gitee.com/ascend/pytorch/pulls/18094
# We set this var default to `1` in vllm-ascend to avoid segment fault when
# enable `pin_memory` while creating a tensor using `torch.tensor`.
"VLLM_ASCEND_ACL_OP_INIT_MODE":
lambda: os.getenv("VLLM_ASCEND_ACL_OP_INIT_MODE", '1'),
}
# end-env-vars-definition

View File

@@ -24,6 +24,7 @@ import vllm.envs as envs
from vllm.logger import logger
from vllm.platforms import Platform, PlatformEnum
import vllm_ascend.envs as ascend_envs
from vllm_ascend.ascend_config import check_ascend_config, init_ascend_config
from vllm_ascend.utils import ASCEND_QUATIZATION_METHOD, update_aclgraph_sizes
@@ -46,6 +47,7 @@ else:
FlexibleArgumentParser = None
os.environ["RAY_EXPERIMENTAL_NOSET_ASCEND_RT_VISIBLE_DEVICES"] = "1"
os.environ["ACL_OP_INIT_MODE"] = ascend_envs.VLLM_ASCEND_ACL_OP_INIT_MODE
class NPUPlatform(Platform):