Skip to content

Commit

Permalink
Update (base update)
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
jansel committed Jun 19, 2024
1 parent d9b7082 commit a7a33c3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
18 changes: 18 additions & 0 deletions benchmarks/dynamo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,12 @@ def parse_args(args=None):
parser.add_argument(
"--freezing", action="store_true", help="turn on freezing", default=False
)
parser.add_argument(
"--inductor-config",
"-c",
action="append",
help="key=value in torch._inductor.config",
)
parser.add_argument(
"--ci", action="store_true", help="Flag to tell that its a CI run"
)
Expand Down Expand Up @@ -4025,6 +4031,18 @@ def run(runner, args, original_dir=None):
inductor_config.triton.divisible_by_16 = not args.disable_divisible_by_16
if args.inference:
inductor_config.freezing = args.freezing
if args.inductor_config:
for config in args.inductor_config:
key, value = config.split("=")
typ = type(inductor_config.__getattr__(key))
if issubclass(typ, bool):
assert value in ("0", "1", "True", "False")
value = value in ("1", "True")
elif issubclass(typ, (str, int, float)):
value = typ(value)
else:
raise NotImplementedError(typ)
inductor_config.__setattr__(key, value)

runner.setup_amp()

Expand Down
16 changes: 10 additions & 6 deletions test/inductor/test_torchinductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9821,7 +9821,7 @@ def fn(x: torch.Tensor) -> torch.Tensor:
# Inductor specializes on the (unguarded) alignment of the initial input.
# Make sure that for different configurations, nothing breaks.
for offset in (0, 1, 2, 3, 4):
base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=GPU_TYPE)
base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=self.device)
inp = torch.as_strided(base, (64, 64), (64, 1), offset)
torch._dynamo.reset()
fn_c = torch.compile(fn)
Expand All @@ -9831,8 +9831,10 @@ def fn(x: torch.Tensor) -> torch.Tensor:
self.assertEqual(ref, res)

for offset2 in (0, 1, 2, 3, 4):
base2 = torch.randn(64 * 64 + 64, dtype=torch.float32, device=GPU_TYPE)
inp2 = torch.as_strided(base, (64, 64), (64, 1), offset2)
base2 = torch.randn(
64 * 64 + 64, dtype=torch.float32, device=self.device
)
inp2 = torch.as_strided(base2, (64, 64), (64, 1), offset2)
ref2 = fn(inp2)
res2 = fn_c(inp2)
self.assertEqual(ref2, res2)
Expand All @@ -9853,7 +9855,7 @@ def fail(guard):
def fn(x: torch.Tensor) -> torch.Tensor:
return x.sin() + x.cos()

base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=GPU_TYPE)
base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=self.device)

inp1 = torch.as_strided(base, (32, 32), (32, 1), 4)
inp2 = torch.as_strided(base, (64, 64), (64, 1), 4)
Expand Down Expand Up @@ -9898,9 +9900,11 @@ def fn(x):
((64, 64), (64, 1), 5),
):
torch.manual_seed(42)
base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=GPU_TYPE)
base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=self.device)
torch.manual_seed(42)
base_ref = torch.randn(64 * 64 + 64, dtype=torch.float32, device=GPU_TYPE)
base_ref = torch.randn(
64 * 64 + 64, dtype=torch.float32, device=self.device
)

inp = torch.as_strided(base, size, stride, offset)
inp_ref = torch.as_strided(base_ref, size, stride, offset)
Expand Down

0 comments on commit a7a33c3

Please sign in to comment.