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
b3a03e4b
Unverified
Commit
b3a03e4b
authored
Jun 09, 2022
by
Ziyue Jiang
Committed by
GitHub
Jun 09, 2022
Browse files
[Tensor] fix equal assert (#1091)
* fix equal assert * polish
parent
50ec3a7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
15 deletions
+3
-15
tests/test_tensor/test_model.py
tests/test_tensor/test_model.py
+3
-15
No files found.
tests/test_tensor/test_model.py
View file @
b3a03e4b
...
...
@@ -15,7 +15,7 @@ from colossalai.context import ParallelMode
from
colossalai.core
import
global_context
as
gpc
from
colossalai.nn.optimizer
import
ColoOptimizer
from
functools
import
partial
from
_utils
import
set_seed
from
_utils
import
tensor_equal
,
tensor_shard_equal
,
set_seed
def
init_1d_row_linear
(
weight
):
...
...
@@ -144,20 +144,8 @@ def run_1d_hybrid_tp(model_name):
with
torch
.
no_grad
():
# check param
for
p1
,
p2
in
zip
(
model
.
parameters
(),
model_torch
.
parameters
()):
if
p1
.
size
()
==
p2
.
size
():
assert
torch
.
allclose
(
p1
,
p2
)
else
:
# TODO(jzy) Only check 1D spec. Need to be replaced by new DistSpec.
if
p1
.
size
(
-
1
)
<
p2
.
size
(
-
1
):
# col
world_size
=
p2
.
size
(
-
1
)
//
p1
.
size
(
-
1
)
split_p2
=
torch
.
chunk
(
p2
,
world_size
,
dim
=-
1
)[
0
]
elif
p1
.
size
(
0
)
<
p2
.
size
(
0
):
# row
world_size
=
p2
.
size
(
0
)
//
p1
.
size
(
0
)
split_p2
=
torch
.
chunk
(
p2
,
world_size
,
dim
=
0
)[
0
]
assert
torch
.
allclose
(
p1
,
split_p2
)
for
p
,
torch_p
in
zip
(
model
.
parameters
(),
model_torch
.
parameters
()):
assert
tensor_shard_equal
(
torch_p
,
p
)
if
i
>
5
:
break
...
...
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