-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add sanity check for inplace copy #285
Conversation
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.
Thanks for putting the effort into writing the check, it's great to have those for a codegen block!
I'm a bit unclear about our expectation from this check function though.
Feels almost like we are hoping that running this check globally would alway ensure that we have a correct function. But I don't think it's sufficient.
A user script could be using an argument after it has been inplace updated (see example below). That's a legit program, our check will reject it. A false negative check is not ideal but I think it's acceptable.
def fn(a, b):
c = a + 1
d = copy_(c, a)
e = b + a
return e
The worse scenario is that, our optimization/transformation could re-order things. For the program above, e = b+a
doesn't depend on anything and we could move it before the inplace copy. Which alters the semantics of the function, but it would appear as legit program in our check.
False positive check and silent wrong result is bad.
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.
BTW, I'm not blocking this PR. It's an improvement to what we have.
yes, I met this problem too
generate the trace:
which is wrong result. |
Not at all, some of the logic is not right, thanks for pointing out @jjsjann123 , I convert it to draft and I'll fix it on Monday :) |
Got'ya. Sounds like our understanding is aligned and that's all that I wanted to confirm. Feel free to ping me when it's ready for another round of review. |
… consumers and check index
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
followed the comments, the modifications are:
@jjsjann123 @IvanYashchuk , could you take a look again |
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.
LGTM. Thanks for updating this!
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.
Thank you @kiya00 @IvanYashchuk @jjsjann123
Before submitting
What does this PR do?
Fixes (#265).
Because it's not safe to use nvfuser's inplace update API. A check is added to ensure that the copy_to argument (and output) of
prims.copy_
is not used as input for any of its subsequent operators in a nvFusion.cc @apaz-cli