-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Experimental] Add experimental distributed SGD API #2858
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
46dabe1
check in sgd api
ericl ec2c21b
idx
ericl aab1d5a
foreach_worker foreach_model
ericl bc1ce2a
add feed_dict
ericl 503f6c2
Merge remote-tracking branch 'upstream/master' into sgd
ericl 9167d3b
Merge remote-tracking branch 'upstream/master' into sgd
ericl 6a0a068
update
ericl 4242886
yapf
ericl ffafb6a
typo
ericl 4525ff0
lint
ericl 5a6c913
plasma op change
ericl 63e4580
fix plasma op
ericl 2ca7c85
still not working
ericl f37af90
fix
ericl 11672b0
fix
ericl 8da7c9a
comments
ericl 8e226a1
yapf
ericl 8c64bde
silly flake8
ericl b840c3f
small test
ericl 4b50f5a
Merge remote-tracking branch 'upstream/master' into sgd
ericl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import ray | ||
import json | ||
import time | ||
|
||
|
||
class Timeline(object): | ||
def __init__(self, tid): | ||
self.events = [] | ||
self.offset = 0 | ||
self.start_time = self.time() | ||
self.tid = tid | ||
|
||
def patch_ray(self): | ||
orig_log = ray.worker.log | ||
|
||
def custom_log(event_type, kind, *args, **kwargs): | ||
orig_log(event_type, kind, *args, **kwargs) | ||
if kind == ray.worker.LOG_SPAN_START: | ||
self.start(event_type) | ||
elif kind == ray.worker.LOG_SPAN_END: | ||
self.end(event_type) | ||
elif kind == ray.worker.LOG_SPAN_POINT: | ||
self.event(event_type) | ||
|
||
ray.worker.log = custom_log | ||
|
||
def time(self): | ||
return time.time() + self.offset | ||
|
||
def reset(self): | ||
self.events = [] | ||
self.start_time = self.time() | ||
|
||
def start(self, name): | ||
self.events.append((self.tid, "B", name, self.time())) | ||
|
||
def end(self, name): | ||
self.events.append((self.tid, "E", name, self.time())) | ||
|
||
def event(self, name): | ||
now = self.time() | ||
self.events.append((self.tid, "B", name, now)) | ||
self.events.append((self.tid, "E", name, now + .0001)) | ||
|
||
def merge(self, other): | ||
if other.start_time < self.start_time: | ||
self.start_time = other.start_time | ||
self.events.extend(other.events) | ||
self.events.sort(key=lambda e: e[3]) | ||
|
||
def chrome_trace_format(self, filename): | ||
out = [] | ||
for tid, ph, name, t in self.events: | ||
ts = int((t - self.start_time) * 1000000) | ||
out.append({ | ||
"name": name, | ||
"tid": tid, | ||
"pid": tid, | ||
"ph": ph, | ||
"ts": ts, | ||
}) | ||
with open(filename, "w") as f: | ||
f.write(json.dumps(out)) | ||
print("Wrote chrome timeline to", filename) | ||
|
||
|
||
if __name__ == "__main__": | ||
a = Timeline(1) | ||
b = Timeline(2) | ||
a.start("hi") | ||
time.sleep(.1) | ||
b.start("bye") | ||
a.start("hi3") | ||
time.sleep(.1) | ||
a.end("hi3") | ||
b.end("bye") | ||
time.sleep(.1) | ||
a.end("hi") | ||
b.start("b1") | ||
b.end("b1") | ||
a.merge(b) | ||
a.chrome_trace_format("test.json") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and
run_timeline
fromsgd.py