Skip to content
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

[DataLoader2] Ensure finalize and finalize_iteration are called during shutdown/exception #846

Closed
wants to merge 2 commits into from

Conversation

NivekT
Copy link
Contributor

@NivekT NivekT commented Oct 20, 2022

Stack from ghstack:

Fixes #821

  1. Ensure finalize_iteration is called during DataLoader2.shutdown()
  2. If an uncaught exception is raised by DataLoader2Iterator.next(), ensure finalization calls are made

Differential Revision: D40569566

NivekT added a commit that referenced this pull request Oct 20, 2022
…g shutdown/exception

ghstack-source-id: 526069dfff1a3171c44288f8f639639784515e9e
Pull Request resolved: #846
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 20, 2022
@@ -67,6 +67,11 @@ def __next__(self) -> T_co:
if self.dataloader.reading_service is not None:
self.dataloader.reading_service.finalize_iteration()
raise
except Exception:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Is this potentially too broad? Should I limit this to specific exceptions? I wonder if users would want to intentionally catch exceptions that are raised here (such that finalization calls aren't needed).
  2. We can also call DataLoader2.shutdown() here instead.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling dl2.shutdown should be good

@NivekT
Copy link
Contributor Author

NivekT commented Oct 20, 2022

@NivekT has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

…alled during shutdown/exception"


Fixes #821

1. Ensure `finalize_iteration` is called during `DataLoader2.shutdown()`
2. If an uncaught exception is raised by `DataLoader2Iterator.next()`, ensure finalization calls are made

Differential Revision: [D40569566](https://our.internmc.facebook.com/intern/diff/D40569566)

[ghstack-poisoned]
NivekT added a commit that referenced this pull request Oct 21, 2022
…g shutdown/exception

ghstack-source-id: eb65f0a99f8dbc6c4b741b0d5d295ed082a08bdc
Pull Request resolved: #846
@NivekT
Copy link
Contributor Author

NivekT commented Oct 21, 2022

@NivekT has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@NivekT NivekT mentioned this pull request Oct 21, 2022
ejguan pushed a commit to ejguan/data that referenced this pull request Oct 21, 2022
…eption (pytorch#846)

Summary:
Pull Request resolved: pytorch#846

Fixes pytorch#821

1. Ensure `finalize_iteration` is called during `DataLoader2.shutdown()`
2. If an uncaught exception is raised by `DataLoader2Iterator.next()`, ensure finalization calls are made

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D40569566

Pulled By: NivekT

fbshipit-source-id: f0768a62fcc6dfba1aef3a70c8c55563a45304aa
ejguan pushed a commit that referenced this pull request Oct 21, 2022
…eption (#846)

Summary:
Pull Request resolved: #846

Fixes #821

1. Ensure `finalize_iteration` is called during `DataLoader2.shutdown()`
2. If an uncaught exception is raised by `DataLoader2Iterator.next()`, ensure finalization calls are made

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D40569566

Pulled By: NivekT

fbshipit-source-id: f0768a62fcc6dfba1aef3a70c8c55563a45304aa
ejguan pushed a commit to ejguan/data that referenced this pull request Oct 23, 2022
…eption (pytorch#846)

Summary:
Pull Request resolved: pytorch#846

Fixes pytorch#821

1. Ensure `finalize_iteration` is called during `DataLoader2.shutdown()`
2. If an uncaught exception is raised by `DataLoader2Iterator.next()`, ensure finalization calls are made

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D40569566

Pulled By: NivekT

fbshipit-source-id: f0768a62fcc6dfba1aef3a70c8c55563a45304aa
@facebook-github-bot facebook-github-bot deleted the gh/NivekT/99/head branch October 25, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants