已合并
【inductor】fix thread pool when inductor is imported #30476
kkjocker创建于 2月3日
【inductor】fix thread pool when inductor is imported #30476
已合并
kkjocker创建于 2月3日
3 个文件变更+7-1
Mtest/_inductor/test_assert_scalar.py+1-1
@@ -11,7 +11,7 @@ class TestAssertScalar(TestUtils):
11 torch.ops.aten._assert_scalar(condition, "batch size must be positive")11 torch.ops.aten._assert_scalar(condition, "batch size must be positive")
12 return x * 212 return x * 2
13 13 
14- @parametrize('shape', [(1024, 32), (8, 16, 256)])14+ @parametrize('shape', [(512, 64), (4, 32, 128)])
15 @parametrize('dtype', ['float32', 'float16'])15 @parametrize('dtype', ['float32', 'float16'])
16 def test_assert_scalar_pass(self, shape, dtype):16 def test_assert_scalar_pass(self, shape, dtype):
17 input_element = self._generate_tensor(shape, dtype, floatPOSIFLAG=1)17 input_element = self._generate_tensor(shape, dtype, floatPOSIFLAG=1)
Mtorch_npu/__init__.py+1-0
@@ -13,6 +13,7 @@ from functools import wraps
13# Disable autoloading before running 'import torch' to avoid circular dependencies13# Disable autoloading before running 'import torch' to avoid circular dependencies
14ORG_AUTOLOAD = os.getenv("TORCH_DEVICE_BACKEND_AUTOLOAD", "1")14ORG_AUTOLOAD = os.getenv("TORCH_DEVICE_BACKEND_AUTOLOAD", "1")
15os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = "0"15os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = "0"
16+os.environ["TORCH_WARM_POOL"] = "0"
16 17 
17import torch18import torch
18from torch.distributed.fsdp import sharded_grad_scaler19from torch.distributed.fsdp import sharded_grad_scaler
Mtorch_npu/_inductor/__init__.py+5-0
@@ -1,5 +1,10 @@
1 1 
2import os2import os
3+ORG_AUTOLOAD = os.getenv("TORCH_DEVICE_BACKEND_AUTOLOAD", "1")
4+os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = "0"
5+from torch._inductor.async_compile import AsyncCompile
6+AsyncCompile.warm_pool()
7+os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = ORG_AUTOLOAD
3 8 
4if os.getenv('TORCHINDUCTOR_NPU_BACKEND', 'default') == 'mlir':9if os.getenv('TORCHINDUCTOR_NPU_BACKEND', 'default') == 'mlir':
5 try:10 try: