[KV Offload][CI] Fall back to buffered I/O without O_DIRECT; fix flaky api-server test (#49734)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Spawn worker targets kept free of heavy imports.
|
||||
|
||||
``multiprocessing`` with the ``spawn`` start method re-imports the module that
|
||||
defines a process target in the child. Housing these stubs in a stdlib-only
|
||||
module keeps child startup fast and deterministic, instead of paying a multi-
|
||||
second ``import vllm`` before the child can run.
|
||||
"""
|
||||
|
||||
|
||||
def exit_before_report_worker(listen_address, sock, args, client_config=None):
|
||||
"""Exit immediately without touching ``actual_address_pipe``."""
|
||||
return
|
||||
@@ -10,6 +10,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
import zmq
|
||||
|
||||
from tests.entrypoints.unit_tests._api_server_spawn_workers import (
|
||||
exit_before_report_worker,
|
||||
)
|
||||
from vllm.utils.network_utils import make_zmq_socket, split_zmq_path
|
||||
from vllm.v1.utils import (
|
||||
APIServerProcessManager,
|
||||
@@ -228,6 +231,7 @@ def test_normal_completion(api_server_args):
|
||||
def test_external_process_monitoring(api_server_args):
|
||||
"""Test that wait_for_completion_or_failure handles additional processes."""
|
||||
global WORKER_RUNTIME_SECONDS
|
||||
prev_worker_runtime = WORKER_RUNTIME_SECONDS
|
||||
WORKER_RUNTIME_SECONDS = 100
|
||||
|
||||
# Create and start the external process
|
||||
@@ -307,6 +311,7 @@ def test_external_process_monitoring(api_server_args):
|
||||
manager.shutdown()
|
||||
mock_coordinator.shutdown()
|
||||
time.sleep(0.2)
|
||||
WORKER_RUNTIME_SECONDS = prev_worker_runtime
|
||||
|
||||
|
||||
@pytest.mark.timeout(60)
|
||||
@@ -383,10 +388,10 @@ def test_gather_actual_addresses_child_crash_before_report():
|
||||
num_servers=num_servers,
|
||||
input_addresses=placeholder_inputs,
|
||||
output_addresses=placeholder_outputs,
|
||||
# mock_run_api_server_worker exits without touching
|
||||
# exit_before_report_worker exits without touching
|
||||
# ``actual_address_pipe`` — simulates a child that dies before
|
||||
# reporting its bound addresses.
|
||||
target_server_fn=mock_run_api_server_worker,
|
||||
target_server_fn=exit_before_report_worker,
|
||||
)
|
||||
try:
|
||||
# Sentinel-first vs pipe-EOF-first both produce "reporting".
|
||||
|
||||
@@ -379,6 +379,43 @@ def test_store_load_data_integrity(fs_tier):
|
||||
)
|
||||
|
||||
|
||||
def test_store_load_roundtrip_without_o_direct(tmp_path, monkeypatch):
|
||||
"""Buffered fallback must round-trip data when O_DIRECT is unsupported.
|
||||
|
||||
Simulates filesystems (e.g. overlayfs, some NFS) that reject O_DIRECT by
|
||||
forcing the capability probe to report it unavailable.
|
||||
"""
|
||||
monkeypatch.setattr(
|
||||
"vllm.v1.kv_offload.tiering.fs.manager.probe_o_direct",
|
||||
lambda _dir: False,
|
||||
)
|
||||
tensor = _page_aligned_rand_tensor(4, _BLOCK_ELEMENTS)
|
||||
tier = FileSystemTierManager(
|
||||
offloading_spec=_MOCK_OFFLOADING_SPEC,
|
||||
primary_kv_view=memoryview(tensor.numpy()),
|
||||
tier_type="fs",
|
||||
root_dir=str(tmp_path),
|
||||
n_read_threads=4,
|
||||
n_write_threads=4,
|
||||
)
|
||||
try:
|
||||
assert tier._use_o_direct is False
|
||||
|
||||
keys = [key(0), key(1)]
|
||||
expected = tensor[:2].clone()
|
||||
tier.submit_store(make_job(1, keys, [0, 1]))
|
||||
assert all(r.success for r in drain(tier))
|
||||
|
||||
tensor[:2] = 0.0
|
||||
tier.submit_load(make_job(2, keys, [2, 3], is_promotion=True))
|
||||
assert all(r.success for r in drain(tier))
|
||||
|
||||
for i, bid in enumerate([2, 3]):
|
||||
assert torch.allclose(tensor[bid], expected[i])
|
||||
finally:
|
||||
tier.shutdown()
|
||||
|
||||
|
||||
def test_wait_idle_blocks_until_tasks_complete():
|
||||
"""wait_idle must not return while a task is still in flight."""
|
||||
pool = DualQueueThreadPool(n_read_threads=1, n_write_threads=1)
|
||||
|
||||
Reference in New Issue
Block a user