Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

fp16 support #4

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Changes from all commits
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
14 changes: 8 additions & 6 deletions energon/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ def __init__(self,
# self._save_parameter()
self._load_parameter()

if self._dtype:
self._dtype_convert()



def _init_dist(self):
launch_from_torch(tp_size = self._tp_size, pp_size = self._pp_size)
Expand All @@ -63,7 +59,13 @@ def _set_sample_device(self):
self._samples[k] = v.cuda()

def _init_model(self):
model = self._model_class(**self._model_config).cuda()
"""
TODO(dujiangsu) support other dtype
"""
if self._dtype == torch.half:
model = self._model_class(**self._model_config).cuda().half()
else:
model = self._model_class(**self._model_config).cuda()
model.eval()
self._model = PipelineCommWrapper(model = model, sample = self._samples, dtype=self._dtype)

Expand Down Expand Up @@ -96,7 +98,7 @@ def _get_ranks_name(self):
ranks_name = f'tp{tp_local_rank}-pp{pp_local_rank}'
return ranks_name

def _dtype_convert(self):
def dtype_convert(self):
"""
TODO(dujiangsu) support other dtype
"""
Expand Down