Skip to content

[BUG] Setting average_tokens_across_devices to True caused an error because it attempted to gather CPU tensors using NCCL. #38035

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

Open
Jintao-Huang opened this issue May 9, 2025 · 3 comments

Comments

@Jintao-Huang
Copy link
Contributor

if num_items_in_batch is not None:
if self.args.average_tokens_across_devices:
num_items_in_batch = self.accelerator.gather(num_items_in_batch).sum()
if torch.is_tensor(num_items_in_batch):
num_items_in_batch = num_items_in_batch.to(device)
if self.args.n_gpu > 1 and num_items_in_batch.dim() == 0:
# In the DataParallel case, convert the scalar tensor into a 1-dim tensor
num_items_in_batch = num_items_in_batch.unsqueeze(0)

@Jintao-Huang
Copy link
Contributor Author

Image

@Jintao-Huang Jintao-Huang changed the title Setting average_tokens_across_devices to True caused an error because it attempted to gather CPU tensors using NCCL. [BUG] Setting average_tokens_across_devices to True caused an error because it attempted to gather CPU tensors using NCCL. May 9, 2025
@Rocketknight1
Copy link
Member

cc @SunMarc

@SunMarc
Copy link
Member

SunMarc commented May 12, 2025

Hey @Jintao-Huang, can you share a reproducer ? The num_items_in_batch should be on cuda normally

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

No branches or pull requests

3 participants