mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-15 22:19:38 +00:00
[misc] refactor launch API and tensor constructor (#5666)
* [misc] remove config arg from initialize * [misc] remove old tensor contrusctor * [plugin] add npu support for ddp * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [devops] fix doc test ci * [test] fix test launch * [doc] update launch doc --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ Licensed under the MIT License.
|
||||
"""
|
||||
import torch
|
||||
|
||||
from colossalai.utils import multi_tensor_applier
|
||||
from colossalai.utils import get_current_device, multi_tensor_applier
|
||||
|
||||
|
||||
class FusedAdam(torch.optim.Optimizer):
|
||||
@@ -75,7 +75,7 @@ class FusedAdam(torch.optim.Optimizer):
|
||||
fused_optim = FusedOptimizerLoader().load()
|
||||
|
||||
# Skip buffer
|
||||
self._dummy_overflow_buf = torch.cuda.IntTensor([0])
|
||||
self._dummy_overflow_buf = torch.tensor([0], dtype=torch.int, device=get_current_device())
|
||||
self.multi_tensor_adam = fused_optim.multi_tensor_adam
|
||||
else:
|
||||
raise RuntimeError("FusedAdam requires cuda extensions")
|
||||
|
@@ -3,7 +3,7 @@ from typing import Any, Optional
|
||||
import torch
|
||||
|
||||
from colossalai.kernel.kernel_loader import FusedOptimizerLoader
|
||||
from colossalai.utils import multi_tensor_applier
|
||||
from colossalai.utils import get_current_device, multi_tensor_applier
|
||||
|
||||
from .cpu_adam import CPUAdam
|
||||
|
||||
@@ -87,7 +87,7 @@ class HybridAdam(CPUAdam):
|
||||
if torch.cuda.is_available():
|
||||
fused_optim = FusedOptimizerLoader().load()
|
||||
self.gpu_adam_op = fused_optim.multi_tensor_adam
|
||||
self._dummy_overflow_buf = torch.cuda.IntTensor([0])
|
||||
self._dummy_overflow_buf = torch.tensor([0], dtype=torch.int, device=get_current_device())
|
||||
|
||||
@torch.no_grad()
|
||||
def step(self, closure=None, div_scale: float = -1):
|
||||
|
Reference in New Issue
Block a user