Skip to content

Simplify running tests in a subprocess - #34213

Merged
ydshieh merged 8 commits into
mainfrom
run_sub
Oct 29, 2024
Merged

ydshieh merged 8 commits into
mainfrom
run_sub

Conversation

@ydshieh

@ydshieh ydshieh commented Oct 17, 2024 •

Copy link
Copy Markdown
Collaborator

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

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

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 🤗

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

Copy link
Copy Markdown

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

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

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

ydshieh commented Oct 28, 2024 •

Copy link
Copy Markdown
Collaborator Author

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
@ydshieh
ydshieh deleted the run_sub branch October 29, 2024 09:48
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>
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