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] POC: Run RLlib w/o Preprocessors setup. #17656

Closed

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Aug 7, 2021

This PR was motivated in preparation for soon allowing individual observation components to be addressed by the trajectory view API, for example to enable frame-stacking for individual observation components within a complex observation space (Tuple|Dict). Also, soon soft-deprecating RLlib's Preprocessor API should increase transparency for the users and allow batched, model-based preprocessing of observations. Observations will arrive in the model exactly as they are returned by the env.

This PR is a POC that works for tf and torch.

  • New config setting for preprocessor_pref: None; Set to None for disabling Preprocessors altogether (not even use NoPreprocessor class anymore).
  • A new example script was added (also to BUILD) to show the new setting in action with both tf and torch's ComplexInputModel (which already exists and handles complex, unflattened inputs).
  • Most changes were necessary within the SimpleListCollector (SampleCollector) class allowing for arbitrarily nested data to be collected from the env and stored/retrieved.
  • Works in unison with the recent SampleBatch enhancement ([RLlib] SampleBatch: Docstring- and API cleanups; Add support for nested data. #17485) for allowing nested data within a SampleBatch.

Why are these changes needed?

Related issue number

Checks

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

…ecate_preprocessors_soft

# Conflicts:
#	rllib/evaluation/collectors/simple_list_collector.py
…ecate_preprocessors_soft

# Conflicts:
#	rllib/evaluation/collectors/simple_list_collector.py
@@ -402,7 +402,7 @@ def add_batch(self, batch: SampleBatchType) -> None:
# If SampleBatch has prio-replay weights, average
# over these to use as a weight for the entire
# sequence.
if "weights" in time_slice:
if "weights" in time_slice and time_slice["weights"]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoid np.mean over empty list (yields: NaN).

@sven1977 sven1977 added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Aug 28, 2021
@@ -416,6 +416,8 @@ def postprocess_nstep_and_prio(policy: Policy,
batch[SampleBatch.REWARDS], batch[SampleBatch.NEXT_OBS],
batch[SampleBatch.DONES])

# Create dummy prio-weights (1.0) in case we don't have any in
Copy link
Contributor

Choose a reason for hiding this comment

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

Prob should be in diff PR

# env's action space before sending actions back to the env.
# (0.0 centered with small stddev; only affecting Box components).
# We will unsquash actions (and clip, just in case) to the bounds of
# the env's action space before sending actions back to the env.
"normalize_actions": True,
# If True, RLlib will clip actions according to the env's bounds
# before sending them back to the env.
# TODO: (sven) This option should be obsoleted and always be False.
"clip_actions": False,
# Whether to use "rllib" or "deepmind" preprocessors by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe describe what rllib or deepmind does in the comment.

self.buffers[SampleBatch.AGENT_INDEX][0].append(agent_index)
self.buffers[SampleBatch.ENV_ID][0].append(env_id)
self.buffers[SampleBatch.T][0].append(t)
self.buffers[SampleBatch.EPS_ID][0].append(self.episode_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

If self.episode_id and unroll_id is constant, why repeat adding the same data?

if SampleBatch.EPS_ID in values:
assert values[SampleBatch.EPS_ID] == self.episode_id
del values[SampleBatch.EPS_ID]
self.buffers[SampleBatch.EPS_ID][0].append(self.episode_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue above

shape=shape,
name=".".join([str(p) for p in path]),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do?

@sven1977 sven1977 closed this Sep 5, 2021
@sven1977 sven1977 deleted the deprecate_preprocessors_soft branch June 2, 2023 20:15
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.

2 participants