Skip to content

Fix worker_init_fn to update DataPipe graph and move worker prefetch to the end of Worker pipeline#1100

Closed
ejguan wants to merge 4 commits intometa-pytorch:mainfrom
ejguan:fix_worker_init_fn
Closed

Fix worker_init_fn to update DataPipe graph and move worker prefetch to the end of Worker pipeline#1100
ejguan wants to merge 4 commits intometa-pytorch:mainfrom
ejguan:fix_worker_init_fn

Conversation

@ejguan
Copy link
Contributor

@ejguan ejguan commented Mar 20, 2023

Fixes #1083

Changes

  • Fix worker loop to update the DataPipe graph with worker_init_fn
    • Add corresponding Tests
  • Since worker_init_fn function might attach new DataPipe to worker graph, guarantee prefetch in worker attached to the end of the pipeline in worker process

@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 Mar 20, 2023
@facebook-github-bot
Copy link
Contributor

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

@ejguan ejguan requested a review from NivekT March 20, 2023 16:56
@ejguan ejguan added the topic: bug fixes topic category label Mar 20, 2023
Copy link
Contributor

@NivekT NivekT left a comment

Choose a reason for hiding this comment

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

LGTM! Small comments:

Comment on lines +100 to +101
if worker_prefetch_cnt > 0:
datapipe = datapipe.prefetch(worker_prefetch_cnt)
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, this is still applied whether or not the DataPipe is replicable but now it is after transformation done by the init function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for non-replicable DataPipe, there won't be this step anyway because it won't be sent to worker process.

@NivekT NivekT added this to the 0.6.1 milestone Mar 20, 2023
@ejguan ejguan force-pushed the fix_worker_init_fn branch from 052781f to 2ec8282 Compare March 20, 2023 19:34
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@ejguan merged this pull request in e78ab6c.

NivekT pushed a commit that referenced this pull request Apr 19, 2023
…h to the end of Worker pipeline (#1100)

Summary:
Fixes #1083

### Changes

- Fix worker loop to update the DataPipe graph with `worker_init_fn`
  - Add corresponding Tests
- Since `worker_init_fn` function might attach new DataPipe to worker graph, guarantee `prefetch` in worker attached to the end of the pipeline in worker process

Pull Request resolved: #1100

Reviewed By: NivekT

Differential Revision: D44221216

Pulled By: ejguan

fbshipit-source-id: dfcbaa3e8a0d82df6dd21d308cc94f6d06bcf8f4
ejguan added a commit that referenced this pull request Apr 20, 2023
…h to the end of Worker pipeline (#1100)

Summary:
Fixes #1083

### Changes

- Fix worker loop to update the DataPipe graph with `worker_init_fn`
  - Add corresponding Tests
- Since `worker_init_fn` function might attach new DataPipe to worker graph, guarantee `prefetch` in worker attached to the end of the pipeline in worker process

Pull Request resolved: #1100

Reviewed By: NivekT

Differential Revision: D44221216

Pulled By: ejguan

fbshipit-source-id: dfcbaa3e8a0d82df6dd21d308cc94f6d06bcf8f4
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. Merged topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return value of worker_init_fn is ignored by MPRS

3 participants