Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
4df01949
Unverified
Commit
4df01949
authored
Nov 01, 2022
by
Ziyue Jiang
Committed by
GitHub
Nov 01, 2022
Browse files
[Pipeline]Adapt to Pipelinable OPT (#1782)
parent
27de2523
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
colossalai/pipeline/utils.py
colossalai/pipeline/utils.py
+5
-2
No files found.
colossalai/pipeline/utils.py
View file @
4df01949
...
@@ -6,6 +6,7 @@ from colossalai.logging import get_dist_logger
...
@@ -6,6 +6,7 @@ from colossalai.logging import get_dist_logger
from
colossalai.nn.layer.utils
import
CheckpointModule
from
colossalai.nn.layer.utils
import
CheckpointModule
from
typing
import
List
from
typing
import
List
from
collections
import
OrderedDict
def
_binary_partition
(
weights
:
List
,
start
:
int
,
end
:
int
):
def
_binary_partition
(
weights
:
List
,
start
:
int
,
end
:
int
):
"""Returns the binary partition position of `weights`, given the start
"""Returns the binary partition position of `weights`, given the start
...
@@ -159,8 +160,10 @@ def build_kwargs_for_module(function, input_tensor, kw_dict):
...
@@ -159,8 +160,10 @@ def build_kwargs_for_module(function, input_tensor, kw_dict):
kwargs_offset
=
0
kwargs_offset
=
0
elif
isinstance
(
input_tensor
,
torch
.
Tensor
):
elif
isinstance
(
input_tensor
,
torch
.
Tensor
):
kwargs_offset
=
1
kwargs_offset
=
1
else
:
elif
isinstance
(
input_tensor
,
(
tuple
,
OrderedDict
)):
assert
isinstance
(
input_tensor
,
tuple
),
f
'input_tensor should be a torch.Tensor or a tuple object.'
#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
)
kwargs_offset
=
len
(
input_tensor
)
args_name_list
=
list
(
sig
.
parameters
.
keys
())
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
:]}
kw_dict
=
{
k
:
v
for
k
,
v
in
kw_dict
.
items
()
if
k
in
args_name_list
[
kwargs_offset
:]}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment