Merge branch 'main' into patches

This commit is contained in:
2026-10-05 08:21:46 +00:00
23 changed files with 1102 additions and 247 deletions
@@ -1552,6 +1552,53 @@ def test_chunked_prefill_reads_live_block_ids() -> None:
assert len(meta2.store_gpu_blocks) == 2
@pytest.mark.parametrize("use_v2_model_runner", [False, True])
@pytest.mark.parametrize("same_output", [False, True])
def test_eager_store_resets_block_cursor_after_preemption(
use_v2_model_runner: bool,
same_output: bool,
) -> None:
"""A resumed request stores its confirmed tail after preemption."""
fix = make_scheduler(num_cpu_blocks=8, num_gpu_blocks=8, lazy=False)
sched = fix.scheduler
req = make_request(num_blocks=3)
initial_blocks = _alloc_and_register(fix, req, num_blocks=2)
sched.update_state_after_alloc(req, initial_blocks, num_external_tokens=0)
initial_output = make_scheduler_output(
{req.request_id: 2 * BLOCK_SIZE},
new_reqs={req.request_id: initial_blocks.get_block_ids()},
)
initial_meta = sched.build_connector_meta(initial_output)
assert len(initial_meta.store_gpu_blocks) == 2
simulate_store_completion(sched, initial_meta.store_event)
if not same_output:
preemption_output = make_scheduler_output({})
preemption_output.preempted_req_ids = {req.request_id}
sched.build_connector_meta(preemption_output)
fix.gpu_block_pool.free_blocks(initial_blocks.blocks[0])
resumed_blocks = _alloc_and_register(fix, req, num_blocks=3)
sched.update_state_after_alloc(req, resumed_blocks, num_external_tokens=0)
if use_v2_model_runner:
resumed_output = make_scheduler_output(
{req.request_id: 3 * BLOCK_SIZE},
new_reqs={req.request_id: resumed_blocks.get_block_ids()},
)
else:
resumed_output = make_scheduler_output(
{req.request_id: 3 * BLOCK_SIZE},
cached_req_new_blocks={req.request_id: resumed_blocks.get_block_ids()},
)
resumed_output.scheduled_cached_reqs.resumed_req_ids.add(req.request_id)
if same_output:
resumed_output.preempted_req_ids = {req.request_id}
resumed_meta = sched.build_connector_meta(resumed_output)
assert resumed_meta.store_gpu_blocks == [resumed_blocks.blocks[0][2].block_id]
# ---------------------------------------------------------------------------
# Test 10: Partial GPU prefix hit + CPU load + new compute blocks
# ---------------------------------------------------------------------------
+40
View File
@@ -152,6 +152,46 @@ def test_scoped_max_split_ignores_async_allocator(monkeypatch):
set_settings.assert_not_called()
@pytest.mark.parametrize("kv_cache_memory_bytes", [None, 1])
def test_memory_profile_bounds_decode_logits_rows(monkeypatch, kv_cache_memory_bytes):
"""ROCm decode workspace uses max_num_seqs during startup profiling."""
from vllm.config import get_current_vllm_config_or_none
from vllm.v1.attention.ops.rocm_aiter_mla_sparse import _max_decode_logits_rows
config = SimpleNamespace(
scheduler_config=SimpleNamespace(max_num_seqs=16),
speculative_config=SimpleNamespace(num_speculative_tokens=5),
)
class Profiled(Exception):
pass
def profile_run(*, randomize_inputs=False):
assert randomize_inputs is True
# Without the config context, the helper falls back to all 32768
# batched tokens, which would reserve 128 GiB at 1M context.
assert _max_decode_logits_rows(32768) == 16 * (1 + 5)
raise Profiled
worker = SimpleNamespace(
vllm_config=config,
randomize_dummy_inputs=True,
cache_config=SimpleNamespace(kv_cache_memory_bytes=kv_cache_memory_bytes),
model_runner=SimpleNamespace(profile_run=profile_run, model_memory_usage=0),
init_snapshot=SimpleNamespace(free_memory=2),
_scoped_allocator_max_split=lambda **kwargs: nullcontext(),
)
monkeypatch.setattr(gpu_worker, "maybe_apply_startup_plan", lambda _: None)
monkeypatch.setattr(
gpu_worker, "memory_profiling", lambda *args, **kwargs: nullcontext()
)
assert get_current_vllm_config_or_none() is None
with pytest.raises(Profiled):
gpu_worker.Worker.determine_available_memory(worker)
assert get_current_vllm_config_or_none() is None
# Startup-plan persistence (vllm/v1/worker/startup_plan.py), applied and
# saved by Worker.determine_available_memory / compile_or_warm_up_model.