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 SampleBatch to_device() #27572

Merged
merged 13 commits into from
Aug 8, 2022

Conversation

kouroshHakha
Copy link
Contributor

@kouroshHakha kouroshHakha commented Aug 5, 2022

Why are these changes needed?

Related issue number

closes #26593

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 :(

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 minor questions.
looks cleeeaaaan!

# Floatify all float64 tensors.
if tensor.dtype == torch.double:
if tensor.is_floating_point():
Copy link
Member

Choose a reason for hiding this comment

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

any chance this is a new api? if yes, maybe make sure it works with the version we pin for core.

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 point. I checked quickly and it's even there on torch=1.8.0 Where do we specify the torch pinned version in ray?
https://pytorch.org/docs/1.8.0/search.html?q=IS_FLOATING_POINT&check_keywords=yes&area=default

# Numpy arrays.
if isinstance(item, np.ndarray):
Copy link
Member

Choose a reason for hiding this comment

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

what were we doing before ... didn't we check these conditions before we get in here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the else is added because I moved a bit of logic to clean the code. e.g torch.is_tensor() is brought down after dealing with RepeatedValues type.

"f": RepeatedValues(np.array([[1, 2, 0, 0]]), lengths=[2], max_len=4),
SampleBatch.SEQ_LENS: np.array([2, 3, 1]),
"state_in_0": np.array([1.0, 3.0, 4.0]),
SampleBatch.INFOS: np.array([{"a": 1}, {"b": 2}, {"c": 3}]),
Copy link
Member

Choose a reason for hiding this comment

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

INFOS's dtype is object right? and we basically don't do anything to it if I understand correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. correct.

@sven1977 sven1977 merged commit 3b2a842 into ray-project:master Aug 8, 2022
scottsun94 pushed a commit to scottsun94/ray that referenced this pull request Aug 9, 2022
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 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] If disable preprocessor api True with GPU then get numpy array instead of Tensor
3 participants