mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #1673] [RFC]: Data Type Support in Mooncake Store #491
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#491
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stmatengss on GitHub (Mar 16, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/1673
Changes proposed
Summary
Extend Mooncake Store to support explicit data type classification for stored objects (KVCache, Tensor, Weight, Sample, etc.), enabling type-aware optimizations for storage, eviction, replication, and retrieval policies.
Motivation
Currently, Mooncake Store treats all objects as opaque byte blobs without semantic understanding of their content. This limits optimization opportunities:
Design Goals
Proposed Design
1. Data Type Enumeration
Add a new enum in
mooncake-store/include/types.h:2. Extended ReplicateConfig
Extend
ReplicateConfiginmooncake-store/include/replica.h:3. Object Metadata Extension
Extend object metadata to store type information:
4. Type-Aware Eviction Strategy
Create new eviction strategy in
mooncake-store/include/eviction_strategy.h:Default policies:
WEIGHT: priority=0.1 (rarely evict), min_ttl=3600sKVCACHE: priority=0.5 (moderate), min_ttl=60sSAMPLE: priority=0.9 (evict first), min_ttl=10sUNKNOWN: priority=0.5 (default behavior)5. API Changes
C++ API (backward compatible)
Python API
6. Type-Aware Allocation
Extend
AllocationStrategyto consider data types:7. Monitoring & Metrics
Add per-type metrics:
store.objects.count{type=KVCACHE}store.objects.bytes{type=WEIGHT}store.evictions.count{type=SAMPLE}store.cache_hit_rate{type=TENSOR}Implementation Plan
Phase 1: Core Infrastructure (Week 1-2)
ObjectDataTypeenum to types.hReplicateConfigwith data_type fieldPhase 2: Storage & Retrieval (Week 3-4)
put()family to accept and store data typeget()family to return data type (optional)put_typed()convenience methodsPhase 3: Type-Aware Policies (Week 5-6)
TypeAwareEvictionStrategyTypeAwareAllocationStrategyPhase 4: Python Bindings & Testing (Week 7-8)
ObjectDataTypeto PythonPhase 5: Monitoring & Documentation (Week 9-10)
Backward Compatibility
UNKNOWN, treated with default policiesUNKNOWNon first accessput()/get()calls work unchangedUNKNOWNif missingPerformance Considerations
Alternatives Considered
Alternative 1: Key Prefix Convention
Use key prefixes like
kvcache:,weight:to infer types.Rejected: Fragile, requires parsing, breaks existing keys, no enforcement.
Alternative 2: Separate Stores per Type
Create separate store instances for each data type.
Rejected: Resource fragmentation, complex management, no unified view.
Alternative 3: External Type Registry
Store type mappings in external service (etcd).
Rejected: Extra network hop, consistency challenges, single point of failure.
Open Questions
Success Metrics
References
Before submitting a new issue...
@ykwd commented on GitHub (Mar 17, 2026):
The idea of introducing a data type is a good one—it provides room for the system to optimize based on object types.
However, the current system has some issues when supporting very long TTLs, such as 3600s. If metadata high availability is not enabled, metadata may be lost when the master restarts or fails over. New
putrequests may overwrite existing data, causing read requests issued before the restart to return incorrect results.When the TTL is short, this issue is almost negligible, because
lease = ttl, and read requests automatically fail once the lease expires.In addition, there are cases where we need to store large objects or read a large batch of data. If the lease duration is too short, it may lead to read failures. As a result, users tend to set a longer lease (e.g., 30 or 300 seconds), which introduces potential risks.
The root cause of these issues is that after a master restart or failover, the system cannot guarantee the semantics of the lease (other than relying on TTL expiration). I think we could decouple lease and TTL going forward. TTL can remain long, while the lease is set to a shorter duration, such as 5 seconds. When a read request exceeds the lease, instead of failing immediately, it can send an RPC to the master for confirmation. This way, by having the new master delay serving requests for 5 seconds, we can ensure the correctness of reads.
@he-yufeng commented on GitHub (Mar 21, 2026):
The phased approach makes sense. I'd like to start with Phase 1 — the core
ObjectDataTypeenum,ReplicateConfigextension, and metadata propagation through the store/allocation path.@ykwd's point about decoupling TTL from type is well taken — Phase 1 can keep TTL behavior unchanged and only add the type field. Type-aware eviction/replication policies can come in Phase 2.
Would this be a reasonable scope for a first PR?
@stmatengss commented on GitHub (Mar 22, 2026):
Agreed. This scope sounds perfect for Phase 1.
Keeping TTL behavior unchanged while just adding the type field aligns well with @ykwd's feedback on decoupling. It minimizes the blast radius of this change and lets us validate the metadata propagation path first. We can tackle the policy logic in Phase 2 once this foundation is laid.
Please proceed with the PR.
Before that, I think we can talk about design details offline (maybe slack or other app?)
@he-yufeng commented on GitHub (Mar 22, 2026):
Great, I'll get started on the PR.
I've reached out to you on WeChat for the discussion — happy to go over the metadata struct layout and serialization details before pushing code.
@github-actions[bot] commented on GitHub (Jun 21, 2026):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please comment to keep it open.
@github-actions[bot] commented on GitHub (Jun 28, 2026):
Closing due to 3 months of inactivity. If this is still relevant, please comment and we can reopen.