KEMBAR78
Stop force realizing to prevent recursion errors unless it's much bigger by Chillee · Pull Request #138881 · pytorch/pytorch · GitHub
Skip to content

Conversation

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 25, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit a1f0c78 with merge base 8fbf866 (image):
💚 Looks good so far! There are no failures yet. 💚

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

def test_inductor_no_recursionerror_on_for_loops(self):
def forward(x):
for _ in range(1000):
for _ in range(10000):
Copy link
Collaborator Author

@Chillee Chillee Oct 25, 2024

Choose a reason for hiding this comment

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

This already wasn't failing without the PR intended to address this. I presume some other thing ameliorated the issue, so I bumped up the threshold to make sure we would hit the recursion error unless we explicitly break it up.


mask_mod = mk_3d_flex_natten_mask(data_size, kernel_size)

torch.compile(create_block_mask)(mask_mod, None, None, S, S)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This compile create_block_mask a side effect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, it's mainly just validating that it runs correctly in Inductor haha


def has_large_inner_fn(self):
return self.inner_fn_opcount().num_ops > config.realize_opcount_threshold
def has_large_inner_fn(self, threshold=None):
Copy link
Collaborator

@Skylion007 Skylion007 Oct 25, 2024

Choose a reason for hiding this comment

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

Suggested change
def has_large_inner_fn(self, threshold=None):
def has_large_inner_fn(self, threshold : Optional[int] = None) -> bool:

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: why not set default of threshold to be 0 in the first place since you need set it to 0 if it's None.

Copy link
Contributor

@shunting314 shunting314 left a comment

Choose a reason for hiding this comment

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

I'm curious if this has broader perf impact since we potentially create larger kernels.


def has_large_inner_fn(self):
return self.inner_fn_opcount().num_ops > config.realize_opcount_threshold
def has_large_inner_fn(self, threshold=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: why not set default of threshold to be 0 in the first place since you need set it to 0 if it's None.

@Chillee
Copy link
Collaborator Author

Chillee commented Oct 25, 2024

@shunting314 I think it's unlikely across our dashboard, since it would require a string of unbroken pointwise ops that's long enough.

pytorchmergebot pushed a commit that referenced this pull request Oct 25, 2024
Fixes #137481

Pull Request resolved: #138787
Approved by: https://github.com/yf225
ghstack dependencies: #138733, #138794, #138881
@github-actions github-actions bot deleted the gh/chillee/372/head branch November 25, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants