Skip to content

Conversation

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 17, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/140895

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 85dbca2 with merge base 260d1dc (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
[ghstack-poisoned]
jansel added a commit that referenced this pull request Nov 17, 2024
@jansel jansel added the topic: not user facing topic category label Nov 17, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@jansel jansel marked this pull request as ready for review November 18, 2024 03:35
@jansel jansel requested review from aorenste and ezyang November 18, 2024 03:37
Comment on lines -6592 to -6598
def __getattr__(self, name): # type: ignore[no-untyped-def]
fn = getattr(self.data, name)
if callable(fn):
return fn
raise AttributeError(f"{type(self.data).__name__}.{name} not callable")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezyang @aorenste I believe this function was the main reason typing ir.py was hard. This little trick does save ~100 lines of boilerplate, but once I got rid of this (and a few hasattr -> isinstance changes in this PR) typing the rest of things seem straightforward.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankssss

size = input_node.get_size()
reduction_size = input_node.get_reduction_size()
size = [*input_node.get_size()]
reduction_size = [*input_node.get_reduction_size()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, is this equivalent to list(...)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah curious what the motivation here is for this. It should actually be marginally less efficient than the ctor list method, shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is faster (for small lists) and looks cleaner IMO:

>>> timeit.timeit("list(range(10))")
0.12816928839311004
>>> timeit.timeit("[*range(10)]")
0.11478627705946565
>>> 

list gets mapped to a LOAD_GLOBAL bytecode (since you could do list = tuple in global scope), while [*x] gets mapped to list-specific bytecodes without touching global scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezyang @Skylion007 maybe we should add a rule to automate this change?

continue
op = buffer.get_defining_op()
if op is None:
if op is None or isinstance(op, ExternKernel):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:0

):
def inner(*inputs: List[TensorBox], alpha=None):
if triton_fallback is not None and any(map(is_triton, inputs)):
def inner(*inputs: TensorBox, alpha=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol whoops

if triton_fallback is not None and any(map(is_triton, inputs)):
def inner(*inputs: TensorBox, alpha=None):
if triton_fallback is not None and any(
isinstance(inp, IRNode) and is_triton(inp) for inp in inputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, when is inp not an IRNode?

Copy link
Contributor Author

@jansel jansel Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually it is an int/float/None/etc.

def codegen(self) -> None:
assert isinstance(self.node, ir.ComputedBuffer), f"{type(self.node)=}"
self.node.get_store_function()(self.node.make_loader()())
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:0

Copy link
Contributor Author

@jansel jansel Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was unused code (with incorrect num args to make_loader())

elif isinstance(x, IRNode):
try:
return x.get_device().type
except NoDevice:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:0

raise NoDevice(f"{self.__class__.__name__} does not implement get_device()")

def has_exceeded_max_reads(self) -> bool:
raise NotImplementedError(type(self).__name__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think commit should change this, but would it be better for these to return NotImplemented instead, so that a catch isn't required from call sites? Not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we could also move some more stuff to the base class (and other stuff down to only on subclasses) -- but that would be for another PR.

Comment on lines -6592 to -6598
def __getattr__(self, name): # type: ignore[no-untyped-def]
fn = getattr(self.data, name)
if callable(fn):
return fn
raise AttributeError(f"{type(self.data).__name__}.{name} not callable")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

[ghstack-poisoned]
@jansel jansel added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 18, 2024
@jansel
Copy link
Contributor Author

jansel commented Nov 19, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Nov 19, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@jansel
Copy link
Contributor Author

jansel commented Nov 20, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Nov 21, 2024
This separate the concepts of a Layout (size/stride/etc) and an OutputSpec (which includes multiple outputs).  Which should make typing easier.

Pull Request resolved: #140910
Approved by: https://github.com/ezyang
ghstack dependencies: #140895
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
…ytorch#140895)"

This reverts commit c79e78b.

Reverted pytorch#140895 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I think test_torchbind_inductor is failing in trunk after this lands ([comment](pytorch#140895 (comment)))
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
This separate the concepts of a Layout (size/stride/etc) and an OutputSpec (which includes multiple outputs).  Which should make typing easier.

Pull Request resolved: pytorch#140910
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#140895
@github-actions github-actions bot deleted the gh/jansel/436/head branch December 21, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants