Skip to content

DeepSpeedCPUAdam triggers core dump at a specific shape (1024,) using FP16 #1983

Closed

Description

@zzqq2199

Describe the bug

I pass a tensor with shape is (1024,) and dtype is float16 to init DeepSpeedCPUAdam. But when I call step(), the program aborts.

But when the passed tensor's shape is (1024, 1024) or its dtype is float32, the program works perfectly ok.

To Reproduce
Just run the code below:

import torch
from deepspeed.ops.adam import DeepSpeedCPUAdam

N = 1024
device = torch.device("cpu")

tmp = torch.randn(N, device=device).half()
param_bias = torch.nn.Parameter(tmp)
param = [param_bias]
optimizer = DeepSpeedCPUAdam(param)
param_bias.grad = torch.randn(N, device=device).half()
optimizer.step()

ds_report output

--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
      runtime if needed. Op compatibility means that your system
      meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
cpu_adam ............... [YES] ...... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
 [WARNING]  please install triton==1.0.0 if you want to use sparse attention
sparse_attn ............ [NO] ....... [NO]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
async_io ............... [NO] ....... [OKAY]
utils .................. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['xxx]
torch version .................... 1.10.0+cu111
torch cuda version ............... 11.1
torch hip version ................ None
nvcc version ..................... 11.1
deepspeed install path ........... ['xxx']
deepspeed info ................... 0.6.6+3da84185, 3da84185, master
deepspeed wheel compiled w. ...... torch 1.10, cuda 11.1

System info (please complete the following information):

  • OS: Ubuntu 18.04
  • CPU: Intel Xeon E5-2620 v4 @ 16x 3GHz
  • Python version: 3.8

Activity

  1. added
    bug
    on May 27, 2022
  2. zzqq2199 commented on May 27, 2022

    @zzqq2199
    Author

    Output:

    Adam Optimizer #0 is created with AVX2 arithmetic capability.
    Config: alpha=0.001000, betas=(0.900000, 0.999000), weight_decay=0.000000, adam_w=1
    [1]    14637 segmentation fault (core dumped)  python fix_optimizer3.py
    
  3. zzqq2199 commented on May 27, 2022

    @zzqq2199
    Author

    I tested some cases, found that:

    1. When the fp16 tensor is one-dimensional and the length is larger than 16, the core dump exists.
    2. When the fp16 tensor is one-dimensional and length is smaller than 8, or the tensor's dimension size is larger than 1, it works fine.
    3. When the tensor's dtype is fp32, it works fine.
  4. zzqq2199 commented on Jun 20, 2022

    @zzqq2199
    Author

    Anyone? Can this be fixed?

  5. tjruwase commented on Jun 20, 2022

    @tjruwase
    Contributor

    Apologies for the delay. It seems we somehow missed this issue. We will take a look.

  6. RezaYazdaniAminabadi commented on Jun 20, 2022

    @RezaYazdaniAminabadi
    Contributor

    Hi @zzqq2199

    Sorry for the slow reply here.
    Could you please try this PR to see if it fixes the issue?
    Thanks,
    Reza

  7. zzqq2199 commented on Jun 22, 2022

    @zzqq2199
    Author

    @RezaYazdaniAminabadi Thank you very much! After testing, CPU-Adam is now working very well and has been able to train GPT/Bert models using fp16.
    I see from the commit log that you solved the bug very quickly, great code ability!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions