Skip to content

fix(infra): simplify RTensor serialization in data proxy#1067

Merged
nuzant merged 1 commit intomainfrom
fw/fix-rtensor
Mar 23, 2026
Merged

fix(infra): simplify RTensor serialization in data proxy#1067
nuzant merged 1 commit intomainfrom
fw/fix-rtensor

Conversation

@garrett4wade
Copy link
Copy Markdown
Collaborator

Description

Replace dual-path serialize/deserialize logic (shard metadata vs legacy plain lists) with unified serialize_value/deserialize_value from areal.infra.rpc.serialization. RTensor.remotize() is now called directly on the data proxy side before serialization, removing the need for manual shard management in the transport layer. Also adds interaction_id setter to InteractionWithTokenLogpReward for proper ID preservation during deserialization.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

N/A

Additional Context

Files changed:

  • areal/experimental/inference_service/data_proxy/app.py: Move RTensor.remotize() to export endpoint, remove node_addr pass-through
  • areal/experimental/openai/proxy/server.py: Replace manual shard/legacy serialization with serialize_value/deserialize_value
  • areal/experimental/openai/types.py: Add _interaction_id field and setter
  • tests/test_examples.py: Add @pytest.mark.ci to test_openclaw_online_rl

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors and simplifies the RTensor serialization and deserialization process within the data proxy. By adopting a unified serialization utility and moving the RTensor.remotize() call to an earlier stage, it streamlines data handling and removes complex, dual-path logic. Additionally, it enhances the InteractionWithTokenLogpReward class to correctly manage interaction IDs during deserialization, improving data integrity.

Highlights

  • Unified RTensor Serialization: Replaced the dual-path serialization logic (shard metadata vs. legacy plain lists) with a unified serialize_value/deserialize_value approach from areal.infra.rpc.serialization.
  • Direct RTensor Remotization: Modified the data proxy to directly call RTensor.remotize() on interactions before serialization, eliminating the need for manual shard management in the transport layer.
  • Interaction ID Setter: Added an _interaction_id field and a corresponding setter to the InteractionWithTokenLogpReward class to properly preserve interaction IDs during deserialization.
  • Test Annotation: Applied the @pytest.mark.ci decorator to the test_openclaw_online_rl function in tests/test_examples.py.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@garrett4wade garrett4wade changed the title fix(archon): simplify RTensor serialization in data proxy fix(infra): simplify RTensor serialization in data proxy Mar 20, 2026
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. high priority labels Mar 20, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies the RTensor serialization logic by centralizing the remotize call and using a unified serialize_value/deserialize_value mechanism, which is a solid improvement. The changes align well with the description, and the addition of the interaction_id setter is a good fix. I've provided a few suggestions to enhance maintainability and robustness, such as moving local imports, re-introducing a configuration warning, using a more idiomatic dictionary comprehension, and adding a type hint.

Comment thread areal/experimental/inference_service/data_proxy/app.py
Comment thread areal/experimental/inference_service/data_proxy/app.py
Comment thread areal/experimental/openai/proxy/server.py
Comment thread areal/experimental/openai/proxy/server.py
Comment thread areal/experimental/openai/proxy/server.py
Comment thread areal/experimental/openai/types.py
Replace dual-path serialize/deserialize logic (shard metadata vs legacy
plain lists) with unified serialize_value/deserialize_value from
areal.infra.rpc.serialization. RTensor.remotize() is now called directly
on the data proxy side before serialization, removing the need for
manual shard management in the transport layer.

Key changes:
- Move RTensor.remotize() call to data proxy export endpoint
- Replace manual shard/legacy serialization with serialize_value
- Replace manual RTensor reconstruction with deserialize_value
- Add interaction_id setter to InteractionWithTokenLogpReward
- Add @pytest.mark.ci to test_openclaw_online_rl
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Mar 20, 2026
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Mar 21, 2026
Copy link
Copy Markdown
Collaborator

@nuzant nuzant left a comment

Choose a reason for hiding this comment

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

LGTM.

@nuzant nuzant merged commit 9639749 into main Mar 23, 2026
18 of 20 checks passed
@nuzant nuzant deleted the fw/fix-rtensor branch March 23, 2026 03:52
garrett4wade added a commit that referenced this pull request Mar 24, 2026
Replace dual-path serialize/deserialize logic (shard metadata vs legacy
plain lists) with unified serialize_value/deserialize_value from
areal.infra.rpc.serialization. RTensor.remotize() is now called directly
on the data proxy side before serialization, removing the need for
manual shard management in the transport layer.

Key changes:
- Move RTensor.remotize() call to data proxy export endpoint
- Replace manual shard/legacy serialization with serialize_value
- Replace manual RTensor reconstruction with deserialize_value
- Add interaction_id setter to InteractionWithTokenLogpReward
- Add @pytest.mark.ci to test_openclaw_online_rl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high priority safe-to-test Ready to run unit-tests in a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants