Make tiering offload region DP-replica aware (#47987)
Signed-off-by: Liran Schour <lirans@il.ibm.com> Co-authored-by: Or Ozeri <oro@il.ibm.com>
This commit is contained in:
@@ -33,14 +33,14 @@ class SharedOffloadRegion:
|
||||
the rest open the existing file and wait until it reaches the expected
|
||||
size. Each worker then mmap()s the full file.
|
||||
|
||||
File path: /dev/shm/vllm_offload_{instance_id}.mmap
|
||||
File path: /dev/shm/vllm_offload_{engine_id}.mmap
|
||||
"""
|
||||
|
||||
BLOCK_SIZE_ALIGNMENT: int = mmap.PAGESIZE
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
instance_id: str,
|
||||
engine_id: str,
|
||||
num_blocks: int,
|
||||
rank: int | None,
|
||||
kv_bytes_per_block: int,
|
||||
@@ -53,7 +53,7 @@ class SharedOffloadRegion:
|
||||
self._row_stride = kv_bytes_per_block
|
||||
self.total_size_bytes = self.num_blocks * self._row_stride
|
||||
|
||||
self.mmap_path = f"/dev/shm/vllm_offload_{instance_id}.mmap"
|
||||
self.mmap_path = f"/dev/shm/vllm_offload_{engine_id}.mmap"
|
||||
self._creator = False # set True only if this worker creates the file
|
||||
self.rank = rank
|
||||
if rank is not None:
|
||||
|
||||
@@ -108,6 +108,13 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
|
||||
# Scheduler-side mmap (rank=None); kept for cleanup
|
||||
self._scheduler_mmap: SharedOffloadRegion | None = None
|
||||
|
||||
# engine_id is unique per DP replica (suffixed with _dp{rank} in both
|
||||
# the Ray and multiprocessing paths), so it names a per-replica offload
|
||||
# region. Non-None is guaranteed by OffloadingSpec.__init__.
|
||||
assert vllm_config.kv_transfer_config is not None
|
||||
assert vllm_config.kv_transfer_config.engine_id is not None
|
||||
self._engine_id: str = vllm_config.kv_transfer_config.engine_id
|
||||
|
||||
@override
|
||||
def get_manager(self) -> OffloadingManager:
|
||||
"""
|
||||
@@ -124,7 +131,7 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
|
||||
# Create scheduler-side SharedOffloadRegion (rank=None) so the
|
||||
# primary tier can eagerly create a memoryview over _base.
|
||||
scheduler_mmap = SharedOffloadRegion(
|
||||
instance_id=self.vllm_config.instance_id,
|
||||
engine_id=self._engine_id,
|
||||
num_blocks=self.num_blocks,
|
||||
rank=None,
|
||||
kv_bytes_per_block=self.kv_bytes_per_offloaded_block,
|
||||
@@ -187,9 +194,12 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
|
||||
|
||||
@override
|
||||
def create_worker(self, kv_caches: CanonicalKVCaches) -> CPUOffloadingWorker:
|
||||
rank = torch.accelerator.current_device_index()
|
||||
# Fold the global physical device index into the replica-local
|
||||
# [0, world_size) slot range.
|
||||
world_size = self.vllm_config.parallel_config.world_size
|
||||
rank = torch.accelerator.current_device_index() % world_size
|
||||
worker_mmap = SharedOffloadRegion(
|
||||
instance_id=self.vllm_config.instance_id,
|
||||
engine_id=self._engine_id,
|
||||
num_blocks=self.num_blocks,
|
||||
rank=rank,
|
||||
kv_bytes_per_block=self.kv_bytes_per_offloaded_block,
|
||||
|
||||
Reference in New Issue
Block a user