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] APPO accelerate vol 02: Various enhancements. #50162

Merged

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Jan 31, 2025

APPO accelerate vol 02: Various enhancements.

  • Remove complex LearnerGroup.update... logic with async-tags and overload of ray.wait requests.
  • Allow Learner actors to have GPUs AND CPUs.

Why are these changes needed?

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) January 31, 2025 14:42
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jan 31, 2025
@sven1977 sven1977 disabled auto-merge January 31, 2025 14:42
@sven1977 sven1977 added rllib RLlib related issues rllib-system system issues, runtime env, oom, etc rllib-newstack labels Jan 31, 2025
Signed-off-by: sven1977 <[email protected]>
Copy link
Collaborator

@simonsays1980 simonsays1980 left a comment

Choose a reason for hiding this comment

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

LGTM. Some minor nits.

# Default is to have a learner thread.
if not hasattr(self, "_learner_thread_in_queue"):
self._learner_thread_in_queue = deque(maxlen=self.config.learner_queue_size)

# Create and start the GPU loader thread(s).
if self.config.num_gpus_per_learner > 0:
self._gpu_loader_threads = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's name the threads for better debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

class _GPULoaderThread(threading.Thread):
def __init__(
self,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the name argument here and pass it to super

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -166,9 +225,8 @@ def step(self):
ma_batch_on_gpu = self._in_queue.sample()
else:
# Queue is empty: Sleep a tiny bit to avoid CPU-thrashing.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually the scheduler makes a good job in providing runtime to each process. This while loop could slow things down and in worst case block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do think we have to sleep here (or at least be careful with removing this logic).

The "queue" here is a deque, which doesn't have the GIL-release logic of a Queue.get(). Looping here with while True: without sleeping would certainly harm performance.

Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 requested review from maxpumperla and a team as code owners February 2, 2025 17:29
@sven1977 sven1977 enabled auto-merge (squash) February 2, 2025 18:59
@sven1977 sven1977 merged commit 8c792db into ray-project:master Feb 2, 2025
6 checks passed
@sven1977 sven1977 deleted the appo_accelerate_02_various_enhancements branch February 2, 2025 19:21
eddyxu pushed a commit to lancedb/ray that referenced this pull request Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests rllib RLlib related issues rllib-newstack rllib-system system issues, runtime env, oom, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants