[NPU] fix conflict between empty_cache and use_mem_pool (#21507)

This commit is contained in:
xiazhahe
2026-03-31 15:37:33 +08:00
committed by GitHub
parent dd9c9c1b8e
commit b4cb31f698
3 changed files with 5 additions and 3 deletions
@@ -1108,6 +1108,10 @@ class ModelRunner(ModelRunnerKVCacheMixin):
self.remote_instance_transfer_engine_weight_info = (
self.loader.remote_instance_transfer_engine_weight_info
)
# Cache needs to be cleared after loading model weights (in the self.loader.load_model function).
# To avoid conflict with memory_saver_adapter.region, empty_cache operation is now moved here.
if _is_npu:
torch.npu.empty_cache()
monkey_patch_vllm_parallel_state(reverse=True)
# Publish metadata to ModelExpress if running as seed source
-2
View File
@@ -707,8 +707,6 @@ class DefaultModelLoader(BaseModelLoader):
# parameters onto device for processing and back off after.
with device_loading_context(module, target_device):
quant_method.process_weights_after_loading(module)
if _is_npu:
torch.npu.empty_cache()
class LayeredModelLoader(DefaultModelLoader):
+1 -1
View File
@@ -365,7 +365,7 @@ def get_int_env_var(name: str, default: int = 0) -> int:
def support_triton(backend: str) -> bool:
return backend not in ["torch_native", "intel_amx"]
return backend not in ["torch_native", "intel_amx", "ascend"]
_ENABLE_TORCH_INFERENCE_MODE = get_bool_env_var(