Skip to content

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Jun 30, 2025

Enhance ConnectorV2 ObservationPreprocessor APIs:

  • add multi-agent support
  • add episode arg (so that for example rewards/actions can be added to an observation during preprocessing).

Why are these changes needed?

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…_redo_connector_v2

Signed-off-by: sven1977 <[email protected]>

# Conflicts:
#	rllib/connectors/common/add_states_from_episodes_to_batch.py
#	rllib/connectors/module_to_env/remove_single_ts_time_rank_from_batch.py
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…_redo_connector_v2

Signed-off-by: sven1977 <[email protected]>

# Conflicts:
#	doc/source/rllib/package_ref/index.rst
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 15:14
@sven1977 sven1977 requested a review from a team as a code owner June 30, 2025 15:14
@sven1977 sven1977 requested a review from a team as a code owner June 30, 2025 15:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the ConnectorV2 ObservationPreprocessor APIs to add multi-agent support and introduces an extra episode argument to the preprocess function. Key changes include:

  • Renaming the existing ObservationPreprocessor to SingleAgentObservationPreprocessor and adding a new MultiAgentObservationPreprocessor.
  • Updating the preprocess method signature and call implementations to pass the corresponding episode object.
  • Adjusting several connector components (e.g., numpy_to_tensor, add_time_dim_to_batch_and_zero_pad, add_states_from_episodes_to_batch) to safely handle cases when rl_module is None and updating documentation accordingly.

Reviewed Changes

Copilot reviewed 12 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rllib/connectors/env_to_module/observation_preprocessor.py Renamed and extended preprocessor APIs for single-agent and multi-agent setups.
rllib/connectors/common/numpy_to_tensor.py Removed the as_learner_connector parameter and added a conditional check on rl_module.
rllib/connectors/common/add_time_dim_to_batch_and_zero_pad.py Updated rl_module check to account for None values.
rllib/connectors/common/add_states_from_episodes_to_batch.py Updated rl_module check to account for None values.
doc/source/rllib/*.rst Updated documentation to include connector-v2 and related new APIs.
Comments suppressed due to low confidence (2)

rllib/connectors/env_to_module/observation_preprocessor.py:162

  • Consider implementing a proper 'set_observations' API for multi-agent episodes instead of relying on the single-agent workaround.
            # TODO (sven): Implement set_observations API for multi-agent episodes.

rllib/connectors/common/numpy_to_tensor.py:60

  • The removal of the 'as_learner_connector' parameter may affect users expecting that configuration. Ensure that the associated documentation and any dependent code reflect this change.
        *,

sven1977 added 2 commits June 30, 2025 18:14
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Copy link
Contributor

@simonsays1980 simonsays1980 left a comment

Choose a reason for hiding this comment

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

LGTM.

Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) July 1, 2025 15:16
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jul 1, 2025
@sven1977 sven1977 merged commit 1bffb1f into ray-project:master Jul 1, 2025
6 of 7 checks passed
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…-agent support; add `episode` arg). (#54209)

Signed-off-by: elliot-barn <[email protected]>
@sven1977 sven1977 deleted the enhance_preprocessor_apis branch July 2, 2025 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants