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

请教一个问题,使用mp_size=2时的loss应该怎么写 #131

Open
kunden0612 opened this issue Aug 24, 2023 · 1 comment
Open

请教一个问题,使用mp_size=2时的loss应该怎么写 #131

kunden0612 opened this issue Aug 24, 2023 · 1 comment

Comments

@kunden0612
Copy link

kunden0612 commented Aug 24, 2023

logits, *mems = model(inputs_ids, position_ids, attention_mask)
# print(logits.shape)
loss_func = CrossEntropyLoss(ignore_index=-100)
loss = loss_func(logits.view(-1, logits.size(-1)).float(), labels.view(-1))``

我是这样写的loss计算方式,会出现一个/opt/conda/conda-bld/pytorch_1670525539683/work/aten/src/ATen/native/cuda/Loss.cu:242: nll_loss_forward_reduce_cuda_kernel_2d: block: [0,0,0], thread: [15,0,0] Assertion t >= 0 && t < n_classes failed.`` 错误

@kunden0612 kunden0612 changed the title 请假一个问题,使用mp_size=2时的loss应该怎么写 请教一个问题,使用mp_size=2时的loss应该怎么写 Aug 24, 2023
@1049451037
Copy link
Member

1049451037 commented Aug 24, 2023

是不是你forward的时候传了parallel_output=Truehttps://github.com/THUDM/SwissArmyTransformer/blob/main/sat/transformer_defaults.py#L146

导致输出还没有聚合,分散在多个rank里

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

2 participants