8000 Windows Dynamo Error Removal CI Check (#115969) · pytorch/pytorch@e0f6fa6 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0f6fa6

Browse files
gs-olivestellaraccident
authored andcommitted
Windows Dynamo Error Removal CI Check (#115969)
Rebase of #111313 onto `main`, for CI validation Co-authored-by: Stella Laurenzo <stellaraccident@gmail.com> Pull Request resolved: #115969 Approved by: https://github.com/PaliC, https://github.com/thiagocrepaldi
1 parent 9201d73 commit e0f6fa6

16 files changed

+66
-13
lines changed

test/export/test_db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
parametrize,
1616
run_tests,
1717
TestCase,
18+
IS_WINDOWS
1819
)
1920

20-
21+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
2122
@unittest.skipIf(not torchdynamo.is_dynamo_supported(), "dynamo doesn't support")
2223
class ExampleTests(TestCase):
2324
# TODO Maybe we should make this tests actually show up in a file?

test/export/test_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def branch_on_shape(x: torch.Tensor):
139139
# Being able to export means shape is preserved as static
140140
export(WrapperModule(branch_on_shape), inp)
141141

142-
142+
@unittest.skipIf(IS_WINDOWS, "Windows isn't supported for this case")
143143
@unittest.skipIf(not torchdynamo.is_dynamo_supported(), "dynamo isn't support")
144144
class TestExport(TestCase):
145145
def _test_export_same_as_eager(self, f, args, kwargs=None):

test/export/test_pass_infra.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from torch._export.pass_base import _ExportPassBaseDeprecatedDoNotUse
99
from torch.export import export
1010
from torch.fx.passes.infra.pass_base import PassResult
11-
from torch.testing._internal.common_utils import run_tests, TestCase
11+
from torch.testing._internal.common_utils import run_tests, TestCase, IS_WINDOWS
1212

1313

1414
@unittest.skipIf(not is_dynamo_supported(), "Dynamo not supported")
@@ -41,6 +41,7 @@ class NullPass(_ExportPassBaseDeprecatedDoNotUse):
4141
self.assertEqual(new_node.op, old_node.op)
4242
self.assertEqual(new_node.target, old_n B41A ode.target)
4343

44+
@unittest.skipIf(IS_WINDOWS, "Windows not supported")
4445
def test_cond(self) -> None:
4546
class M(torch.nn.Module):
4647
def __init__(self):

test/export/test_passes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from torch.fx.passes.infra.partitioner import Partition
2727
from torch.fx.passes.operator_support import OperatorSupport
2828
from torch.testing import FileCheck
29-
from torch.testing._internal.common_utils import run_tests, TestCase, skipIfTorchDynamo
29+
from torch.testing._internal.common_utils import run_tests, TestCase, skipIfTorchDynamo, IS_WINDOWS
3030
from torch.utils import _pytree as pytree
3131

3232

@@ -276,6 +276,7 @@ def forward(self, x):
276276
new_inp = torch.tensor([1, 1, 1, 1])
277277
self.assertEqual(mod(new_inp), ep.module()(new_inp))
278278

279+
@unittest.skipIf(IS_WINDOWS, "Windows not supported")
279280
def test_runtime_assert_inline_constraints_for_cond(self) -> None:
280281
class M(torch.nn.Module):
281282
def __init__(self):

test/export/test_serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
221221
g.nodes[1].inputs[0].arg.as_tensor.name
222222
)
223223

224-
224+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
225225
@unittest.skipIf(not torchdynamo.is_dynamo_supported(), "dynamo doesn't support")
226226
class TestDeserialize(TestCase):
227227
def check_graph(self, fn, inputs, dynamic_shapes=None, _check_meta=True) -> None:

test/export/test_unflatten.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def forward(self, x):
210210
id(getattr(unflattened_module.sub_net, "2")),
211211
)
212212

213+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
213214
@skipIfTorchDynamo("Non strict mode is not meant to run with dynamo")
214215
def test_unflatten_preserve_signature(self):
215216
class NestedChild(torch.nn.Module):

test/export/test_upgrade.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from torch.testing._internal.common_utils import (
1111
run_tests,
1212
TestCase,
13+
IS_WINDOWS,
1314
)
1415

1516
TEST_UPGRADERS = {
@@ -115,6 +116,7 @@ def forward(self, a: torch.Tensor, b):
115116
custom_op_count = count_op(upgraded.graph, "aten::div__Scalar_mode_0_3")
116117
self.assertEqual(custom_op_count, 1)
117118

119+
@unittest.skipIf(IS_WINDOWS, "Test case not supported on Windows")
118120
def test_div_upgrader_pass_return_new_op_after_retrace(self):
119121
class Foo(torch.nn.Module EF5E ):
120122
def forward(self, a: torch.Tensor, b):

test/export/test_verifier.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from torch._export.verifier import SpecViolationError, Verifier
1111
from torch.export.exported_program import InputKind, InputSpec, TensorArgument
12-
from torch.testing._internal.common_utils import run_tests, TestCase
12+
from torch.testing._internal.common_utils import run_tests, TestCase, IS_WINDOWS
1313

1414
@unittest.skipIf(not is_dynamo_supported(), "dynamo isn't supported")
1515
class TestVerifier(TestCase):
@@ -56,6 +56,7 @@ def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
5656
with self.assertRaises(SpecViolationError):
5757
verifier.check(ep)
5858

59+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
5960
def test_verifier_higher_order(self) -> None:
6061
class Foo(torch.nn.Module):
6162
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
@@ -76,6 +77,7 @@ def false_fn(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
7677
verifier = Verifier()
7778
verifier.check(ep)
7879

80+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
7981
def test_verifier_nested_invalid_module(self) -> None:
8082
class Foo(torch.nn.Module):
8183
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:

test/functorch/test_aotdispatch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
run_tests,
1414
IS_ARM64,
1515
IS_MACOS,
16+
IS_WINDOWS,
1617
IS_X86,
1718
compare_equal_outs_and_grads,
1819
outs_and_grads,
@@ -3324,6 +3325,7 @@ def fn(p, x):
33243325
):
33253326
aot_export_module(mod, [inp], trace_joint=True, output_loss_index=1)
33263327

3328+
@unittest.skipIf(IS_WINDOWS, "Windows isn't supported for this case")
33273329
@unittest.skipIf(not torch._dynamo.is_dynamo_supported(), "Cond needs dynamo to run")
33283330
def test_aot_export_with_torch_cond(self):
33293331
class M(torch.nn.Module):

test/functorch/test_control_flow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from functorch.experimental.control_flow import UnsupportedAliasMutationException, cond
1111
from torch._higher_order_ops.while_loop import while_loop
1212
from torch.fx.experimental.proxy_tensor import make_fx
13-
from torch.testing._internal.common_utils import run_tests, TestCase
13+
from torch.testing._internal.common_utils import run_tests, TestCase, IS_WINDOWS
1414
from torch.testing._internal.common_quantization import skipIfNoDynamoSupport
1515
from torch._subclasses.functional_tensor import FunctionalTensor, CppFunctionalizeAPI, PythonFunctionalizeAPI, FunctionalTensorMode
1616

@@ -130,7 +130,7 @@ def forward(self, *operands):
130130
return self._reduce(*operands)
131131

132132

133-
133+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
134134
@skipIfNoDynamoSupport
135135
class TestControlFlow(TestCase):
136136
def setUp(self):
@@ -316,6 +316,7 @@ def fwbw(map_op, f, x, y):
316316
self.assertEqual(true_outs, fake_outs)
317317

318318

319+
@unittest.skipIf(IS_WINDOWS, "Windows not supported for this test")
319320
@skipIfNoDynamoSupport
320321
class TestControlFlowTraced(TestCase):
321322
def setUp(self):

test/quantization/pt2e/test_x86inductor_quantizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
NodeSpec as ns,
1515
QuantizationTestCase,
1616
skipIfNoX86,
17-
skipIfNoDynamoSupport,
17+
skipIfNoInductorSupport,
1818
)
1919
from torch.testing._internal.common_utils import skipIfTorchDynamo
2020
from torch.testing._internal.common_quantized import override_quantized_engine
@@ -340,7 +340,7 @@ def _test_quantizer(
340340
)
341341
return export_model, prepare_model, convert_model
342342

343-
@skipIfNoDynamoSupport
343+
@skipIfNoInductorSupport
344344
class TestQuantizePT2EX86Inductor(X86InductorQuantTestCase):
345345
@skipIfNoX86
346346
def test_conv2d(self):

test/test_content_store.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
# Owner(s): ["oncall: pt2"]
22

33
import tempfile
4+
import unittest
45

56
import torch
67
from torch._prims.debug_prims import load_tensor_reader
78
from torch._subclasses.fake_tensor import FakeTensor, FakeTensorMode
89
from torch.multiprocessing.reductions import StorageWeakRef
910
from torch.testing._internal.common_device_type import instantiate_device_type_tests
10-
from torch.testing._internal.common_utils import run_tests, skipIfRocm, TestCase
11+
from torch.testing._internal.common_utils import (
12+
IS_WINDOWS,
13+
run_tests,
14+
skipIfRocm,
15+
TestCase,
16+
)
1117
from torch.utils._content_store import (
1218
ContentStoreReader,
1319
ContentStoreWriter,
1420
hash_storage,
1521
)
1622

1723

24+
@unittest.skipIf(IS_WINDOWS, "Test case not supported on Windows")
1825
class TestContentStore(TestCase):
1926
def test_basic(self, device):
2027
# setup test data

torch/_dynamo/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
explain,
2222
export,
2323
is_dynamo_supported,
24+
is_inductor_supported,
2425
optimize,
2526
optimize_assert,
2627
OptimizedModule,

torch/_dynamo/backends/inductor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# mypy: ignore-errors
22

3+
import sys
4+
35
from torch._dynamo import register_backend
46

57

68
@register_backend
79
def inductor(*args, **kwargs):
10+
if sys.platform == "win32":
11+
raise RuntimeError("Windows not yet supported for inductor")
12+
813
# do import here to avoid loading inductor into memory when it is not used
914
from torch._inductor.compile_fx import compile_fx
1015

torch/_dynamo/eval_frame.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,6 @@ def __call__(self, fn):
592592

593593

594594
def check_if_dynamo_supported():
595-
if sys.platform == "win32":
596-
raise RuntimeError("Windows not yet supported for torch.compile")
597595
if sys.version_info >= (3, 12):
598596
raise RuntimeError("Python 3.12+ not yet supported for torch.compile")
599597

@@ -606,6 +604,21 @@ def is_dynamo_supported():
606604
return False
607605

608606

607+
def check_if_inductor_supported():
608+
check_if_dynamo_supported()
609+
610+
if sys.platform == "win32":
611+
raise RuntimeError("Windows not yet supported for inductor")
612+
613+
614+
def is_inductor_supported():
615+
try:
616+
check_if_inductor_supported()
617+
return True
618+
except Exception:
619+
return False
620+
621+
609622
def optimize(
610623
backend="inductor",
611624
*,

torch/testing/_internal/common_quantization.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,22 @@ def wrapper(*args, **kwargs):
423423
fn(*args, **kwargs)
424424
return wrapper
425425

426+
def skipIfNoInductorSupport(fn):
427+
reason = "inductor doesn't support."
428+
if isinstance(fn, type):
429+
if not torchdynamo.is_inductor_supported():
430+
fn.__unittest_skip__ = True
431+
fn.__unittest_skip_why__ = reason
432+
return fn
433+
434+
@functools.wraps(fn)
435+
def wrapper(*args, **kwargs):
436+
if not torchdynamo.is_inductor_supported():
437+
raise unittest.SkipTest(reason)
438+
else:
439+
fn(*args, **kwargs)
440+
return wrapper
441+
426442
try:
427443
import torchvision # noqa: F401
428444
HAS_TORCHVISION = True

0 commit comments

Comments
 (0)
0