Repository navigation
[Store] add TP chunk metadata put APIs - #1908
zxpdemonio wants to merge 7 commits into
Conversation
Add TP chunk put APIs and metadata serialization in the Python store bindings, with scoped tests and API docs for the PR1 split. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Run clang-format on the TP chunk metadata store bindings after the PR1 split commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validate split_dim, clean up partial batch writes, and tighten docs/tests for TP chunk metadata APIs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces new APIs for storing individual tensor-parallel shards and their associated metadata, including put_tensor_chunk_with_tp, batch_put_tensor_chunk_with_tp, and their variants for registered buffers. It also defines GlobalMetadata and ChunkMetadata structures to manage shard placement and full tensor shapes. Review feedback highlights the need for better atomicity and cleanup logic when metadata storage fails to prevent orphaned objects in the store, specifically within the put_tensor_chunk_with_tp and batch_put_tensor_with_tp_impl functions. Additionally, the sharding range calculation logic was flagged for assuming a specific distribution strategy that may not be compatible with all user-defined sharding plans.
|
This pr is split from #1389 |
Restore the serialized-tensor decode helpers and make TP metadata key helpers static so the Python store bindings build cleanly across CI configurations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Tighten TP chunk put validation to reject shard shapes that don't match the default TP sharding plan, and clean up partially written shard/metadata objects when later metadata writes fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| return TensorDtype::UNKNOWN; | ||
| } | ||
|
|
||
| inline size_t get_element_size(int32_t dtype) { |
There was a problem hiding this comment.
Why not directly use sizeof?
There was a problem hiding this comment.
This follows the existing put_tensor serialization path.
In this code path we only have the runtime TensorDtype value from TensorMetadata, not a concrete compile-time C++ type, so sizeof(...) is not directly applicable here.
We therefore keep a runtime dtype-to-element-size mapping, consistent with the current put_tensor / put_tensor_from logic.
Reject mismatched TP chunk payloads in put_tensor_chunk_with_tp_from before storing shard data so the from-buffer API matches the other TP chunk write paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This PR introduces tensor chunk write APIs that allow distributed processes to write their own tensor shards directly, instead of requiring the full tensor to be materialized on a single process first. The main motivation is to let each rank write its local tensor chunk concurrently, which avoids the extra all-gather cost and reduces both communication overhead and temporary memory pressure in distributed workloads. This is especially useful when each process already owns its local shard and only needs to persist it together with enough metadata for later reconstruction. It also prepares the storage interface for future heterogeneous tensor-parallel (TP) read/write scenarios. By making shard-level writes and metadata handling explicit now, we can support more flexible TP layouts and heterogeneous execution environments in follow-up work, where different devices or ranks may not share the same data placement or reconstruction path. |
|
Performence test with different sizes: 256MB
512MB
1024MB
And I profiled the overhead of metadata put:just 0.6ms。 We have not tested the performance of multiple threads concurrently writing their own chunks versus all-gather + put yet, because even when multiple threads write in parallel today, the underlying path is still effectively serialized. As a result, the expected advantage cannot be observed yet. We need to fix that issue first before the benefit can be reflected in benchmark results. For now, these performance tests show that there is no obvious performance regression. |
Add a tensor API benchmark that warms up large zero-copy TP writes before comparing put and TP chunk put paths. This verifies the new TP chunk APIs do not show an obvious regression once Mooncake reaches steady-state performance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
We decided not to redesign the underlying metadata layer for TP chunk metadata at this stage. |
Description
This PR extracts the PR1-scoped TP metadata write path from the larger TP/CCRP work.
It adds chunk-oriented TP put APIs in the Python store bindings so callers that already own the sharding plan can write shard payloads together with TP metadata, without depending
on later reconstruction/CCRP changes.
Changes in this PR include:
GlobalMetadataandChunkMetadatafor TP shard metadataput_tensor_chunk_with_tpbatch_put_tensor_chunk_with_tpput_tensor_chunk_with_tp_frombatch_put_tensor_chunk_with_tp_fromMotivation
This PR introduces tensor chunk write APIs that allow distributed processes to write their own tensor shards directly, instead of requiring the full tensor to be materialized on a single process first. The main motivation is to let each rank write its local tensor chunk concurrently, which avoids the extra all-gather cost and reduces both communication overhead and temporary memory pressure in distributed workloads. This is especially useful when each process already owns its local shard and only needs to persist it together with enough metadata for later reconstruction.
It also prepares the storage interface for future heterogeneous tensor-parallel (TP) read/write scenarios. By making shard-level writes and metadata handling explicit now, we can support more flexible TP layouts and heterogeneous execution environments in follow-up work, where different devices or ranks may not share the same data placement or reconstruction path.
Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-pg)mooncake-rl)Type of Change
How Has This Been Tested?
python -m py_compile scripts/test_tensor_chunk_api.pyscripts/test_tensor_chunk_api.pycovering:split_dimnegative caseNote:
remove_all().Checklist
./scripts/code_format.shbefore submitting.