-
Notifications
You must be signed in to change notification settings - Fork 480
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
Sharing tensor storage (with DLPack) results in unexpected behavior. #7304
Comments
Hi, @vanbasten23, is that ok to assign this ticket to you? |
Thanks for reporting the issue. I did some investigation. I think there is a typo in your repro:
After we do Second, regarding
It means t1 is output of the XLA graph and t0 is the input. So if you modify t1 as |
I'm pretty sure it's not for the following reasons:
I believe it should. The one that guarantees mutation is propagated through aliasing relations is the functionalization layer. In other words, even though they don't actually share memory, the functionalization layer knows that whenever an in-place operation takes place, it should update the base tensor (eagerly) and the other views (lazyly). |
🐛 Bug
Consider the following tensors:
t0
: an XLA tensort1
: a slice oft0
t2
: a CUDA tensor that shares storage witht0
Then, consider the following sequence of in-place operations:
Due to #7198, we already expect that the effects of the in-place operation (II) is not going to be propagated back to the CUDA tensor
t2
. However, sincet1
is a view oft0
, I would expect (II) to use the values updated by (I). However, (II) clearly uses the value oft0
before (I), unexpectedly resulting int0[1, 0] == 6
.This problem happens because of how the functional layer applies updates to the base tensor of a view. Even though the functional implementation does try to synchronize (i.e. regenerating the view from base), the regeneration doesn't happen because the functional wrapper of
t0
doesn't know it has changed.Expected behavior
Given #7198, I think a reasonable result would be:
i.e. run the in-place operation with the updated base values.
Environment
cc @miladm @JackCaoG @vanbasten23 @bdhirsh @lezcano
The text was updated successfully, but these errors were encountered: