-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[rollout] fix: memory release bug #5917
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
base: release/v0.7.1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -239,7 +239,7 @@ def receive_weights(self, on_bucket_received: callable): | |||||||||||||
| # receive bucket and update weights | ||||||||||||||
| while True: | ||||||||||||||
| metadata = self.socket.recv_pyobj() | ||||||||||||||
| weights, tensor = [], None | ||||||||||||||
| weights = [] | ||||||||||||||
| for name, meta in metadata["bucket_meta"].items(): | ||||||||||||||
| shape, dtype, offset = meta["shape"], meta["dtype"], meta["offset"] | ||||||||||||||
| size = dtype.itemsize * shape.numel() | ||||||||||||||
|
|
@@ -255,7 +255,10 @@ def receive_weights(self, on_bucket_received: callable): | |||||||||||||
| get_torch_device().synchronize() | ||||||||||||||
| self.socket.send(b"") | ||||||||||||||
| on_bucket_received(weights) | ||||||||||||||
| del weights, tensor | ||||||||||||||
| for _, tensor in weights: | ||||||||||||||
| del tensor | ||||||||||||||
| weights.clear() | ||||||||||||||
| del weights | ||||||||||||||
|
Comment on lines
+258
to
+261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The loop iterating over
Suggested change
|
||||||||||||||
| if metadata["is_last"]: | ||||||||||||||
| break | ||||||||||||||
| finally: | ||||||||||||||
|
|
||||||||||||||
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.
Initializing
tensortoNoneis recommended to ensure the variable is defined in the function scope. This prevents a potentialNameErrorduring the cleanup phase (line 261) if the bucket metadata is empty and the loop at line 243 never executes.