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
4b01da24
Unverified
Commit
4b01da24
authored
Apr 16, 2022
by
Ziyue Jiang
Committed by
GitHub
Apr 16, 2022
Browse files
[TP] change the check assert in split batch 2d (#772)
parent
846406a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
colossalai/nn/layer/parallel_2d/_operation.py
colossalai/nn/layer/parallel_2d/_operation.py
+4
-2
colossalai/nn/layer/parallel_2p5d/_operation.py
colossalai/nn/layer/parallel_2p5d/_operation.py
+4
-2
No files found.
colossalai/nn/layer/parallel_2d/_operation.py
View file @
4b01da24
...
@@ -739,11 +739,13 @@ def split_batch_2d(input_: Tensor, dim: int = 0) -> Tensor:
...
@@ -739,11 +739,13 @@ def split_batch_2d(input_: Tensor, dim: int = 0) -> Tensor:
"""
"""
dim_size
=
input_
.
size
(
dim
)
dim_size
=
input_
.
size
(
dim
)
world_size
=
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2D_COL
)
world_size
=
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2D_COL
)
if
world_size
<=
1
:
return
input_
assert
dim_size
%
world_size
==
0
,
\
assert
dim_size
%
world_size
==
0
,
\
f
'The batch size (
{
dim_size
}
) is not a multiple of 2D size (
{
world_size
}
).'
f
'The batch size (
{
dim_size
}
) is not a multiple of 2D size (
{
world_size
}
).'
if
input_
.
size
(
dim
)
<=
1
:
return
input_
return
torch
.
chunk
(
input_
,
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2D_COL
),
return
torch
.
chunk
(
input_
,
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2D_COL
),
dim
=
dim
)[
gpc
.
get_local_rank
(
ParallelMode
.
PARALLEL_2D_COL
)].
contiguous
()
dim
=
dim
)[
gpc
.
get_local_rank
(
ParallelMode
.
PARALLEL_2D_COL
)].
contiguous
()
...
...
colossalai/nn/layer/parallel_2p5d/_operation.py
View file @
4b01da24
...
@@ -770,11 +770,13 @@ def split_batch_2p5d(input_: Tensor, dim: int = 0) -> Tensor:
...
@@ -770,11 +770,13 @@ def split_batch_2p5d(input_: Tensor, dim: int = 0) -> Tensor:
"""
"""
dim_size
=
input_
.
size
(
dim
)
dim_size
=
input_
.
size
(
dim
)
world_size
=
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2P5D_COL
)
world_size
=
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2P5D_COL
)
if
world_size
<=
1
:
return
input_
assert
dim_size
%
world_size
==
0
,
\
assert
dim_size
%
world_size
==
0
,
\
f
'The batch size (
{
dim_size
}
) is not a multiple of 2.5D size * depth (
{
world_size
}
).'
f
'The batch size (
{
dim_size
}
) is not a multiple of 2.5D size * depth (
{
world_size
}
).'
if
input_
.
size
(
dim
)
<=
1
:
return
input_
return
torch
.
chunk
(
input_
,
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2P5D_COL
),
return
torch
.
chunk
(
input_
,
gpc
.
get_world_size
(
ParallelMode
.
PARALLEL_2P5D_COL
),
dim
=
dim
)[
gpc
.
get_local_rank
(
ParallelMode
.
PARALLEL_2P5D_COL
)].
contiguous
()
dim
=
dim
)[
gpc
.
get_local_rank
(
ParallelMode
.
PARALLEL_2P5D_COL
)].
contiguous
()
...
...
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