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
FastMoE
Commits
c91dfad8
Commit
c91dfad8
authored
Jan 09, 2021
by
Rick Ho
Browse files
modify performance test
parent
49732231
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
pytorch/cuda/moe_test.py
pytorch/cuda/moe_test.py
+9
-4
No files found.
pytorch/cuda/moe_test.py
View file @
c91dfad8
...
@@ -4,6 +4,9 @@ import time
...
@@ -4,6 +4,9 @@ import time
import
sys
import
sys
dev_name
=
'cuda:0'
def
perf
():
def
perf
():
batch_size
=
int
(
sys
.
argv
[
1
])
batch_size
=
int
(
sys
.
argv
[
1
])
in_feat
=
int
(
sys
.
argv
[
2
])
in_feat
=
int
(
sys
.
argv
[
2
])
...
@@ -11,10 +14,11 @@ def perf():
...
@@ -11,10 +14,11 @@ def perf():
num_expert
=
int
(
sys
.
argv
[
4
])
num_expert
=
int
(
sys
.
argv
[
4
])
inp
=
torch
.
rand
(
batch_size
,
in_feat
).
cuda
(
"cuda:1"
)
inp
=
torch
.
rand
(
batch_size
,
in_feat
).
cuda
(
dev_name
)
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
),
requires_grad
=
False
).
int
().
cuda
(
"cuda:1"
)
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
),
requires_grad
=
False
).
int
().
cuda
(
dev_name
)
moe
=
MOELayer
(
num_expert
,
in_feat
,
out_feat
).
cuda
(
"cuda:1"
)
moe
=
MOELayer
(
num_expert
,
in_feat
,
out_feat
).
cuda
(
dev_name
)
o
=
moe
(
inp
,
gate
)
o
=
moe
(
inp
,
gate
)
o
=
moe
(
inp
,
gate
)
o
=
moe
(
inp
,
gate
)
...
@@ -28,7 +32,8 @@ def perf():
...
@@ -28,7 +32,8 @@ def perf():
maxt
=
0.
maxt
=
0.
sqtot
=
0.
sqtot
=
0.
for
i
in
range
(
n_runs
):
for
i
in
range
(
n_runs
):
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
),
requires_grad
=
False
).
int
().
cuda
(
"cuda:1"
)
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
),
requires_grad
=
False
).
int
().
cuda
(
dev_name
)
ts
=
time
.
time
()
ts
=
time
.
time
()
o
=
moe
(
inp
,
gate
)
o
=
moe
(
inp
,
gate
)
te
=
time
.
time
()
te
=
time
.
time
()
...
...
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