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

Make parallelism optional #311

Merged
merged 7 commits into from
Jun 26, 2020
Merged

Make parallelism optional #311

merged 7 commits into from
Jun 26, 2020

Conversation

n1t0
Copy link
Member

@n1t0 n1t0 commented Jun 19, 2020

Related to #187

An attempt at implementing your first idea @epwalsh. I just didn't manage to have map_with working with maybe_par_bridge but everything else seems to be good!

Let me know what you think! And if you have an idea for the map_with, that'd be awesome, I couldn't make sense of the error...

@epwalsh
Copy link
Collaborator

epwalsh commented Jun 20, 2020

Oof, that error message has me stumped.

I do like this solution though! I hope we can get it working.

#[cfg(target_os = "linux")]
unsafe {
if !REGISTERED_FORK_CALLBACK {
libc::pthread_atfork(None, None, Some(child_after_fork));
Copy link
Collaborator

Choose a reason for hiding this comment

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

💯 💯 🎉 🎉 !!!

Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't know about it either, and it seems to be working really well. This should let us have a very flawless experience. 🎉

n1t0 and others added 2 commits June 23, 2020 11:25
Co-authored-by: Evan Pete Walsh <epwalsh10@gmail.com>
@n1t0
Copy link
Member Author

n1t0 commented Jun 23, 2020

Ok, everything should be good now. map_with now also works when using maybe_par_bridge.

So, the behavior in Python is now the following:

  • When the library is imported for the first time, we register a listener to make sure we catch a potential fork
  • If we detect a fork and TOKENIZERS_PARALLELISM is not set, we disable the parallelism and warn the user
  • If TOKENIZERS_PARALLELISM has been set, we use the provided value

Except for the fork part, everything works the same on any OS/platform. The environement variable can be used to disable parallelism in any situation.

I think we might wait for cuviper/rayon-cond#2 to be merged before we merge this, but this is now ready for review!

@n1t0 n1t0 requested a review from epwalsh June 23, 2020 17:48
@n1t0 n1t0 marked this pull request as ready for review June 23, 2020 17:49
Copy link
Collaborator

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

This is awesome!!

One thing: it seems that the fork callback isn't being called on Mac OS X. But I can confirm it works on Ubuntu 18.04.

@n1t0
Copy link
Member Author

n1t0 commented Jun 23, 2020

Nice catch! I think it should work fine now.

@epwalsh
Copy link
Collaborator

epwalsh commented Jun 23, 2020

I just confirmed it works! 💯

@n1t0
Copy link
Member Author

n1t0 commented Jun 26, 2020

Ok, let's merge this to include it in the upcoming release. We'll see what to do with the git dependency when we'll release the Rust version.

@n1t0 n1t0 merged commit 6d531a4 into master Jun 26, 2020
@n1t0 n1t0 deleted the optional-parallelism branch June 26, 2020 14:55
abhinavkashyap pushed a commit to abhinavkashyap/domadapter that referenced this pull request Sep 21, 2021
- Added TOKENIZERS_PARALLELISM=false in the envrc file. For more
  information you can visit huggingface/tokenizers#311
- orchestration/task_adapter.py - Added model checkpointing callbacks to the trainer. Saves the best
  model depending on the metric being tracked
- models/task_adapter.py - Removed logging loss for every step in the test. It is enough to log
  at the end of test epoch
- scripts/train_task/task-adapter.sh passes the options for number of
  workers to use in the dataloader; the metric to track among others
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants