[inductor] Enable dynamo for Windows. RC1 (#131286)
Changes:
1. Enable Windows in `check_if_inductor_supported`.
2. Disable Windows in `AotCodeCompiler`.
3. Force Windows inductor to `c++20` to support `std::enable_if_t`.
4. Disable `test_x86inductor_quantizer` UT on `Windows` temporary, It still some issue need to be fix: https://github.com/pytorch/pytorch/pull/131308 .
Based on this PR, I have run first model `resnet18` on Windows inductor successful.
<img width="1036" alt="image" src="https://github.com/user-attachments/assets/2642bda1-1845-417a-aaba-39bdf22e65d6">
TODO:
1. Upgrade pytorch Windows build to `c++20`.
2. Fix and re-enable `test_x86inductor_quantizer` UT on `Windows`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131286
Approved by: https://github.com/jgong5, https://github.com/jansel
diff --git a/test/quantization/pt2e/test_x86inductor_quantizer.py b/test/quantization/pt2e/test_x86inductor_quantizer.py
index 669ab68..f656212 100644
--- a/test/quantization/pt2e/test_x86inductor_quantizer.py
+++ b/test/quantization/pt2e/test_x86inductor_quantizer.py
@@ -1,6 +1,8 @@
# Owner(s): ["oncall: quantization"]
import copy
import itertools
+
+import sys
from enum import Enum
import torch
@@ -24,7 +26,11 @@
skipIfNoX86,
)
from torch.testing._internal.common_quantized import override_quantized_engine
-from torch.testing._internal.common_utils import skipIfTorchDynamo
+from torch.testing._internal.common_utils import IS_CI, IS_WINDOWS, skipIfTorchDynamo
+
+if IS_WINDOWS and IS_CI:
+ sys.stderr.write("Windows CI still has some issue to be fixed.\n")
+ sys.exit(0)
class NodePosType(Enum):
diff --git a/torch/_dynamo/eval_frame.py b/torch/_dynamo/eval_frame.py
index b05a05c..2990b68 100644
--- a/torch/_dynamo/eval_frame.py
+++ b/torch/_dynamo/eval_frame.py
@@ -683,9 +683,6 @@
def check_if_inductor_supported():
check_if_dynamo_supported()
- if sys.platform == "win32":
- raise RuntimeError("Windows not yet supported for inductor")
-
def is_inductor_supported():
try:
diff --git a/torch/_inductor/codecache.py b/torch/_inductor/codecache.py
index aadcd99..8381b0f 100644
--- a/torch/_inductor/codecache.py
+++ b/torch/_inductor/codecache.py
@@ -1618,6 +1618,9 @@
serialized_extern_kernel_nodes: Optional[str],
cuda: bool,
) -> str:
+ if sys.platform == "win32":
+ raise RuntimeError("AotCodeCompiler not yet supported for inductor")
+
_set_gpu_runtime_env() # cpp_extension consults the env
picked_vec_isa = pick_vec_isa()
diff --git a/torch/_inductor/cpp_builder.py b/torch/_inductor/cpp_builder.py
index 777999a..ef63f4f 100644
--- a/torch/_inductor/cpp_builder.py
+++ b/torch/_inductor/cpp_builder.py
@@ -356,6 +356,12 @@
def _get_cpp_std_cflag(std_num: str = "c++17") -> List[str]:
if _IS_WINDOWS:
+ """
+ On Windows, only c++20 can support `std::enable_if_t`.
+ Ref: https://learn.microsoft.com/en-us/cpp/overview/cpp-conformance-improvements-2019?view=msvc-170#checking-for-abstract-class-types # noqa: B950
+ TODO: discuss upgrade pytorch to c++20.
+ """
+ std_num = "c++20"
return [f"std:{std_num}"]
else:
return [f"std={std_num}"]