Skip to content
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

Feature/eval intervals #323

Merged
merged 33 commits into from
Nov 30, 2021
Merged

Feature/eval intervals #323

merged 33 commits into from
Nov 30, 2021

Conversation

KaleabTessera
Copy link
Contributor

@KaleabTessera KaleabTessera commented Oct 18, 2021

What?

  • Added eval interval so that evaluation loops can run at certain intervals.
  • Minor changes for new version of mypy.

Why?

  • To be able to schedule evaluator runs.

How?

  • Added extra condition to environment loop - to check if interval exists.

Extra

  • @DriesSmit @arnupretorius Most of the file changes were mypy changes (for new version of mypy) so you can focus on looking the environment loop code.
  • Also note this is a PR into mava-scaling and not into develop.
  • I ran all test and checks locally and they pass 👍

@DriesSmit DriesSmit assigned DriesSmit and unassigned DriesSmit Oct 21, 2021
Base automatically changed from feature/mava-scaling to develop October 25, 2021 09:43
@DriesSmit DriesSmit added the enhancement New feature or request label Oct 25, 2021
arnupretorius
arnupretorius previously approved these changes Nov 18, 2021
Copy link
Collaborator

@arnupretorius arnupretorius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KaleabTessera! Going to be super useful for comparisons. 🔥

Just left a few minor suggestions.

counts = self._counter.get_counts()
return counts

def record_counts(self, episode_steps: int) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the function return type int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I updated this. It returns a counting.Counter object.

@@ -338,6 +348,36 @@ def _compute_episode_statistics(
) -> None:
pass

def get_counts(self) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to counting.Counter.

@@ -338,6 +348,36 @@ def _compute_episode_statistics(
) -> None:
pass

def get_counts(self) -> Any:
if hasattr(self._executor, "_counts"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this being used anywhere? I.e. executor examples that have this attribute. What is the use case for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is for systems that haven't been moved to mava scaling yet. These systems use _counts .


# We need to get the latest counts if we are using eval intervals.
if environment_loop_schedule:
self._executor.update()
Copy link
Contributor

@DriesSmit DriesSmit Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this update not already performed in the run_episode call? Why are we doing it again here? If we want to force an update (for evironment_loop_schedule == True) we need to change the variable client update rate for the evaluator, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this update is important to get the latest counts.

Since these loops run on different processes, while the evaluator is waiting, it doesn't run the loop and so it vars counts don't get updated (this part doesn't run).

So while the evaluator is waiting, it still need to call self._executor.update() to get latest counts from the executor runs.

Not sure if that makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. That makes sense yes. Should there not maybe be a time.sleep somewhere in here? This is so that the evaluator does not constantly speak to the variable_server while waiting. And also self._executor.update() only updates the executor every 1000 steps right? So we maybe need to change that setting to 1 in the case of using an evaluator that has waiting intervals?

Copy link
Contributor

@DriesSmit DriesSmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KaleabTessera the changes looks great 🚀 Just see my few comments.

@KaleabTessera
Copy link
Contributor Author

From my side this can be merged in. The issues with the github actions/ package versions are resolved in this PR - #310.

from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union

import sonnet as snt
import tensorflow as tf
import trfl


def non_blocking_sleep(time_in_seconds: int) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I like this.

mava/environment_loop.py Outdated Show resolved Hide resolved
mava/environment_loop.py Outdated Show resolved Hide resolved
mava/environment_loop.py Outdated Show resolved Hide resolved
mava/environment_loop.py Outdated Show resolved Hide resolved
mava/environment_loop.py Outdated Show resolved Hide resolved
Copy link
Contributor

@DriesSmit DriesSmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @KaleabTessera 🚀

@KaleabTessera KaleabTessera merged commit 5f51f11 into develop Nov 30, 2021
@KaleabTessera KaleabTessera deleted the feature/eval-intervals branch November 30, 2021 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants