Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Jeffrey_Wigger_Master_Project
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
Model registry
Operate
Environments
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
Semester-Projects
spring22
Jeffrey_Wigger_Master_Project
Commits
7575bd98
Commit
7575bd98
authored
3 years ago
by
Rishi Sharma
Browse files
Options
Downloads
Patches
Plain Diff
Separate files shared_params
parent
3c3007a0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
eval/ip_addr_4Machines.json
+6
-0
6 additions, 0 deletions
eval/ip_addr_4Machines.json
eval/ip_addr_5Machines.json
+7
-0
7 additions, 0 deletions
eval/ip_addr_5Machines.json
src/decentralizepy/sharing/PartialModel.py
+15
-16
15 additions, 16 deletions
src/decentralizepy/sharing/PartialModel.py
with
28 additions
and
16 deletions
eval/ip_addr_4Machines.json
0 → 100644
+
6
−
0
View file @
7575bd98
{
"0"
:
"10.90.41.130"
,
"1"
:
"10.90.41.131"
,
"2"
:
"10.90.41.132"
,
"3"
:
"10.90.41.133"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
eval/ip_addr_5Machines.json
0 → 100644
+
7
−
0
View file @
7575bd98
{
"0"
:
"10.90.41.129"
,
"1"
:
"10.90.41.130"
,
"2"
:
"10.90.41.131"
,
"3"
:
"10.90.41.132"
,
"4"
:
"10.90.41.133"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/decentralizepy/sharing/PartialModel.py
+
15
−
16
View file @
7575bd98
import
json
import
logging
import
os
from
pathlib
import
Path
import
numpy
import
torch
...
...
@@ -28,6 +29,10 @@ class PartialModel(Sharing):
self
.
alpha
=
alpha
self
.
dict_ordered
=
dict_ordered
self
.
communication_round
=
0
self
.
folder_path
=
os
.
path
.
join
(
self
.
log_dir
,
"
shared_params/{}
"
.
format
(
self
.
rank
)
)
Path
(
self
.
folder_path
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
def
extract_top_gradients
(
self
):
logging
.
info
(
"
Summing up gradients
"
)
...
...
@@ -48,26 +53,20 @@ class PartialModel(Sharing):
with
torch
.
no_grad
():
_
,
G_topk
=
self
.
extract_top_gradients
()
if
self
.
communication_round
:
with
open
(
os
.
path
.
join
(
self
.
log_dir
,
"
{}_shared_params.json
"
.
format
(
self
.
rank
)
),
"
r
"
,
)
as
inf
:
shared_params
=
json
.
load
(
inf
)
else
:
shared_params
=
dict
()
shared_params
[
"
order
"
]
=
list
(
self
.
model
.
state_dict
().
keys
())
shapes
=
dict
()
for
k
,
v
in
self
.
model
.
state_dict
().
items
():
shapes
[
k
]
=
list
(
v
.
shape
)
shared_params
[
"
shapes
"
]
=
shapes
shared_params
=
dict
()
shared_params
[
"
order
"
]
=
list
(
self
.
model
.
state_dict
().
keys
())
shapes
=
dict
()
for
k
,
v
in
self
.
model
.
state_dict
().
items
():
shapes
[
k
]
=
list
(
v
.
shape
)
shared_params
[
"
shapes
"
]
=
shapes
shared_params
[
self
.
communication_round
]
=
G_topk
.
tolist
()
with
open
(
os
.
path
.
join
(
self
.
log_dir
,
"
{}_shared_params.json
"
.
format
(
self
.
rank
)),
os
.
path
.
join
(
self
.
folder_path
,
"
{}_shared_params.json
"
.
format
(
self
.
communication_round
+
1
),
),
"
w
"
,
)
as
of
:
json
.
dump
(
shared_params
,
of
)
...
...
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