Skip to content

collecting latest step as a stat #5264

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

Merged
merged 19 commits into from
Apr 19, 2021
Merged

Conversation

maryamhonari
Copy link
Contributor

@maryamhonari maryamhonari commented Apr 15, 2021

Proposed change(s)

  • Reporting the latest step as a separate stat.
  • A new property in TensorboardWriter to hide irrelevant stats based on their key

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@maryamhonari maryamhonari requested a review from ervteng April 15, 2021 01:04
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


mahon94 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -209,6 +209,7 @@ def _increment_step(self, n_steps: int, name_behavior_id: str) -> None:
p = self.get_policy(name_behavior_id)
if p:
p.increment_step(n_steps)
self.stats_reporter.set_stat("Step", float(self.get_step))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ervteng Is there a place that I can collect more granular/frequent step updates?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the right place if we care about synchronizing with the other metrics.

The other place would be in the AgentProcessor, but that is a bit decoupled from the other metrics as it would be added pre-trajectory assembly.

Copy link
Contributor

Choose a reason for hiding this comment

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

At some point (e.g. if the inference and training are separate processes) it might be useful to emit both as different stats (e.g. steps_executed and steps_processed)

@maryamhonari maryamhonari requested a review from sini April 15, 2021 21:57
Copy link
Contributor

@ervteng ervteng left a comment

Choose a reason for hiding this comment

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

Minor comments on typing but otherwise LGTM

@@ -31,6 +31,7 @@ def get_default_stats_writers(run_options: RunOptions) -> List[StatsWriter]:
TensorboardWriter(
checkpoint_settings.write_path,
clear_past_data=not checkpoint_settings.resume,
hidden_keys=["Is Training", "Step"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of the magic strings here. I think these would be better as a static frozenset() in TensorBoardWriter.
Any thoughts?

Copy link
Contributor

@sini sini Apr 17, 2021

Choose a reason for hiding this comment

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

I encouraged @mahon94 to remove it as a magic string from the TensorboardWriter. My thinking is that the writer has no responsibility for the implementation of the trainer or its stats and as such configuration/behavior should be removed from the details of said implementation. The get_default_stats_writers in stats_writer.py plugin on the otherhand is more closely related to the main entry-point/execution of the trainer. et

If it wasn't mutable, I'd say this should just be the default value of TensorboardWriter param and call it a day. Transforming it from a list to a frozenset resolves the mutability issue -- even if it's still a collection of magic strings in the writer. Do you have opinions on the coupling implications?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion. I am okay leaving it as is.

@maryamhonari maryamhonari merged commit e695fc1 into main Apr 19, 2021
@delete-merged-branch delete-merged-branch bot deleted the develop-report-step-in-trainer branch April 19, 2021 18:21
maryamhonari added a commit that referenced this pull request Apr 19, 2021
* collecting latest step as a stat

* adding a list of hidden_keys to TB summarywriter to hide unnecessary stats from user

* fixing precommit

* fixing precommit

* formating

* defined the property types

* moving custom defaults to get_default_stats_writers

* new test for TensorboardWriter.hidden_keys

* improved testing

* explicit None evaluation

Co-authored-by: Ervin T. <[email protected]>

* make hidden_keys optional

Co-authored-by: Ervin T. <[email protected]>

* adding optional argument

* lowering the training threshold to 0.8 on test_var_len_obs_and_goal_poca

* Update pytest.yml

* Do not merge! droping pytest 3.9 job

* -add back pytest
-format imports and comments

* back to default threshold for test_var_len_obs_and_goal_poca

Co-authored-by: mahon94 <[email protected]>
Co-authored-by: Ervin T. <[email protected]>
maryamhonari added a commit that referenced this pull request Apr 20, 2021
* collecting latest step as a stat

* adding a list of hidden_keys to TB summarywriter to hide unnecessary stats from user

* fixing precommit

* formating

* defined the property types

* moving custom defaults to get_default_stats_writers

* new test for TensorboardWriter.hidden_keys

* improved testing

* explicit None evaluation

Co-authored-by: Ervin T. <[email protected]>

* make hidden_keys optional

Co-authored-by: Ervin T. <[email protected]>

* adding optional argument

* lowering the training threshold to 0.8 on test_var_len_obs_and_goal_poca

* Update pytest.yml

* Do not merge! droping pytest 3.9 job

* -add back pytest
-format imports and comments

* back to default threshold for test_var_len_obs_and_goal_poca

Co-authored-by: mahon94 <[email protected]>
Co-authored-by: Ervin T. <[email protected]>

Co-authored-by: mahon94 <[email protected]>
Co-authored-by: Ervin T. <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants