Conversation
wschin
reviewed
Aug 24, 2022
orttraining/orttraining/python/training/ortmodule/_custom_autograd_function_exporter.py
Show resolved
Hide resolved
…pengwa/segfault
wschin
approved these changes
Aug 30, 2022
Contributor
Author
|
Thanks @wschin @baijumeswani. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: fix segment fault for alltoall.
In MOE model tests, there are random issues reporting segment fault.
The problem is AllToAll autograd function is consuming a process group object in its forward function. when the segmentfault happens, the process group param accepted in the forward function is a 'str' like "ONNX:Slice114" or some wired object pointer.
The root cause is: during PythonOp export, we save the process group (as a non tensor pointer type) object's address only, and save it in PythonOp's attribute. But python did not know there is a reference to that object. In the new env MOE test is trying to onboard, it looks there is more possibility process group is destroyed before the tests completed. If it is teared down before PythonOp/PythonOpGrad completed, an unexpected object (e.g. the str or werid object) is picked up and used as process group type, segement fault occurs.
The fix: the process group as inputs of all PythonOp, they should exist along the training lifetime. So we can track those non-tensor object reference once we are exporting PythonOp. Keeping those object in a global store will avoid that object be released. We will clean up the store before python program exits. For multiple UT cases, cleaning up is not triggered, but it should be fine.
Motivation and Context