-
Notifications
You must be signed in to change notification settings - Fork 54
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
FusionDefinition.execute returns output shardings. #3732
base: wjy/execute
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍(Review updated until commit d7dc6cd)Here are some key observations to aid the review process:
|
@@ -71,11 +75,24 @@ void bindDeviceMesh(py::module& nvfuser) { | |||
py::arg("device_id")); | |||
} | |||
|
|||
void bindDistributedTensor(py::module& nvfuser) { | |||
py::class_<DistributedTensor> distributed_tensor( | |||
nvfuser, "_DistributedTensor"); |
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.
Docs are omitted because the class name starts with an underscore, indicating it's hidden from the user. nvfuser.DistributedTensor
, defined in __init__.py
, has docs though.
!test |
!test |
!test |
@@ -344,7 +347,7 @@ void FusionDefinition::print(std::ostream& os) const { | |||
os << std::endl; | |||
} | |||
|
|||
std::vector<at::Tensor> FusionDefinition::execute( | |||
std::vector<DistributedTensor> FusionDefinition::execute( |
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.
Alternatives:
- Return
std::vector<std::variant<at::Tensor, DistributedTensor>>
. BecauseDistributedTensor
can also represent a non-distributed tensor, I chose the current API for simplicity -- C++ is more verbose than Python when dealing with dynamic types. - Return
std::variant<std::vector<at::Tensor>, std::vector<DistributedTensor>>
. Same reason. - Store output shardings (i.e. the mesh and the mesh-to-tenseor-axis mapping) to a field of FusionDefinition and retrieve it using another method. This would be similar to getDebugOutput. I didn't choose that because it introduced a new state in the class that could get out of sync.
This is done by adding a
nvfuser.DistributedTensor
that inherits fromtorch.Tensor
and wraps a mesh and a mesh-axis-to-tensor-axis mapping.