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
a762d33c
Commit
a762d33c
authored
Dec 14, 2022
by
Rick Ho
Browse files
capacity numerical fix
parent
6cb550fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
fmoe/gates/gshard_gate.py
fmoe/gates/gshard_gate.py
+2
-1
No files found.
fmoe/gates/gshard_gate.py
View file @
a762d33c
...
@@ -34,7 +34,8 @@ class GShardGate(NaiveGate):
...
@@ -34,7 +34,8 @@ class GShardGate(NaiveGate):
self
.
set_loss
(
loss
)
self
.
set_loss
(
loss
)
cap_rate
=
self
.
capacity
[
0
if
self
.
training
else
1
]
cap_rate
=
self
.
capacity
[
0
if
self
.
training
else
1
]
capacity
=
math
.
ceil
(
cap_rate
*
x
.
shape
[
0
])
//
self
.
world_size
capacity
=
math
.
ceil
(
cap_rate
*
x
.
shape
[
0
])
capacity
=
capacity
*
self
.
top_k
//
(
self
.
world_size
*
self
.
num_expert
)
capacity
=
torch
.
ones
(
self
.
num_expert
*
self
.
world_size
,
capacity
=
torch
.
ones
(
self
.
num_expert
*
self
.
world_size
,
dtype
=
torch
.
int32
,
device
=
topk_idx
.
device
)
*
capacity
dtype
=
torch
.
int32
,
device
=
topk_idx
.
device
)
*
capacity
topk_idx
=
fmoe_native
.
prune_gate_by_capacity
(
topk_idx
,
capacity
,
topk_idx
=
fmoe_native
.
prune_gate_by_capacity
(
topk_idx
,
capacity
,
...
...
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