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
fairscale
Commits
86c62cc9
Unverified
Commit
86c62cc9
authored
Oct 26, 2021
by
Eugen Hotaj
Committed by
GitHub
Oct 26, 2021
Browse files
Use correct node names for param counting in auto_shard. (#830)
Fixes #827. Co-authored-by:
Eugen Hotaj
<
ehotaj@fb.com
>
parent
eadfdc49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
fairscale/experimental/nn/auto_shard.py
fairscale/experimental/nn/auto_shard.py
+1
-2
tests/experimental/nn/test_auto_shard.py
tests/experimental/nn/test_auto_shard.py
+1
-3
No files found.
fairscale/experimental/nn/auto_shard.py
View file @
86c62cc9
...
...
@@ -52,8 +52,7 @@ def _split_nodes(traced_graph_module: torch.fx.GraphModule, shard_count: int = 3
# Find the total number of params in the model and
# the number of params per shard we are aiming for.
for
name
,
module
in
traced_graph_module
.
named_modules
():
if
"."
in
name
:
continue
name
=
name
.
replace
(
"."
,
"_"
)
param_count
[
name
]
=
sum
([
x
.
numel
()
for
x
in
module
.
parameters
()])
logging
.
info
(
f
"Total number of params are
{
param_count
[
''
]
}
"
)
per_shard_param
=
param_count
[
""
]
//
shard_count
...
...
tests/experimental/nn/test_auto_shard.py
View file @
86c62cc9
...
...
@@ -140,9 +140,7 @@ def test_dynaimc_conditionals_auto_wrapped():
model
=
BranchedNetwork
(
features
)
sharded_model
=
shard_model
(
model
,
3
)
# TODO(ehotaj): There might be a bug in our split code because we shard the
# model into 10 shards even though we specify 3 shards above.
assert
len
(
sharded_model
)
==
10
assert
len
(
sharded_model
)
==
3
input_
=
torch
.
randn
(
3
,
features
)
model_output
=
model
(
input_
)
...
...
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