Skip to content

Conversation

@abdulfatir
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@abdulfatir abdulfatir requested a review from shchur December 15, 2025 16:04
if disable_data_parallel:
# This is a hack to disable the default `transformers` behavior of using DataParallel
training_args._n_gpu = 1
assert training_args.n_gpu == 1 # Ensure that the hack worked
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some branches where this is set to 0 (e.g. on the CPU)
https://github.com/huggingface/transformers/blob/40dc11cd3eb4126652aa41ef8272525affd4a636/src/transformers/training_args.py#L1778
Are we sure we don't break it? Should we instead set either

training_args._n_gpu = min(1, training_args._n_gpu)

or

if disable_data_parallel and torch.cuda.device_count() > 1:
    training_args._n_gpu = min(1, training_args._n_gpu)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a guard not use_cpu. Do you think is good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me

if disable_data_parallel:
# This is a hack to disable the default `transformers` behavior of using DataParallel
training_args._n_gpu = 1
assert training_args.n_gpu == 1 # Ensure that the hack worked
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me

@abdulfatir abdulfatir merged commit 71ff0d6 into amazon-science:main Dec 15, 2025
6 checks passed
@abdulfatir abdulfatir deleted the disable-dp branch December 15, 2025 18:27
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.

2 participants