-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[inductor] support dilation in max_pool2d lowering #148209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/148209
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 4a15f7a with merge base 5d4b5ee ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - might be nice to add a few tests across forward/backward, and with low_mem_decomposition and without
@@ -4485,12 +4507,6 @@ def offsets_to_indices(idx): | |||
return indices | |||
|
|||
|
|||
fallback_max_pool2d_with_indices = fallback_handler( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
torch/_inductor/lowering.py
Outdated
@@ -4386,7 +4405,10 @@ def _max_pool2d_with_offsets( | |||
def fn_inner(idx, reduction_idx): | |||
prefix = idx[:-dim] | |||
bh = idx[-dim:] | |||
ih = [bh[i] * stride[i] + reduction_idx[i] - padding[i] for i in range(dim)] | |||
ih = [ | |||
bh[i] * stride[i] + reduction_idx[i] * dilation[i] - padding[i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - paranethesize to make it easier to parse ?
torch/_inductor/lowering.py
Outdated
ih = hbase + h_inc | ||
iw = wbase + w_inc | ||
ih = hbase + h_inc * ops.index_expr(dilation[0], torch.int64) | ||
iw = wbase + w_inc * ops.index_expr(dilation[1], torch.int64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're downstream of max_pool2d signature which has dilation as int
instead of symint
, dilation
should always be an int instead of potentially a symint.. but i guess its better to write it more generally..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this it fails with
Traceback (most recent call last):
File "/home/isuruf/git/pytorch/torch/testing/_internal/common_utils.py", line 3146, in wrapper
method(*args, **kwargs)
File "/home/isuruf/git/pytorch/test/inductor/test_torchinductor.py", line 12840, in new_test
return value(self)
File "/home/isuruf/git/pytorch/test/inductor/test_torchinductor.py", line 893, in wrapper
return fn(self)
File "/home/isuruf/git/pytorch/test/inductor/test_torchinductor.py", line 4682, in test_adaptive_max_pool2d1
self.common(
File "/home/isuruf/.conda/envs/pytorch-dev39/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/isuruf/git/pytorch/test/inductor/test_torchinductor.py", line 625, in check_model_gpu
check_model(
File "/home/isuruf/git/pytorch/test/inductor/test_torchinductor.py", line 466, in check_model
actual = run(*example_inputs, **kwargs)
File "/home/isuruf/git/pytorch/torch/_dynamo/eval_frame.py", line 665, in _fn
raise e.remove_dynamo_frames() from None # see TORCHDYNAMO_VERBOSE=1
File "/home/isuruf/git/pytorch/torch/_inductor/compile_fx.py", line 763, in _compile_fx_inner
raise InductorError(e, currentframe()).with_traceback(
File "/home/isuruf/git/pytorch/torch/_inductor/compile_fx.py", line 748, in _compile_fx_inner
mb_compiled_graph = fx_codegen_and_compile(
File "/home/isuruf/git/pytorch/torch/_inductor/compile_fx.py", line 1454, in fx_codegen_and_compile
return scheme.codegen_and_compile(gm, example_inputs, inputs_to_check, graph_kwargs)
File "/home/isuruf/git/pytorch/torch/_inductor/compile_fx.py", line 1174, in codegen_and_compile
compiled_fn = graph.compile_to_module().call
File "/home/isuruf/git/pytorch/torch/_inductor/graph.py", line 2084, in compile_to_module
return self._compile_to_module()
File "/home/isuruf/git/pytorch/torch/_inductor/graph.py", line 2092, in _compile_to_module
self.codegen_with_cpp_wrapper() if self.cpp_wrapper else self.codegen()
File "/home/isuruf/git/pytorch/torch/_inductor/graph.py", line 1999, in codegen
self._update_scheduler()
File "/home/isuruf/git/pytorch/torch/_inductor/graph.py", line 1993, in _update_scheduler
self.scheduler = Scheduler(self.operations)
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 1952, in __init__
self._init(nodes)
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 1971, in _init
self.nodes = [self.create_scheduler_node(n) for n in nodes]
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 1971, in <listcomp>
self.nodes = [self.create_scheduler_node(n) for n in nodes]
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 2110, in create_scheduler_node
return SchedulerNode(self, node)
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 987, in __init__
self._compute_attrs()
File "/home/isuruf/git/pytorch/torch/_inductor/scheduler.py", line 995, in _compute_attrs
self._sizes, self._body = self.node.simplify_and_reorder(
File "/home/isuruf/git/pytorch/torch/_inductor/ir.py", line 4131, in simplify_and_reorder
) = self.get_default_sizes_body()
File "<string>", line 6, in get_default_sizes_body_cache_on_self
File "/home/isuruf/git/pytorch/torch/_inductor/ir.py", line 4084, in get_default_sizes_body
body = LoopBody(
File "/home/isuruf/git/pytorch/torch/_inductor/loop_body.py", line 117, in __init__
self._init_with_tracing(fn, args)
File "/home/isuruf/git/pytorch/torch/_inductor/loop_body.py", line 131, in _init_with_tracing
self.root_block = LoopBodyBlock(self, fn, args) # traces
File "/home/isuruf/git/pytorch/torch/_inductor/loop_body.py", line 463, in __init__
ops.output(fn(*args))
File "/home/isuruf/git/pytorch/torch/_inductor/ir.py", line 932, in store_output
return ops.store(output_name or "unnamed", indexer(vars), loader(vars))
File "/home/isuruf/git/pytorch/torch/_inductor/lowering.py", line 4499, in offsets_to_indices
return increments_to_index(h_inc, w_inc, bh, bw)
File "/home/isuruf/git/pytorch/torch/_inductor/lowering.py", line 4489, in increments_to_index
ih = hbase + h_inc * dilation[0]
File "/home/isuruf/git/pytorch/torch/_inductor/virtualized.py", line 221, in __mul__
return ops.mul(self, other)
File "<string>", line 296, in mul
File "/home/isuruf/git/pytorch/torch/_inductor/virtualized.py", line 286, in _default
return OpsWrapper._wrap(getattr(_ops, name)(*new_args, **new_kwargs))
File "<string>", line 296, in mul
File "/home/isuruf/git/pytorch/torch/_inductor/index_propagation.py", line 303, in _default
return self.propagate_sympy(name, args, kwargs)
File "/home/isuruf/git/pytorch/torch/_inductor/index_propagation.py", line 281, in propagate_sympy
new_expr = getattr(SymPyOps, name)(*new_args, **new_kwargs)
File "/home/isuruf/git/pytorch/torch/_inductor/index_propagation.py", line 120, in mul
result_type = torch.promote_types(x.dtype, y.dtype)
torch._inductor.exc.InductorError: AttributeError: 'int' object has no attribute 'dtype'
Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
To execute this test, run the following from the base repo dir:
python test/inductor/test_torchinductor.py GPUTests.test_adaptive_max_pool2d1_cuda
This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you would want ops.constant
[ghstack-poisoned]
[ghstack-poisoned]
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 2 jobs have failed, first few of them are: trunk / macos-py3-arm64-mps / test (mps, 1, 1, macos-m1-13), trunk / macos-py3-arm64-mps / test (mps, 1, 1, macos-m1-14) Details for Dev Infra teamRaised by workflow job |
[ghstack-poisoned]
[ghstack-poisoned]
@@ -34,6 +34,7 @@ | |||
# This tests basic MPS compile functionality | |||
|
|||
|
|||
@instantiate_parametrized_tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @malfet
@pytorchbot rebase |
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
Successfully rebased |
@pytorchbot merge -f "unrelated cudnn failure" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Pull Request resolved: pytorch#148209 Approved by: https://github.com/eellison
Stack from ghstack (oldest at bottom):
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov