Skip to content

update seed_worker to set seed based on worker_id and rank #37980

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

Merged
merged 8 commits into from
May 12, 2025

Conversation

gathierry
Copy link
Contributor

@gathierry gathierry commented May 6, 2025

What does this PR do?

Fixes #37932

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@github-actions github-actions bot marked this pull request as draft May 6, 2025 16:07
Copy link
Contributor

github-actions bot commented May 6, 2025

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@gathierry gathierry marked this pull request as ready for review May 6, 2025 16:07
@Rocketknight1
Copy link
Member

cc @SunMarc

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks ! Can you add a test ?

@gathierry
Copy link
Contributor Author

Test added

@gathierry
Copy link
Contributor Author

Hi @SunMarc, there are still 2 workflows pending, is it expected? Any additional actions needed on my side?
thanks

@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.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks, looks good, just a final nit

Comment on lines +73 to +75
training_args.max_steps = 10
# dataloader_num_workers must be > 0 to enable worker_init_fn
training_args.dataloader_num_workers = 2
Copy link
Member

Choose a reason for hiding this comment

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

minor nit, please set the output_dir to self.get_auto_remove_tmp_dir() so that we don't store the results

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I put it in test_trainer as args

Copy link
Member

Choose a reason for hiding this comment

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

thx ! merging

@SunMarc SunMarc enabled auto-merge (squash) May 12, 2025 15:46
@SunMarc SunMarc merged commit a63cb75 into huggingface:main May 12, 2025
20 checks passed
@gathierry gathierry deleted the shiyu/seed_depend_on_rank branch May 12, 2025 23:55
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
…ce#37980)

* update seed_worker to set seed based on worker_id and rank

* test case

* set output_dir as remove tmp dir
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.

Different DataLoader worker share the same seed and lost randomness
4 participants