-
Notifications
You must be signed in to change notification settings - Fork 713
Fix placeholder lifetime bug in memory planning #6971
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6971
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 7c8271e with merge base a347665 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
5abeae6 to
8bb10bb
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Differential Revision: D66184849
8bb10bb to
bb3f155
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Reviewed By: JacobSzwejbka
Differential Revision: D66184849
bb3f155 to
b9ad5a6
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Reviewed By: JacobSzwejbka
Differential Revision: D66184849
b9ad5a6 to
a7c7528
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Reviewed By: JacobSzwejbka
Differential Revision: D66184849
a7c7528 to
9aa41fe
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Reviewed By: JacobSzwejbka
Differential Revision: D66184849
9aa41fe to
7c8271e
Compare
|
This pull request was exported from Phabricator. Differential Revision: D66184849 |
Differential Revision: D66184849