class_docstr: Implements Adam algorithm.
  
  Currently GPU-only.  Requires Apex to be installed via
  ``pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./``.
  
  This version of fused Adam implements 2 fusions.
  
    * Fusion of the Adam update's elementwise operations
    * A multi-tensor apply launch that batches the elementwise updates applied to all the model's parameters into one or a few kernel launches.
  
  :class:`apex.optimizers.FusedAdam` may be used as a drop-in replacement for ``torch.optim.AdamW``,
  or ``torch.optim.Adam`` with ``adam_w_mode=False``::
  
      opt = apex.optimizers.FusedAdam(model.parameters(), lr = ....)
      ...
      opt.step()
  
  :class:`apex.optimizers.FusedAdam` may be used with or without Amp.  If you wish to use :class:`FusedAdam` with Amp,
  you may choose any ``opt_level``::
  
      opt = apex.optimizers.FusedAdam(model.parameters(), lr = ....)
      model, opt = amp.initialize(model, opt, opt_level="O0" or "O1 or "O2")
      ...
      opt.step()
  
  In general, ``opt_level="O1"`` is recommended.
  
  
  .. warning::
      A previous version of :class:`FusedAdam` allowed a number of additional arguments to ``step``.  These additional arguments
      are now deprecated and unnecessary.
  
  Adam was been proposed in `Adam: A Method for Stochastic Optimization`_.
  
  Arguments:
      params (iterable): iterable of parameters to optimize or dicts defining
          parameter groups.
      lr (float, optional): learning rate. (default: 1e-3)
      betas (Tuple[float, float], optional): coefficients used for computing
          running averages of gradient and its square. (default: (0.9, 0.999))
      eps (float, optional): term added to the denominator to improve
          numerical stability. (default: 1e-8)
      weight_decay (float, optional): weight decay (L2 penalty) (default: 0)
      amsgrad (boolean, optional): whether to use the AMSGrad variant of this
          algorithm from the paper `On the Convergence of Adam and Beyond`_
          (default: False) NOT SUPPORTED in FusedAdam!
      adam_w_mode (boolean, optional): Apply L2 regularization or weight decay
          True for decoupled weight decay(also known as AdamW) (default: True)
      set_grad_none (bool, optional): whether set grad to None when zero_grad()
          method is called. (default: True)
  
  .. _Adam - A Method for Stochastic Optimization:
      https://arxiv.org/abs/1412.6980
  .. _On the Convergence of Adam and Beyond:
      https://openreview.net/forum?id=ryQu7f-RZ
code: def __init__(
      self,
      params,
      lr=1e-3,
      bias_correction=True,
      betas=(0.9, 0.999),
      eps=1e-8,
      adam_w_mode=True,
      weight_decay=0.0,
      amsgrad=False,
      set_grad_none=True,
  ):
      if amsgrad:
          raise RuntimeError(
              "FusedAdam does not support the AMSGrad variant."
          )
      defaults = dict(
          lr=lr,
          bias_correction=bias_correction,
          betas=betas,
          eps=eps,
          weight_decay=weight_decay,
      )
      super(FusedAdam, self).__init__(params, defaults)
      self.adam_w_mode = 1 if adam_w_mode else 0
      self.set_grad_none = set_grad_none
  
      fused_adam_cuda = FusedAdamBuilder().load()
      # Skip buffer
      self._dummy_overflow_buf = get_accelerator().IntTensor([0])
      self.multi_tensor_adam = fused_adam_cuda.multi_tensor_adam
  
file_path: deepspeed/deepspeed/ops/adam/fused_adam.py
imports: import torch
  from .multi_tensor_apply import MultiTensorApply
  from deepspeed.accelerator import get_accelerator
  from deepspeed.ops.op_builder import FusedAdamBuilder
label_desc: Use image node_id 1 to create a new FusedAdam object from inherited base classes: torch.optim with example: obj = FusedAdam(params, lr, bias_correction, betas, eps, adam_w_mode, weight_decay, amsgrad, set_grad_none)