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

Remove unnecessary fp32/bf16 conversion #1169

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: remove unnecessary bf16 conversions since no collective op is p…
…erformed
  • Loading branch information
DayOfThePenguin committed Mar 3, 2024
commit 6abad8b2fea886e30bf34258a813a6bc50e16afa
9 changes: 0 additions & 9 deletions megatron/mpu/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,13 @@ def _split(input_):
if world_size == 1:
return input_

# Bf16 convert
dt = input_.dtype
if dt == torch.bfloat16 and get_fp32_allreduce():
input_ = input_.float()

# Split along last dimension.
input_list = split_tensor_along_last_dim(input_, world_size)

# Note: torch.split does not create contiguous tensors by default.
rank = get_model_parallel_rank()
output = input_list[rank].contiguous()

# Bf16 convert
if dt == torch.bfloat16 and get_fp32_allreduce():
output = output.bfloat16()

return output


Expand Down
Loading