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] Fix IMPALA/APPO old API stack queueing stats. #44446

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions rllib/algorithms/impala/impala.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,16 +984,17 @@ def place_processed_samples_on_learner_thread_queue(self) -> None:
NOTE: This method is called if self.config._enable_new_api_stack is False.

"""
while self.batches_to_place_on_learner:
batch = self.batches_to_place_on_learner[0]
for i, batch in enumerate(self.batches_to_place_on_learner):
try:
# Setting block = True prevents the learner thread,
# the main thread, and the gpu loader threads from
# thrashing when there are more samples than the
# learner can reasonable process.
# see https://github.com/ray-project/ray/pull/26581#issuecomment-1187877674 # noqa
self._learner_thread.inqueue.put(batch, block=True)
self.batches_to_place_on_learner.pop(0)
self._learner_thread.inqueue.put(
batch,
# Setting block = True for the very last item in our list prevents
# the learner thread, this main thread, and the GPU loader threads
# from thrashing when there are more samples than the learner can
# reasonably process.
# see https://github.com/ray-project/ray/pull/26581#issuecomment-1187877674 # noqa
block=i == len(self.batches_to_place_on_learner) - 1
)
self._counters["num_samples_added_to_queue"] += (
batch.agent_steps()
if self.config.count_steps_by == "agent_steps"
Expand All @@ -1002,6 +1003,8 @@ def place_processed_samples_on_learner_thread_queue(self) -> None:
except queue.Full:
self._counters["num_times_learner_queue_full"] += 1

self.batches_to_place_on_learner.clear()

def process_trained_results(self) -> ResultDict:
"""Process training results that are outputed by the learner thread.

Expand Down
Loading