Skip to content

Commit

Permalink
[Pipeline]Adapt to Pipelinable OPT (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley-Jzy authored Nov 1, 2022
1 parent 27de252 commit 4df0194
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions colossalai/pipeline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from colossalai.nn.layer.utils import CheckpointModule
from typing import List

from collections import OrderedDict

def _binary_partition(weights: List, start: int, end: int):
"""Returns the binary partition position of `weights`, given the start
Expand Down Expand Up @@ -159,8 +160,10 @@ def build_kwargs_for_module(function, input_tensor, kw_dict):
kwargs_offset = 0
elif isinstance(input_tensor, torch.Tensor):
kwargs_offset = 1
else:
assert isinstance(input_tensor, tuple), f'input_tensor should be a torch.Tensor or a tuple object.'
elif isinstance(input_tensor, (tuple, OrderedDict)):
#assert isinstance(input_tensor, tuple), f'input_tensor should be a torch.Tensor or a tuple object.'
# Huggingface will take their own structures based on OrderedDict as the output
# between layers so we've to close this check.
kwargs_offset = len(input_tensor)
args_name_list = list(sig.parameters.keys())
kw_dict = {k: v for k, v in kw_dict.items() if k in args_name_list[kwargs_offset:]}
Expand Down

0 comments on commit 4df0194

Please sign in to comment.