[KV Offload] Split replicated-layout pre-faulting across workers (#59545)
Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com> Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Robert Shaw
Codex
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
c068db0e1d
commit
483e0c24c7
@@ -45,6 +45,7 @@ def _make_region(
|
||||
num_workers: int = 1,
|
||||
rank: int = 0,
|
||||
barrier=None,
|
||||
populate_shard: tuple[int, int] | None = None,
|
||||
) -> SharedOffloadRegion:
|
||||
assert cpu_page_size % PAGE_SIZE == 0
|
||||
return SharedOffloadRegion(
|
||||
@@ -54,6 +55,7 @@ def _make_region(
|
||||
kv_bytes_per_chunk=num_workers * cpu_page_size,
|
||||
cpu_page_size=cpu_page_size,
|
||||
barrier=barrier,
|
||||
populate_shard=populate_shard,
|
||||
)
|
||||
|
||||
|
||||
@@ -526,6 +528,25 @@ def test_madvise_success_selects_madvise_population(iid, monkeypatch):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"shard, expected",
|
||||
[((1, 2), [(3 * PAGE_SIZE, 3 * PAGE_SIZE)]), ((3, 4), [])],
|
||||
)
|
||||
def test_populate_shard_prefaults_only_its_share(iid, monkeypatch, shard, expected):
|
||||
"""Workers that map the same bytes each pre-fault one contiguous share
|
||||
(page-rounded; a trailing share may be empty) instead of the whole region."""
|
||||
from vllm.v1.kv_offload.cpu import shared_offload_region as sor
|
||||
|
||||
madvise_calls: list[tuple[int, int]] = []
|
||||
monkeypatch.setattr(
|
||||
sor,
|
||||
"_madvise_populate_write",
|
||||
lambda mm, off, ln: madvise_calls.append((off, ln)),
|
||||
)
|
||||
with _region(iid, num_chunks=3, num_workers=2, populate_shard=shard):
|
||||
assert madvise_calls == [(0, PAGE_SIZE), *expected]
|
||||
|
||||
|
||||
def test_madvise_einval_selects_fallback_for_ranked_region(iid, monkeypatch):
|
||||
"""An EINVAL probe must select fallback for every ranked chunk."""
|
||||
from vllm.v1.kv_offload.cpu import shared_offload_region as sor
|
||||
|
||||
Reference in New Issue
Block a user