Skip to content

Commit c69c682

Browse files
author
s50057208
committed
fix: fix: Fixed the patch so it applies correctly without errors
1 parent eb2ff52 commit c69c682

16 files changed

Lines changed: 79 additions & 85 deletions

test_upstream/test/distributed/_composable/fsdp/test_fully_shard_overlap.py.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ index 2d1cc77..7dbd122 100644
1010
+
1111
# Owner(s): ["oncall: distributed"]
1212

13-
import copy
13+
import contextlib

test_upstream/test/distributed/_composable/test_replicate_mixed_precision.py.patch

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
diff --git a/test/distributed/_composable/test_replicate_mixed_precision.py b/test/distributed/_composable/test_replicate_mixed_precision.py
2-
index 8a03bdb..8924f15 100644
32
--- a/test/distributed/_composable/test_replicate_mixed_precision.py
43
+++ b/test/distributed/_composable/test_replicate_mixed_precision.py
5-
@@ -1,6 +1,8 @@
6-
# Owner(s): ["oncall: distributed"]
4+
@@ -5,6 +5,8 @@
5+
import functools
76

87
import torch
98
+import torch_npu

test_upstream/test/distributed/rpc/test_tensorpipe_agent.py.patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ index e21460ba04c..84afb6ecfd5 100644
1010
+
1111
#!/usr/bin/env python3
1212
# Owner(s): ["oncall: distributed"]
13+

test_upstream/test/dynamo/test_functions.py.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ index 48e08b0..d1fea78 100644
33
--- a/test/dynamo/test_functions.py
44
+++ b/test/dynamo/test_functions.py
55
@@ -5454,7 +5454,7 @@ class DefaultsTests(torch._dynamo.test_case.TestCase):
6-
6+
77
opt_fn = torch.compile(fn, backend="eager", fullgraph=True)
8-
8+
99
- x = [torch.randn(4), [torch.randn(4), torch.randn(4)]]
1010
+ x = [torch.randn(4).npu(), [torch.randn(4).npu(), torch.randn(4).npu()]]
11-
11+
1212
def f(y):
1313
return y * 2
1414
@@ -5466,8 +5466,8 @@ class DefaultsTests(torch._dynamo.test_case.TestCase):
1515
self.assertTrue(type(ref) is type(res))
16-
16+
1717
x = {
1818
- "a": torch.randn(4),
1919
- "b": [torch.randn(4), torch.randn(4)],

test_upstream/test/dynamo/test_guard_serialization.py.patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ diff --git a/test/dynamo/test_guard_serialization.py b/test/dynamo/test_guard_se
22
index 99727bb..808d7a5 100644
33
--- a/test/dynamo/test_guard_serialization.py
44
+++ b/test/dynamo/test_guard_serialization.py
5-
@@ -1,6 +1,8 @@
6-
# Owner(s): ["module: dynamo"]
5+
@@ -13,5 +13,7 @@
76

87
import torch
98
+import torch_npu

test_upstream/test/dynamo/test_install_free_tensors.py.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ index 438ad5c..c36dca2 100644
33
--- a/test/dynamo/test_install_free_tensors.py
44
+++ b/test/dynamo/test_install_free_tensors.py
55
@@ -5,6 +5,8 @@ from typing import Any
6-
6+
77
import torch
88
import torch._dynamo
99
+import torch_npu

test_upstream/test/dynamo/test_misc.py.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ index 893fe24..fca0602 100644
33
--- a/test/dynamo/test_misc.py
44
+++ b/test/dynamo/test_misc.py
55
@@ -12569,7 +12569,7 @@ def ___make_guard_fn():
6-
6+
77
# Call create_symbolic_sizes_strides_storage_offset on both of them.
88
r = main.create_symbolic_sizes_strides_storage_offset(
99
- torch.randn(3, 2), ConstantSource("x")
1010
+ torch.randn(3, 2).npu(), ConstantSource("x")
1111
)
12-
12+
1313
# Create a guard: size[0] == 3 (call evaluate_expr)
1414
@@ -12623,7 +12623,7 @@ ShapeEnv not equal: field values don't match:
1515
def test_shape_env_equal_create_symbolic_sizes_strides_storage_offset(self):
@@ -21,7 +21,7 @@ index 893fe24..fca0602 100644
2121
self.assertExpectedRaisesInline(
2222
NotEqualError,
2323
@@ -12693,10 +12693,10 @@ ShapeEnv not equal: field values don't match:
24-
24+
2525
# Call create_symbolic_sizes_strides_storage_offset on both of them.
2626
r = main.create_symbolic_sizes_strides_storage_offset(
2727
- torch.randn(3, 2), ConstantSource("x")
@@ -31,10 +31,10 @@ index 893fe24..fca0602 100644
3131
- torch.randn(3, 2), ConstantSource("x")
3232
+ torch.randn(3, 2).npu(), ConstantSource("x")
3333
)
34-
34+
3535
# Create a guard: size[0] % 3 == 0 (only in the main ShapeEnv)
3636
@@ -12733,10 +12733,10 @@ ShapeEnv not equal: field values don't match:
37-
37+
3838
# Call create_symbolic_sizes_strides_storage_offset on both of them.
3939
r = main.create_symbolic_sizes_strides_storage_offset(
4040
- torch.randn(3, 2), ConstantSource("x")
@@ -44,10 +44,10 @@ index 893fe24..fca0602 100644
4444
- torch.randn(3, 2), ConstantSource("x")
4545
+ torch.randn(3, 2).npu(), ConstantSource("x")
4646
)
47-
47+
4848
# Create a guard: size[0] == 3 (only in the main ShapeEnv)
4949
@@ -12776,10 +12776,10 @@ ShapeEnv not equal: field values don't match:
50-
50+
5151
# Call create_symbolic_sizes_strides_storage_offset on both of them.
5252
r = main.create_symbolic_sizes_strides_storage_offset(
5353
- torch.randn(3, 2), ConstantSource("x")
@@ -57,5 +57,5 @@ index 893fe24..fca0602 100644
5757
- torch.randn(3, 2), ConstantSource("x")
5858
+ torch.randn(3, 2).npu(), ConstantSource("x")
5959
)
60-
60+
6161
# Create a guard: size[0] >= 3 (only in the main ShapeEnv)

test_upstream/test/dynamo/test_python_autograd.py.patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ index 2acaf67..d6d8162 100644
88
+
99
# Owner(s): ["module: dynamo"]
1010
from typing import NamedTuple, TYPE_CHECKING
11+

test_upstream/test/fx/test_subgraph_rewriter.py.patch

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,4 @@ index d19ee70..5149c63 100644
177177
+ x1 = torch.randn(3, 4).npu()
178178

179179
subgraph_rewriter.replace_pattern(traced, pattern, replacement)
180-
#
181-
# NPU Patch Explanation:
182-
#
183-
# Key modifications:
184-
# - Changed all torch.rand/torch.randn tensor creations to use .npu() method
185-
# - All test input tensors now created on NPU device
186-
# - Subgraph rewriter tests now execute on NPU instead of CPU
187-
# - Pattern matching and replacement operations validated on NPU
188-
# - No import changes needed as torch_npu is typically imported elsewhere
180+

test_upstream/test/inductor/test_aot_inductor.py.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ index 45444ae3d7f..f533beabb7e 100644
55
@@ -13,7 +13,6 @@ import zipfile
66
from unittest import skip
77
from unittest.mock import patch
8-
8+
99
-import torch
1010
import torch._export
1111
import torch._inductor
@@ -14,34 +14,34 @@ index 45444ae3d7f..f533beabb7e 100644
1414
if __name__ == "__main__":
1515
sys.exit(0)
1616
raise
17+
1718
-
1819
+import torch_npu._inductor
19-
2020
def get_module_ext_type():
2121
if IS_WINDOWS:
2222
@@ -532,7 +531,6 @@ class AOTInductorTestsTemplate:
2323
new_output = runner_call(test_inputs)
2424
self.assertEqual(expected, new_output)
25-
25+
2626
- @requires_gpu
2727
def test_duplicate_constant_folding(self):
2828
class Model(torch.nn.Module):
2929
def __init__(self, device):
3030
@@ -679,7 +677,6 @@ class AOTInductorTestsTemplate:
3131
dynamic_shapes=dynamic_shapes,
3232
)
33-
33+
3434
- @requires_gpu
3535
def test_multi_device(self):
3636
if self.device == "cpu" and GPU_TYPE == "xpu":
3737
raise unittest.SkipTest(
3838
@@ -8651,7 +8648,5 @@ class TestCheckLowerboundConfig(TestCase):
39-
39+
4040
if __name__ == "__main__":
4141
from torch._inductor.test_case import run_tests
4242
-
4343
- # cpp_extension N/A in fbcode
4444
- if HAS_GPU or sys.platform == "darwin":
4545
- run_tests(needs="filelock")
46-
+
46+
+
4747
+ run_tests(needs="filelock")

0 commit comments

Comments
 (0)