[unified-memory] Honor move gates in float relocation and size auto HiCache from host capacity (#41248)

Co-authored-by: Yonghao Zhuang <yhzhuang@meta.com>
This commit is contained in:
metamergebot
2026-09-25 12:17:28 -07:00
committed by GitHub
co-authored by Yonghao Zhuang
parent 31b931edc3
commit 671000aee6
5 changed files with 87 additions and 9 deletions
@@ -2385,7 +2385,11 @@ class FloatMultiEndedAllocator(MultiEndedAllocator):
lo, hi = self._region_bounds_pages()
gap_low, gap_high = self._gap_pages()
gap_side_bytes = (gap_low if side == "low" else gap_high) * epp
if gap_side_bytes >= min_bytes or self._is_frontier_transparent():
if (
self.moves_blocked()
or gap_side_bytes >= min_bytes
or self._is_frontier_transparent()
):
return gap_side_bytes
# Capacity: even packing every live page flush against the far side
@@ -2560,7 +2564,7 @@ class FloatMultiEndedAllocator(MultiEndedAllocator):
OPPOSITE ``retreat_side`` (order-preserving), shrinking the span on
``retreat_side`` by the hole count. Returns pages moved."""
assert retreat_side in ("low", "high")
if self._hole_pages() == 0:
if self.moves_blocked() or self._hole_pages() == 0:
return 0
# Settle before the first copy -- see `make_room`.
self._settle_inflight_forward()
@@ -46,7 +46,9 @@ def _pool_bytes(pool) -> int:
return _pool_bytes(pool.full_kv_pool) + _pool_bytes(pool.swa_kv_pool)
if isinstance(pool, HybridLinearKVPool):
return _pool_bytes(pool.full_kv_pool)
sizes = pool.get_kv_size_bytes()
sizes = getattr(pool, "host_capacity_bytes", None)
if sizes is None:
sizes = pool.get_kv_size_bytes()
return sum(sizes) if isinstance(sizes, tuple) else sizes