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

Simplify running tests in a subprocess #34213

Merged
merged 8 commits into from
Oct 29, 2024
Merged

Simplify running tests in a subprocess #34213

merged 8 commits into from
Oct 29, 2024

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Oct 17, 2024

What does this PR do?

In order to make running (some individual) tests in a subprocess work with GPU (cuda), if we use multiprocessing, we have to use spawn, but this uses pickle and has some limitations that make the necessary changes to the test methods quite big.

This PR tries to use the subprocess module to implement a simpler way to run (some individual) tests in a subprocess.

@ydshieh ydshieh requested a review from ArthurZucker October 17, 2024 09:55
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Looks super complicated, thanks for diving!
Just missing some doc for me 🤗

src/transformers/testing_utils.py Show resolved Hide resolved
@ydshieh ydshieh requested a review from ArthurZucker October 17, 2024 15:49
@ydshieh ydshieh requested a review from ArthurZucker October 22, 2024 13:16
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@ydshieh ydshieh requested review from ArthurZucker and removed request for ArthurZucker October 28, 2024 10:28
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Okay, on my side I don't really see how this can be "hacked" now, sys.executable is supposed to be safe, we could also just put python here no?

@ydshieh
Copy link
Collaborator Author

ydshieh commented Oct 28, 2024

On some docker environment we use, python won't work and we have to use python3. And in other environments, the situation is inversed. That's why I go for sys.executable 👀

@ydshieh ydshieh merged commit 439334c into main Oct 29, 2024
25 of 27 checks passed
@ydshieh ydshieh deleted the run_sub branch October 29, 2024 09:48
2015aroras pushed a commit to 2015aroras/transformers that referenced this pull request Nov 15, 2024
* check

* check

* check

* check

* add docstring

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* check

* check

* check

* check

* add docstring

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
BernardZach pushed a commit to innovationcore/transformers that referenced this pull request Dec 6, 2024
* check

* check

* check

* check

* add docstring

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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.

4 participants
  NODES
COMMUNITY 2
innovation 1
Project 5
USERS 4