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] Issue: Get single step input dict incorrect. #20217

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Nov 10, 2021

Fixes issue #20216

A new unit test has been added to the CI to cover this functionality in the future.

Why are these changes needed?

Related issue number

Checks

Closes #20216

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

@sven1977 sven1977 self-assigned this Nov 10, 2021
@sven1977 sven1977 added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Nov 10, 2021
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.

just 3 simple comments. 1 comment is repeated 5 times :)
thanks.

})
input_dict = batch.get_single_step_input_dict(
view_requirements=view_reqs, index="last")
check(
Copy link
Member

Choose a reason for hiding this comment

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

self.assertEqual?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our check() works on nested structures and also handles np.array vs list comparisons, so it's much more practical.

})
input_dict = batch.get_single_step_input_dict(
view_requirements=view_reqs, index="last")
check(
Copy link
Member

Choose a reason for hiding this comment

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

same here

})
input_dict = batch.get_single_step_input_dict(
view_requirements=view_reqs, index="last")
check(
Copy link
Member

Choose a reason for hiding this comment

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

same here

})
input_dict = batch.get_single_step_input_dict(
view_requirements=view_reqs, index="last")
check(
Copy link
Member

Choose a reason for hiding this comment

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

same here

})
input_dict = batch.get_single_step_input_dict(
view_requirements=view_reqs, index="last")
check(
Copy link
Member

Choose a reason for hiding this comment

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

same here

def get_single_step_input_dict(
self,
view_requirements: ViewRequirementsDict,
index: Union[str, int] = "last",
Copy link
Member

Choose a reason for hiding this comment

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

it seems like index can be a tuple too. maybe update the annotation and doc string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch!

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 took out the Tuple option. Never used and doesn't seem to make any sense here.
We only ever use "last" or -1 (in the MARWIL algo).

Copy link
Member

Choose a reason for hiding this comment

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

👌

data = self[view_col][-1]
traj_len = len(self[data_col])
missing_at_end = traj_len % view_req.batch_repeat_value
obs_shift = -1 if data_col in [
Copy link
Member

Choose a reason for hiding this comment

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

can you help comment what obs_shift means?? I can't quite understand it. thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

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

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.

cool. didn't notice is our own util.

@sven1977 sven1977 merged commit 70fe250 into ray-project:master Nov 12, 2021
@sven1977 sven1977 deleted the issue_get_single_step_input_dict_incorrect branch June 2, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug; RLlib]: Error in SampleBatch.get_single_step_input_dict()
2 participants