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] added preprocessor to dataset #28420

Merged
merged 7 commits into from
Sep 11, 2022

Conversation

kouroshHakha
Copy link
Contributor

Signed-off-by: Kourosh Hakhamaneshi [email protected]

Why are these changes needed?

Dataset reader does not apply rllib preprocessors if the observation space is complex.

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 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: Kourosh Hakhamaneshi <[email protected]>
Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

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

a couple of nits.

samples = []
for sample in batch[key]:
samples.append(preprocessor.transform(sample))
batch[key] = np.stack(samples, axis=0)
Copy link
Member

Choose a reason for hiding this comment

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

batch[key] = np.stack([preprocessor.transform(s) for s in batch[key]])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sg.

ret.append(self._postprocess_if_needed(d))
ret = concat_samples(ret)
return ret

def _preprocess_if_needed(self, batch: SampleBatchType) -> SampleBatchType:
# TODO: @kourosh, preprocessor is only supported for single agent case.
Copy link
Member

Choose a reason for hiding this comment

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

seems like I can replace all of these with connectors after it's enabled by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sg, this was not supported properly yet. So let's continue with this solution for now.

count += d.count
d = self._preprocess_if_needed(d)
Copy link
Member

Choose a reason for hiding this comment

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

should we re-arrange these to be:

...
count += d.count
d = self._preprocess_if_needed(d)
d = postprocess_actions(d, self._ioctx.worker)
d = self._postprocess_if_needed(d)
ret.append(d)

so it looks like preprocessing happens before postprocessing??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea.

Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
@kouroshHakha
Copy link
Contributor Author

@gjoliver I addressed all your comments.

Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

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

looks nice. thanks.

@richardliaw richardliaw merged commit de820c6 into ray-project:master Sep 11, 2022
ilee300a pushed a commit to ilee300a/ray that referenced this pull request Sep 12, 2022
justinvyu pushed a commit to justinvyu/ray that referenced this pull request Sep 14, 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.

3 participants