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] Reduce SampleBatch counting complexity #30936

Conversation

ArturNiederfahrenhorst
Copy link
Contributor

@ArturNiederfahrenhorst ArturNiederfahrenhorst commented Dec 7, 2022

Signed-off-by: Artur Niederfahrenhorst artur@anyscale.com

Why are these changes needed?

SampleBatch counting has a aspects that slow us down in connection with the QMix connectors regression.
Since we spend lots of time there instantiating new sample batches, we count alot.

  • We count on every field
  • We compare the results of these attempts to count (to catch SampleBatches with different counts)
  • We create a new dict just to skip SampleBatch.SEQ_LENS for counting

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 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: Artur Niederfahrenhorst <artur@anyscale.com>
@ArturNiederfahrenhorst ArturNiederfahrenhorst changed the title [RLlib] Don't modify SampleBatch in place when counting [RLlib] Reduce SampleBatch counting attemp complexity Jan 16, 2023
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
@ArturNiederfahrenhorst ArturNiederfahrenhorst changed the title [RLlib] Reduce SampleBatch counting attemp complexity [RLlib] Reduce SampleBatch counting complexity Jan 17, 2023
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
# has same length.
if isinstance(v, (Number, list)):
self[k] = np.array(v)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was previously part of our counting code. Moving it does not yield a performance improvement but we should still move it.

Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
Copy link
Contributor

@kouroshHakha kouroshHakha left a comment

Choose a reason for hiding this comment

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

LGTM

@gjoliver gjoliver merged commit 42ad3d5 into ray-project:master Jan 18, 2023
andreapiso pushed a commit to andreapiso/ray that referenced this pull request Jan 22, 2023
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
Signed-off-by: Andrea Pisoni <andreapiso@gmail.com>
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.

4 participants