Repository navigation
[Store] add structured object flat mvp - #2600
Conversation
Add object-level structured transfers for flat mappings and wrapped values, with torch tensor fields using the Store tensor fast path when available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split tensor payload handling from bytes view conversion so the flat structured object path is easier to review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for storing and retrieving PyTorch tensors directly in the structured object store, adding helper methods put_object and get_object along with corresponding serialization and deserialization logic. The review feedback focuses on optimizing the tensor fast path for GPU-enabled stores by avoiding eager CPU and NumPy conversions during encoding. Specifically, it is recommended to redefine _TensorPayload to lazily evaluate the CPU/NumPy array and its size (nbytes), and to raise a clear RuntimeError if a tensor stored via put_tensor cannot be retrieved due to a lack of get_tensor support in the underlying store.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Keep structured torch tensor payloads on the direct Store tensor path without first converting them to CPU NumPy buffers; only materialize bytes for the raw payload fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Raise a direct error when tensor payloads written through put_tensor are read from a store without get_tensor, matching the storage path reviewers need to reason about. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@gemini-code-assist please review again |
There was a problem hiding this comment.
Code Review
This pull request introduces support for PyTorch tensors in the structured object store, adding new put_object and get_object methods to handle mapping objects or single tensors/arrays, along with corresponding encoding and decoding helper functions. The review feedback suggests two key improvements: first, optimizing _read_torch_tensor_member to avoid double copying of tensor data by reading directly into an allocated numpy array buffer; second, using memoryview.cast("B") in _tensor_payload_bytes_view for a more idiomatic and robust way to obtain a 1D bytes view of the tensor.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Read raw tensor fallback payloads directly into writable arrays and use memoryview casts for fallback tensor bytes to avoid unnecessary intermediate copies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@gemini-code-assist please review again |
There was a problem hiding this comment.
Code Review
This pull request adds support for storing and materializing PyTorch tensors in the structured object store, introducing a fast-path optimization when the underlying store supports tensor-specific operations, as well as a raw fallback path. The review feedback highlights critical edge cases concerning 0-dimensional (scalar) and boolean PyTorch tensors, which currently cause runtime errors during serialization and materialization. Actionable suggestions are provided to resolve these issues by flattening and reshaping the arrays before casting, alongside recommendations to expand the test suite to cover these scenarios.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Handle scalar and boolean tensors in the raw tensor fallback path by flattening before byte views, and cover those cases in fast-path and fallback tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
* [Store] add flat structured object tensor support Add object-level structured transfers for flat mappings and wrapped values, with torch tensor fields using the Store tensor fast path when available. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Motivation
PR2050 added a broad DataProto-oriented transfer stack for RL batch exchange. That PR is now being split into smaller, reviewable pieces so reviewers can validate the structured-object foundation before lazy batch, planner, sharding, and DataProto compatibility layers are added.
This PR adds the minimal flat structured-object object API and tensor fast path on top of the existing
structured_object_store.pybundle/manifest infrastructure that has already landed on main.Scenario
This targets the first step of remote structured-object transfer in RL pipelines:
MooncakeBundleTransfer.put_tensor/get_tensorare available.get_object()or the existingread_spec()/materialize()path.Later split PRs will layer nested mappings, TensorDict support, row/list codecs, partial materialization, lazy remote batch, planner, and DataProto compatibility on this foundation.
Description
This PR adds the flat structured-object MVP split from PR2050.
Structured object convenience API
MooncakeBundleTransfer.put_object(obj, ...)valuemember.MooncakeBundleTransfer.get_object(ref)put_object();Torch tensor fast path
_TensorPayloadmarker for structured tensor fields.torch_tensorstructured members with dtype/shape metadata.put_tensor()when available.get_tensor()when materializing tensor payloads.Tests
put_tensor()/get_tensor()hooks.Basic Usage
Architecture
This PR keeps the abstraction generic and framework-neutral.
caller object / flat mapping
│
▼
MooncakeBundleTransfer.put_object()
│
├── numpy fields ─────► structured ndarray payload + dtype/shape metadata
├── torch fields ─────► Mooncake Store put_tensor/get_tensor fast path
└── bytes fields ─────► existing bundle payload path
│
▼
existing structured_object_store bundle manifest
This is intentionally only the first layer from PR2050. It does not introduce DataProto-specific APIs or a parallel manifest format.
Robustness and Safety
Performance
The main performance improvement in this split is avoiding raw byte serialization for torch tensor fields when Store tensor APIs are available:
Planner, lazy selection, range reads, sharding, and DataProto adaptive policy are intentionally left to later split PRs.
How Has This Been Tested?
Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
Checklist
./scripts/code_format.shpre-commit run --all-filesand all hooks passAI Assistance Disclosure
Claude Opus 4.6 assisted with code generation, code review, benchmark analysis, and PR description drafting. All changes were reviewed and validated by me。