-
Notifications
You must be signed in to change notification settings - Fork 9
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
Python pass #120
Open
jcarreira
wants to merge
4
commits into
master
Choose a base branch
from
python_pass
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Python pass #120
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -76,9 +76,9 @@ def __init__(self, | |
self.kill_signal = threading.Event() | ||
self.num_lambdas = 0 | ||
self.cost_model = CostModel( | ||
'm5.large', | ||
ps.instance.type, | ||
self.n_ps, | ||
0, | ||
0, # FIX | ||
self.n_workers, | ||
self.lambda_size) | ||
|
||
|
@@ -96,17 +96,27 @@ def __init__(self, | |
} | ||
|
||
# Stored values | ||
self.last_num_lambdas = 0 | ||
self.last_num_lambdas = 0 # not clear what this is. Need comment or better name | ||
|
||
def get_name(self): | ||
string = "Rate %f" % self.learning_rate | ||
return string | ||
|
||
|
||
def get_cost_per_second(self): | ||
"""Returns cost | ||
|
||
Returns the cost ($) of running this job on the cloud | ||
|
||
""" | ||
return self.time_cps_lst | ||
|
||
def get_num_lambdas(self, fetch=True): | ||
"""Returns number of active lambdas | ||
|
||
Returns the number of active lambdas. | ||
We contact the parameter server to get an accurate value | ||
|
||
""" | ||
if self.is_dead(): | ||
return 0 | ||
if fetch: | ||
|
@@ -118,6 +128,11 @@ def get_num_lambdas(self, fetch=True): | |
return self.last_num_lambdas | ||
|
||
def get_updates_per_second(self, fetch=True): | ||
"""Returns number of updates per second | ||
|
||
Returns the number of sgd updates per second | ||
|
||
""" | ||
if self.is_dead(): | ||
return self.time_ups_lst | ||
if fetch: | ||
|
@@ -135,14 +150,17 @@ def get_updates_per_second(self, fetch=True): | |
|
||
num_lambdas = self.get_num_lambdas() | ||
self.get_updates_per_second() | ||
num_task = 3 | ||
|
||
if num_lambdas == None: | ||
if num_lambdas == None: # not clear when this can happen. It seems to me self.get_num_lambdas() never returns None | ||
return | ||
|
||
|
||
# it doesn't make sense to have this code here | ||
# why are we launching lambdas in a get_update_per_seconds() method? | ||
# isn't that what the wait_then_maintain_workers code does? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yangryan0 Can you please comment? |
||
if num_lambdas < self.n_workers: | ||
shortage = self.n_workers - num_lambdas | ||
|
||
num_task = 3 # we should use constants like CIRRUS_WORKER, CIRRUS_PS, etc.. | ||
payload = '{"num_task": %d, "num_workers": %d, "ps_ip": \"%s\", "ps_port": %d}' \ | ||
% (num_task, self.n_workers, self.ps_ip_private, self.ps_ip_port) | ||
for i in range(shortage): | ||
|
@@ -236,8 +254,7 @@ def kill(self): | |
|
||
|
||
def is_dead(self): | ||
return self.dead | ||
|
||
return self.dead # when does this dead turns True? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
@abstractmethod | ||
def define_config(self, fetch=False): | ||
|
@@ -271,7 +288,7 @@ def get_updates_per_second(self, fetch=True): | |
return self.fetch_metric(self.UPDATES_PER_SECOND) | ||
|
||
def get_time_loss(self, rtl=False): | ||
self.maintain_error() | ||
self.update_loss_metrics() | ||
if rtl: | ||
return self.fetch_metric(self.REAL_TIME_LOSS_VS_TIME) | ||
else: | ||
|
@@ -282,20 +299,20 @@ def fetch_metric(self, key): | |
return self.metrics[key] | ||
|
||
# This will grab the Loss v. Time by communicating with the parameter server | ||
def maintain_error(self): | ||
def update_loss_metrics(self): | ||
if self.is_dead(): | ||
return | ||
|
||
out = messenger.get_last_time_error(self.ps) | ||
if out is None: | ||
return | ||
|
||
|
||
t, loss, real_time_loss, total_loss = out | ||
if t == 0: | ||
return | ||
|
||
if len(self.metrics[self.LOSS_VS_TIME]) == 0 or not ((t, loss) == self.metrics[self.LOSS_VS_TIME][-1]): | ||
if len(self.metrics[self.LOSS_VS_TIME]) == 0 or | ||
not ((t, loss) == self.metrics[self.LOSS_VS_TIME][-1]): | ||
self.metrics[self.LOSS_VS_TIME].append((t, loss)) | ||
|
||
elapsed_time = time.time() - self.start_time | ||
|
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
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
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.
@yangryan0 Can you please check this?
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.
self.get_num_lambdas returns none when there is no response from the parameter server or the connection times out.