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

Fix the behavior of collecting 'num_input_tokens_seen' #29099

Conversation

YouliangHUANG
Copy link
Contributor

What does this PR do?

The length of "inputs[main_input_name]" is not guaranteed to be the same when using DDP, which may make the training process hang. Besides, in a distributed setup, it costs a lot to gather the WHOLE input tensors on different workers. It is better to call .numel() first and then .gather().

Fixes #28791

The modified code has already passed the relevant test tests/trainer/test_trainer_distributed.py with additional argument 'include_num_input_tokens_seen'.

Who can review?

@pacman100
@muellerzr

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Thanks! Overall this looks good to me, can you rebase from main to ensure that tests pass?

@YouliangHUANG
Copy link
Contributor Author

Just got it rebased from the main. However something still went wrong in the test, and it seems irrevelant to my PR.
Could you help identify?
Much appreciate @muellerzr

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.

LGTM, it's been three weeks the unrelated tests are fixed, sorry to ask you to rebase one more time!

@YouliangHUANG
Copy link
Contributor Author

Done, and it has passed all the tests.
@muellerzr @ArthurZucker

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

@ArthurZucker ArthurZucker merged commit afe73ae into huggingface:main Mar 25, 2024
21 checks passed
@ArthurZucker
Copy link
Collaborator

thanks for this fix

hovnatan pushed a commit to hovnatan/transformers that referenced this pull request Mar 27, 2024
…9099)

fix the behavior of collecting 'num_input_tokens_seen'

See huggingface#28791 for more details.
itazap pushed a commit that referenced this pull request May 14, 2024
fix the behavior of collecting 'num_input_tokens_seen'

See #28791 for more details.
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.

Inappropriate reduce operation of "num_input_tokens_seen" is prone to get training stuck.
4 participants