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

RFC: Add snapshot to MultiProcessingReadingService #1039

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jhoareau
Copy link

@jhoareau jhoareau commented Feb 22, 2023

  • Added communication methods for state pickling in worker processes
    • The worker datapipes are briefly paused for the state to be gathered
    • The state is then gathered by the QueueWrapper datapipes then _IterateQueueDataPipes
    • We only gather the state of worker processes and not of prefetch processes in this first iteration
  • Added tests for the feature

Fixes #1033

@NivekT @ejguan

@facebook-github-bot
Copy link
Contributor

Hi @jhoareau!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@NivekT
Copy link
Contributor

NivekT commented Feb 23, 2023

Hi @jhoareau,

Thanks for opening the issue and the PR. I have read both of them. Some thoughts (please correct me if I'm wrong):

  1. Getting the serialized state of each worker's DataPipe is probably more info that you need
    • Based on your description, it sounds like you only want the length before sharding, and not other serialized state data
    • While I have a few open PRs related to checkpoint, there is a reason why we have not provided that feature yet. That is because it gets very complicated in order to work for every single DataPipe implementation, especially since we plan to allow state restoration.
      • For example shuffle currently doesn't store the state of its buffer during serialization. We do not want to make a public API that returns an incomplete state of the DataPipes, at least not yet.
    • This __len__ PR ([DataLoader] Add __len__ to DataLoader2 #728) might be more relevant but we haven't prioritized that
  2. As things stand, sharding_round_robin_dispatch is probably what you want since you aren't sharding until you have fully tokenized. Therefore, I don't think you will be benefiting from having multiple workers tokenizing the same data anyway?
    • Based on your description, each worker should return the same length value as well? Unless there is randomness in your transformation that I'm not aware of.
    • Let me know if there is something I missed here.
  3. Another ideally solution is the have the DataLoader2 __len__ feature fully implemented, then you can use that in combination with inserting dp.custom_set_length() (which will be a custom DataIpe) after sharding to ensure that you get the desired from each worker.

@jhoareau
Copy link
Author

@NivekT Thanks for your reply. I'll focus on 1 here:
Ultimately, if I understand correctly, full state checkpointing will be necessary in some shape or form with all reading services. Right now, we are able to access the state of the datapipe when on the main process, but not in the MPRS - if we reduce the problem purely to state accessing, there's a "gap" in the current feature set.

I understand that the state as defined now is not satisfactory to you yet in terms of resuming capabilities, but technically right now the DataLoader2 does have a state_dict/from_state public API that allows us to snapshot and resume from this partial state, just not with the MPRS. I don't think this PR is introducing any extra "partiality" to the snapshotting, but do feel free to correct me on that :D

Would you accept this PR under any shape, for example if I convert the methods to protected, making this a non-public API for now? Or do you consider that the reading service is not mature enough for it yet?

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

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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.

Accessing DataPipe state with MultiProcessingReadingService
3 participants