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

[RLlib] Issue 21334: Fix APPO when kl_loss is enabled. #21855

Merged
merged 4 commits into from
Jan 27, 2022

Conversation

gjoliver
Copy link
Member

@gjoliver gjoliver commented Jan 25, 2022

Why are these changes needed?

Fix APPO agent when kl_loss is enabled.
value is now saved under different policy id keys. also we need to torch_mean() the stats for the torch policy.

Related issue number

Closes #21334

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • [*] Unit tests
    • Release tests
    • This PR is not tested :(

Bug is with learner_info construction in our LearnerThread.
This only shows up for APPO because APPO, IMPALA, and APEX are the only ones
that use async Learnthread, while APPO is the only agent that updates kl loss.
@sven1977 sven1977 self-assigned this Jan 26, 2022
@@ -47,6 +47,25 @@ def test_appo_compilation(self):
check_compute_single_action(trainer)
trainer.stop()

def test_appo_compilation_use_kl_loss(self):
"""Test whether an APPOTrainer can be built with both frameworks."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Fix the comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops done.

num_iterations = 2

for _ in framework_iterator(config, with_eager_tracing=True):
print("w/ v-trace")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary here, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

right, I got rid of it.

for _ in framework_iterator(config, with_eager_tracing=True):
print("w/ v-trace")
_config = config.copy()
_config["vtrace"] = True
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Member Author

Choose a reason for hiding this comment

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

done


if released:
self.idle_tower_stacks.put(buffer_idx)

self.outqueue.put((get_num_samples_loaded_into_buffer, learner_stats))
self.outqueue.put((get_num_samples_loaded_into_buffer,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

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

Very cool! Thanks for the fix.
Is there an issue related to this PR? Could you change the title to: [RLlib] Issue xyz: ...

@sven1977
Copy link
Contributor

Sorry, saw the issue # now.

@sven1977 sven1977 changed the title Fix APPO when kl_loss is enabled. [RLlib] Issue 21334: Fix APPO when kl_loss is enabled. Jan 26, 2022
@sven1977 sven1977 merged commit 8ebc50f into ray-project:master Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RLlib] [Bug] APPO with kl_loss learner_stats bug
2 participants