Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
decentralizepy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SaCS
decentralizepy
Commits
327519cc
Commit
327519cc
authored
3 years ago
by
Rishi Sharma
Browse files
Options
Downloads
Patches
Plain Diff
Debug TCP
parent
892cf251
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/decentralizepy/sharing/GrowingAlpha.py
+4
-19
4 additions, 19 deletions
src/decentralizepy/sharing/GrowingAlpha.py
src/decentralizepy/sharing/PartialModel.py
+8
-0
8 additions, 0 deletions
src/decentralizepy/sharing/PartialModel.py
with
12 additions
and
19 deletions
src/decentralizepy/sharing/GrowingAlpha.py
+
4
−
19
View file @
327519cc
import
logging
from
decentralizepy.sharing.PartialModel
import
PartialModel
from
decentralizepy.sharing.Sharing
import
Sharing
class
GrowingAlpha
(
PartialModel
):
...
...
@@ -18,9 +17,9 @@ class GrowingAlpha(PartialModel):
init_alpha
=
0.0
,
max_alpha
=
1.0
,
k
=
10
,
metadata_cap
=
0.6
,
dict_ordered
=
True
,
save_shared
=
False
,
metadata_cap
=
1.0
,
):
super
().
__init__
(
rank
,
...
...
@@ -34,34 +33,20 @@ class GrowingAlpha(PartialModel):
init_alpha
,
dict_ordered
,
save_shared
,
metadata_cap
,
)
self
.
init_alpha
=
init_alpha
self
.
max_alpha
=
max_alpha
self
.
k
=
k
self
.
metadata_cap
=
metadata_cap
self
.
base
=
None
def
step
(
self
):
if
(
self
.
communication_round
+
1
)
%
self
.
k
==
0
:
self
.
alpha
+=
(
self
.
max_alpha
-
self
.
init_alpha
)
/
self
.
k
self
.
alpha
=
min
(
self
.
alpha
,
1.00
)
if
self
.
alpha
==
0.0
:
logging
.
info
(
"
Not sending/receiving data (alpha=0.0)
"
)
self
.
communication_round
+=
1
return
if
self
.
alpha
>
self
.
metadata_cap
:
if
self
.
base
==
None
:
self
.
base
=
Sharing
(
self
.
rank
,
self
.
machine_id
,
self
.
communication
,
self
.
mapping
,
self
.
graph
,
self
.
model
,
self
.
dataset
,
)
self
.
base
.
communication_round
=
self
.
communication_round
self
.
base
.
step
()
else
:
super
().
step
()
super
().
step
()
This diff is collapsed.
Click to expand it.
src/decentralizepy/sharing/PartialModel.py
+
8
−
0
View file @
327519cc
...
...
@@ -22,6 +22,7 @@ class PartialModel(Sharing):
alpha
=
1.0
,
dict_ordered
=
True
,
save_shared
=
False
,
metadata_cap
=
1.0
,
):
"""
Constructor
...
...
@@ -51,6 +52,7 @@ class PartialModel(Sharing):
self
.
alpha
=
alpha
self
.
dict_ordered
=
dict_ordered
self
.
save_shared
=
save_shared
self
.
metadata_cap
=
metadata_cap
# Only save for 2 procs
if
rank
==
0
or
rank
==
1
:
...
...
@@ -78,6 +80,9 @@ class PartialModel(Sharing):
)
def
serialized_model
(
self
):
if
self
.
alpha
>
self
.
metadata_cap
:
# Share fully
return
super
().
serialized_model
()
with
torch
.
no_grad
():
_
,
G_topk
=
self
.
extract_top_gradients
()
...
...
@@ -129,6 +134,9 @@ class PartialModel(Sharing):
return
m
def
deserialized_model
(
self
,
m
):
if
self
.
alpha
>
self
.
metadata_cap
:
# Share fully
return
super
().
deserialized_model
(
m
)
with
torch
.
no_grad
():
state_dict
=
self
.
model
.
state_dict
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment