Skip to content

vllm.distributed.ec_transfer.ec_connector.mooncake.memory

Registered-memory allocation and residency for Mooncake transfers.

The Producer pool stages source tensors in a registered slab. The Consumer pool owns destination allocations from reservation through publication, resident reuse, CUDA-safe retirement, and pressure-driven reclamation.

Classes:

  • ConsumerMemoryPool –

    Own the registered receive slab and resident allocation lifecycle.

  • ContiguousAllocator –

    Own a registered slab and its aligned regions; callers serialize access.

  • MemoryAllocation –

    Describe a tensor view carved from the Consumer receive slab.

  • ProducerMemoryPool –

    Own the Producer staging slab and regions carved from it.

  • ResidentLease –

    Represent a borrow of one resident entry.

  • ResidentPool –

    Track resident values, active leases, and LRU eviction eligibility.

  • StagedSources –

    Own Producer tensor views and their staging-slab regions.

ConsumerMemoryPool

Own the registered receive slab and resident allocation lifecycle.

Methods:

invalidate_published()

Invalidate every published resident after a cache reset.

Unleased residents are evicted at once. Leased residents are marked invalidated: lookups miss immediately, and the entry is evicted when its final lease is released. Evictions are not reported via drain_reclaimed -- the Scheduler already expired its own records at reset, and a late notice could clobber a re-established resident of the same hash. Reclaim notices accumulated before the reset are dropped for the same reason. This is a no-op before the receive slab is prepared.

ContiguousAllocator

Own a registered slab and its aligned regions; callers serialize access.

MemoryAllocation dataclass

Describe a tensor view carved from the Consumer receive slab.

ProducerMemoryPool

Own the Producer staging slab and regions carved from it.

Methods:

  • stage –

    Copy tensors into one registered slab, or return None for fallback.

stage(tensors)

Copy tensors into one registered slab, or return None for fallback.

ResidentLease dataclass

Bases: Generic[_T]

Represent a borrow of one resident entry.

ResidentPool

Bases: Generic[_T]

Track resident values, active leases, and LRU eviction eligibility.

Methods:

  • evict_unleased –

    Remove one resident that has no active leases.

  • insert –

    Pin an entry and return a displaced value that has no owners.

  • mark_invalidated –

    Flag one leased resident for eviction at final lease release.

  • peek –

    Return the current value even when invalidated.

evict_unleased(key, evict)

Remove one resident that has no active leases.

Unlike retire, this drops the entry so later lookups miss. Entries with leases stay in the pool. evict decides whether to accept the value and is responsible for releasing it.

insert(key, value)

Pin an entry and return a displaced value that has no owners.

mark_invalidated(key)

Flag one leased resident for eviction at final lease release.

peek(key)

Return the current value even when invalidated.

Replacement bookkeeping must see invalidated entries; lookups serving new work must not.

StagedSources dataclass

Own Producer tensor views and their staging-slab regions.

_ResidentEntry dataclass

Bases: Generic[_T]

Store one resident value and its ownership accounting.