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
f6389d08
Commit
f6389d08
authored
Oct 17, 2022
by
binmakeswell
Committed by
Frank Lee
Oct 19, 2022
Browse files
[NFC] polish tests/test_layers/test_2d/checks_2d/check_operation_2d.py code style (#1715)
parent
e1d78003
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
36 deletions
+9
-36
tests/test_layers/test_2d/checks_2d/check_operation_2d.py
tests/test_layers/test_2d/checks_2d/check_operation_2d.py
+9
-36
No files found.
tests/test_layers/test_2d/checks_2d/check_operation_2d.py
View file @
f6389d08
...
@@ -41,18 +41,8 @@ def check_AB():
...
@@ -41,18 +41,8 @@ def check_AB():
out_shape
=
(
BATCH_SIZE
//
DEPTH
,
SEQ_LENGTH
,
4
*
HIDDEN_SIZE
//
DEPTH
)
out_shape
=
(
BATCH_SIZE
//
DEPTH
,
SEQ_LENGTH
,
4
*
HIDDEN_SIZE
//
DEPTH
)
out
=
Matmul_AB_2D
.
apply
(
out
=
Matmul_AB_2D
.
apply
(
A
,
B
,
DEPTH
,
out_shape
,
i
,
j
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
A
,
B
,
data_parallel_rank
,
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
DEPTH
,
out_shape
,
i
,
j
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
data_parallel_rank
,
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
C_shape
=
(
BATCH_SIZE
,
SEQ_LENGTH
,
4
*
HIDDEN_SIZE
)
C_shape
=
(
BATCH_SIZE
,
SEQ_LENGTH
,
4
*
HIDDEN_SIZE
)
A_master
=
A_master
.
clone
()
A_master
=
A_master
.
clone
()
...
@@ -119,17 +109,9 @@ def check_ABT():
...
@@ -119,17 +109,9 @@ def check_ABT():
B
=
B
.
clone
()
B
=
B
.
clone
()
B
.
requires_grad
=
True
B
.
requires_grad
=
True
out
=
Matmul_ABT_2D
.
apply
(
out
=
Matmul_ABT_2D
.
apply
(
C
,
B
,
DEPTH
,
(
BATCH_SIZE
//
DEPTH
,
SEQ_LENGTH
,
HIDDEN_SIZE
//
DEPTH
),
i
,
j
,
C
,
B
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
data_parallel_rank
,
DEPTH
,
(
BATCH_SIZE
//
DEPTH
,
SEQ_LENGTH
,
HIDDEN_SIZE
//
DEPTH
),
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
i
,
j
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
data_parallel_rank
,
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
A_shape
=
(
BATCH_SIZE
,
SEQ_LENGTH
,
HIDDEN_SIZE
)
A_shape
=
(
BATCH_SIZE
,
SEQ_LENGTH
,
HIDDEN_SIZE
)
C_master
=
C_master
.
clone
()
C_master
=
C_master
.
clone
()
...
@@ -194,17 +176,9 @@ def check_ATB():
...
@@ -194,17 +176,9 @@ def check_ATB():
C
=
C
.
clone
()
C
=
C
.
clone
()
C
.
requires_grad
=
True
C
.
requires_grad
=
True
out
=
Matmul_ATB_2D
.
apply
(
out
=
Matmul_ATB_2D
.
apply
(
A
,
C
,
DEPTH
,
(
HIDDEN_SIZE
//
DEPTH
,
4
*
HIDDEN_SIZE
//
DEPTH
),
i
,
j
,
A
,
C
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
data_parallel_rank
,
DEPTH
,
(
HIDDEN_SIZE
//
DEPTH
,
4
*
HIDDEN_SIZE
//
DEPTH
),
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
i
,
j
,
ParallelMode
.
PARALLEL_2D_ROW
,
ParallelMode
.
PARALLEL_2D_COL
,
data_parallel_rank
,
pipeline_parallel_rank
,
pipeline_parallel_size
,
tensor_parallel_size
)
B_shape
=
(
HIDDEN_SIZE
,
4
*
HIDDEN_SIZE
)
B_shape
=
(
HIDDEN_SIZE
,
4
*
HIDDEN_SIZE
)
A_master
=
A_master
.
clone
()
A_master
=
A_master
.
clone
()
...
@@ -212,8 +186,7 @@ def check_ATB():
...
@@ -212,8 +186,7 @@ def check_ATB():
C_master
=
C_master
.
clone
()
C_master
=
C_master
.
clone
()
C_master
.
requires_grad
=
True
C_master
.
requires_grad
=
True
B_master
=
torch
.
matmul
(
B_master
=
torch
.
matmul
(
A_master
.
view
(
-
1
,
A_master
.
shape
[
-
1
]).
transpose
(
0
,
1
),
A_master
.
view
(
-
1
,
A_master
.
shape
[
-
1
]).
transpose
(
0
,
1
),
C_master
.
view
(
-
1
,
C_master
.
shape
[
-
1
]))
C_master
.
view
(
-
1
,
C_master
.
shape
[
-
1
]))
B
=
torch
.
chunk
(
B_master
,
DEPTH
,
dim
=
0
)[
i
]
B
=
torch
.
chunk
(
B_master
,
DEPTH
,
dim
=
0
)[
i
]
B
=
torch
.
chunk
(
B
,
DEPTH
,
dim
=-
1
)[
j
]
B
=
torch
.
chunk
(
B
,
DEPTH
,
dim
=-
1
)[
j
]
check_equal
(
out
,
B
)
check_equal
(
out
,
B
)
...
...
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