Givewait_tensor()
a schema that reflects its side effect
#126773
Labels
oncall: distributed
Add this issue/PR to distributed oncall triage queue
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
wait_tensor
currently has a schema that advertises as functional/pure (it takes in a tensor, returns a fresh tensor) - but this is not really true:(1) it has the side effect of waiting for a pending collective to finish
(2) it returns its input directly : https://github.com/pytorch/pytorch/blob/main/torch/csrc/distributed/c10d/Functional.cpp#L307
One reason this is error prone is that e.g. if you use this API as if it had a side effect (and discard the result, e.g. the bug here), then we will DCE it during tracing (unless we land this PR).
The more proper thing to do would be to: either:
(1) tell functionalization to explicitly not functionalize the op.
(2) update the schema of this op to mark it as mutating its input (to reflect the side effect), and add a functional variant of the op so we can functionalize it, and "de-functionalize" it in inductor (although to be fair, this all amounts to a giant no-op).
cc @mrshenli @pritamdamania87 @zhaojuanmao @satgera @gqchen @aazzolini @osalpekar @jiayisuse @H-Huang @kwen2501 @awgu @penguinwu @fegin @XilunWu @wanchaol @fduwjj @wz337 @tianyu-l @wconstab @yf225 @chauhang @d4l3k
The text was updated successfully, but these errors were encountered: