[CI] Ignore ruff D209, rejoin the docstrings it split, and silence incompatible-rule warnings (#57212)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1085b64425
commit
651a88c09a
@@ -101,8 +101,7 @@ def test_packed_dsv4_zeroer_zeroes_only_each_layers_page():
|
||||
def test_overlaid_zeroer_dedups_segments_with_max_span():
|
||||
"""Two groups overlay one allocation; the zeroer must emit one segment per distinct
|
||||
byte offset, spanning the widest overlaid page, so a newly allocated block is fully
|
||||
zeroed no matter which group owns it.
|
||||
"""
|
||||
zeroed no matter which group owns it."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from vllm.v1.core.kv_cache_utils import get_kv_cache_config_from_groups
|
||||
|
||||
@@ -97,8 +97,7 @@ def test_draft_lookahead_uses_boundary_feature_when_cached():
|
||||
"""The drafter's +1 look-ahead can reach the feature at offset ==
|
||||
processed_end (the next chunk). When its encoder output is already cached
|
||||
(the scheduler encoded it ahead), it is used for the look-ahead position
|
||||
rather than ignored.
|
||||
"""
|
||||
rather than ignored."""
|
||||
f0 = _feature("h0", offset=0, length=8)
|
||||
f1 = _feature("h1", offset=8, length=8) # starts exactly at processed_end
|
||||
runner = _make_runner([f0, f1], cached=[f0, f1])
|
||||
@@ -115,8 +114,7 @@ def test_draft_lookahead_uses_boundary_feature_when_cached():
|
||||
def test_draft_lookahead_tolerates_missing_boundary_feature():
|
||||
"""When the +1 look-ahead feature past the processed boundary is not yet
|
||||
encoded, fall back to the token embedding (the draft token is verified by
|
||||
the target) instead of raising.
|
||||
"""
|
||||
the target) instead of raising."""
|
||||
f0 = _feature("h0", offset=0, length=8)
|
||||
f1 = _feature("h1", offset=8, length=8) # boundary feature, not cached
|
||||
runner = _make_runner([f0, f1], cached=[f0])
|
||||
@@ -133,8 +131,7 @@ def test_draft_lookahead_tolerates_missing_boundary_feature():
|
||||
def test_draft_lookahead_raises_on_interior_miss():
|
||||
"""A miss for a feature within the processed range (not the look-ahead
|
||||
boundary) is a real invariant violation and must fail loudly, even on the
|
||||
drafter path.
|
||||
"""
|
||||
drafter path."""
|
||||
f0 = _feature("h0", offset=0, length=8) # interior, within processed range
|
||||
runner = _make_runner([f0], cached=[])
|
||||
|
||||
@@ -144,8 +141,7 @@ def test_draft_lookahead_raises_on_interior_miss():
|
||||
|
||||
def test_target_path_raises_on_encoder_cache_miss():
|
||||
"""On the target path (no look-ahead) a miss is a real invariant
|
||||
violation and must fail loudly.
|
||||
"""
|
||||
violation and must fail loudly."""
|
||||
f0 = _feature("h0", offset=0, length=8)
|
||||
runner = _make_runner([f0], cached=[])
|
||||
|
||||
@@ -156,8 +152,7 @@ def test_target_path_raises_on_encoder_cache_miss():
|
||||
@pytest.mark.parametrize("draft_lookahead", [0, 1])
|
||||
def test_multi_request_batch_gathers_per_request(draft_lookahead):
|
||||
"""Two prefilling requests in one batch: per-request query bounds must be
|
||||
indexed by request, not applied as whole arrays.
|
||||
"""
|
||||
indexed by request, not applied as whole arrays."""
|
||||
a0 = _feature("a0", offset=0, length=8)
|
||||
b0 = _feature("b0", offset=0, length=8)
|
||||
cache = EncoderCache()
|
||||
|
||||
@@ -73,8 +73,7 @@ def _apply(bad_words_token_ids: list[list[int]]) -> torch.Tensor:
|
||||
|
||||
def test_v2_bad_words_prefix_inside_draft_tokens():
|
||||
"""A prefix matching entirely within the draft tokens must mask the bad
|
||||
word's last token at the draft position that completes the prefix.
|
||||
"""
|
||||
word's last token at the draft position that completes the prefix."""
|
||||
out = _apply([[12, 13, 40]])
|
||||
expected = torch.zeros_like(out)
|
||||
expected[2, 40] = -float("inf")
|
||||
@@ -83,8 +82,7 @@ def test_v2_bad_words_prefix_inside_draft_tokens():
|
||||
|
||||
def test_v2_bad_words_prefix_spanning_committed_and_draft_tokens():
|
||||
"""A prefix spanning the committed/draft boundary must mask at the row
|
||||
where the prefix completes, not one draft position later.
|
||||
"""
|
||||
where the prefix completes, not one draft position later."""
|
||||
out = _apply([[11, 12, 30]])
|
||||
expected = torch.zeros_like(out)
|
||||
expected[1, 30] = -float("inf")
|
||||
@@ -93,8 +91,7 @@ def test_v2_bad_words_prefix_spanning_committed_and_draft_tokens():
|
||||
|
||||
def test_v2_bad_words_no_spurious_match_from_last_committed_token():
|
||||
"""The last committed token must not be double-counted as the first draft
|
||||
token; [11, 11] never occurs in output [10, 11] + drafts [12, 13].
|
||||
"""
|
||||
token; [11, 11] never occurs in output [10, 11] + drafts [12, 13]."""
|
||||
out = _apply([[11, 11, 50]])
|
||||
expected = torch.zeros_like(out)
|
||||
torch.testing.assert_close(out, expected)
|
||||
|
||||
@@ -43,8 +43,7 @@ def _make_batch(
|
||||
slot_pool: np.ndarray | None = None,
|
||||
) -> InputBatch:
|
||||
"""Consistent batch with random unique request slots, 1 + k_i logits
|
||||
rows per request at the tail of each query segment.
|
||||
"""
|
||||
rows per request at the tail of each query segment."""
|
||||
if slot_pool is None:
|
||||
slot_pool = np.arange(max_num_reqs)
|
||||
slots = rng.choice(slot_pool, size=num_reqs, replace=False)
|
||||
@@ -142,8 +141,7 @@ def _owned_rows(cu: np.ndarray, owned: np.ndarray) -> np.ndarray:
|
||||
def test_local_batch_partition(tp_size: int, seed: int):
|
||||
"""Local sub-batches partition the batch by owner, preserve batch order
|
||||
within an owner, and carry exactly the owned requests' entries of every
|
||||
per-request and per-row array.
|
||||
"""
|
||||
per-request and per-row array."""
|
||||
rng = np.random.default_rng(seed)
|
||||
max_num_reqs = 64
|
||||
batch = _make_batch(rng, num_reqs=23, max_num_reqs=max_num_reqs, max_spec=3)
|
||||
@@ -225,8 +223,7 @@ def test_local_batch_partition(tp_size: int, seed: int):
|
||||
def test_all_to_all_reassembly_simulated(tp_size: int):
|
||||
"""Vocab shards computed from owner-sorted hidden states and routed
|
||||
through the simulated all-to-all reassemble into exactly the full-vocab
|
||||
logits of each rank's owned rows.
|
||||
"""
|
||||
logits of each rank's owned rows."""
|
||||
rng = np.random.default_rng(7)
|
||||
max_num_reqs = 32
|
||||
batch = _make_batch(rng, num_reqs=11, max_num_reqs=max_num_reqs, max_spec=4)
|
||||
@@ -264,8 +261,7 @@ def test_all_to_all_reassembly_simulated(tp_size: int):
|
||||
@requires_cuda
|
||||
def test_shard_no_spec():
|
||||
"""Batches without draft tokens (one logits row per request) degenerate
|
||||
cleanly: rows mirror requests.
|
||||
"""
|
||||
cleanly: rows mirror requests."""
|
||||
rng = np.random.default_rng(11)
|
||||
tp_size = 4
|
||||
max_num_reqs = 32
|
||||
@@ -284,8 +280,7 @@ def test_shard_no_spec():
|
||||
@pytest.mark.parametrize("tp_size", [2, 4])
|
||||
def test_shard_grammar_output(tp_size: int):
|
||||
"""The grammar filter keeps exactly the owned requests' bitmask rows, in
|
||||
grammar order, and the per-rank pieces partition the global bitmask.
|
||||
"""
|
||||
grammar order, and the per-rank pieces partition the global bitmask."""
|
||||
rng = np.random.default_rng(5)
|
||||
max_num_reqs = 32
|
||||
num_reqs = 12
|
||||
@@ -340,8 +335,7 @@ def test_shard_grammar_output(tp_size: int):
|
||||
@pytest.mark.parametrize("tp_size", [2, 4])
|
||||
def test_gather_src_indices_round_trip(tp_size: int):
|
||||
"""Padded per-rank result blocks indexed by gathered_src_indices restore
|
||||
batch order, including when some rank owns zero requests.
|
||||
"""
|
||||
batch order, including when some rank owns zero requests."""
|
||||
rng = np.random.default_rng(3)
|
||||
max_num_reqs = 40
|
||||
all_slots = np.arange(max_num_reqs)
|
||||
@@ -376,8 +370,7 @@ def test_gather_src_indices_round_trip(tp_size: int):
|
||||
def test_gather_sampler_output_kernels(tp_size: int):
|
||||
"""The fused pack/unpack kernels round-trip per-rank sampler results
|
||||
into batch order: token ids zero-filled past the local width, counts
|
||||
cast back to int32, identical on every rank.
|
||||
"""
|
||||
cast back to int32, identical on every rank."""
|
||||
from dataclasses import replace as dc_replace
|
||||
|
||||
from vllm.v1.worker.gpu.sample.output import SamplerOutput
|
||||
@@ -472,8 +465,7 @@ def test_gather_sampler_output_kernels(tp_size: int):
|
||||
def test_gather_sampler_output_logprobs_and_nans():
|
||||
"""num_nans is reduced per request and gathered; LogprobsTensors are
|
||||
packed into fixed per-request blocks, width-aligned across ranks (pad
|
||||
and truncate paths), and restored to global row order.
|
||||
"""
|
||||
and truncate paths), and restored to global row order."""
|
||||
from dataclasses import replace as dc_replace
|
||||
|
||||
from vllm.v1.outputs import LogprobsTensors
|
||||
@@ -606,8 +598,7 @@ def test_gather_sampler_output_logprobs_and_nans():
|
||||
def test_finish_requests_frees_slots_in_sorted_order():
|
||||
"""Request slots must be freed in the same order on every TP rank:
|
||||
ownership derives from slot indices, and `finished_req_ids` is a set
|
||||
whose iteration order is per-process hash-randomized.
|
||||
"""
|
||||
whose iteration order is per-process hash-randomized."""
|
||||
from vllm.v1.worker.gpu.model_runner import GPUModelRunner
|
||||
|
||||
removed: list[str] = []
|
||||
|
||||
@@ -217,8 +217,7 @@ def test_v1_block_table_move_row_clears_vacated_row():
|
||||
not keep stale block ids. Padded dummy-run batches dereference stale rows
|
||||
as mamba state slots (bypassing the NULL_BLOCK_ID fill of real decode
|
||||
padding) and write state in place there — corrupting the blocks' new
|
||||
owner once they are reallocated, e.g. to an in-flight NIXL load.
|
||||
"""
|
||||
owner once they are reallocated, e.g. to an in-flight NIXL load."""
|
||||
from vllm.v1.worker.block_table import BlockTable
|
||||
|
||||
block_table = BlockTable(
|
||||
@@ -250,8 +249,7 @@ def test_get_dummy_block_tables_returns_zeroed_rows():
|
||||
PAD-filled, state indices are not), so stale rows would direct dummy
|
||||
state writes at freed — possibly reallocated — blocks.
|
||||
get_dummy_block_tables must hand out zeroed (null block) rows while
|
||||
preserving the persistent storage address for CUDA graphs.
|
||||
"""
|
||||
preserving the persistent storage address for CUDA graphs."""
|
||||
device = torch.device("cuda")
|
||||
block_tables = BlockTables(
|
||||
block_sizes=[16],
|
||||
|
||||
@@ -85,8 +85,7 @@ def test_v2_min_tokens_keeps_masking_when_other_candidates_remain():
|
||||
|
||||
def test_v2_min_tokens_mixed_batch_gates_restore_per_request():
|
||||
"""CHECK_ALL_MASKED_ROWS is a batch-wide constexpr, so a mixed batch must
|
||||
still consult the per-request flag.
|
||||
"""
|
||||
still consult the per-request flag."""
|
||||
out = _apply(_only_stop_token_left(2), structured=[True, False])
|
||||
|
||||
assert out[0, STOP_TOKEN] == 1.0
|
||||
|
||||
@@ -73,8 +73,7 @@ DEVICE_TYPE = current_platform.device_type
|
||||
def _restore_default_dtype():
|
||||
"""Several tests here set the process-wide default dtype to float16 and
|
||||
previously leaked it, corrupting later float-sensitive tests in the same
|
||||
pytest process (torch.randn silently produced fp16).
|
||||
"""
|
||||
pytest process (torch.randn silently produced fp16)."""
|
||||
old = torch.get_default_dtype()
|
||||
yield
|
||||
torch.set_default_dtype(old)
|
||||
@@ -1454,8 +1453,7 @@ def test_v2_runner_snapshots_late_interleave_adjustment(monkeypatch):
|
||||
|
||||
def test_hybrid_block_table_initialization():
|
||||
"""Test hybrid block table with different kernel and kvcache_manager block
|
||||
sizes.
|
||||
"""
|
||||
sizes."""
|
||||
from vllm.v1.worker.block_table import BlockTable
|
||||
|
||||
# Test configuration: kvcache_manager block size = 32,
|
||||
|
||||
@@ -62,8 +62,7 @@ def _gather(features, cached, *, num_scheduled, shift, num_computed=0):
|
||||
def test_draft_shift_uses_boundary_feature_when_cached():
|
||||
"""The drafter's +1 look-ahead reaches the feature at offset ==
|
||||
processed_end; when it is already cached it is used for the look-ahead
|
||||
position rather than ignored.
|
||||
"""
|
||||
position rather than ignored."""
|
||||
f0 = _feature("h0", offset=0, length=8)
|
||||
f1 = _feature("h1", offset=8, length=8) # starts exactly at processed_end
|
||||
mm_embeds, is_mm_embed = _gather([f0, f1], [f0, f1], num_scheduled=8, shift=1)
|
||||
@@ -76,8 +75,7 @@ def test_draft_shift_uses_boundary_feature_when_cached():
|
||||
|
||||
def test_draft_shift_tolerates_missing_boundary_feature():
|
||||
"""When the +1 look-ahead feature past the processed boundary is not yet
|
||||
encoded, fall back to the token embedding instead of raising.
|
||||
"""
|
||||
encoded, fall back to the token embedding instead of raising."""
|
||||
f0 = _feature("h0", offset=0, length=8)
|
||||
f1 = _feature("h1", offset=8, length=8) # boundary feature, not cached
|
||||
mm_embeds, is_mm_embed = _gather([f0, f1], [f0], num_scheduled=8, shift=1)
|
||||
@@ -89,8 +87,7 @@ def test_draft_shift_tolerates_missing_boundary_feature():
|
||||
|
||||
def test_draft_shift_raises_on_interior_miss():
|
||||
"""A miss for a feature within the processed range (not the look-ahead
|
||||
boundary) is a real invariant violation, even on the drafter path.
|
||||
"""
|
||||
boundary) is a real invariant violation, even on the drafter path."""
|
||||
f0 = _feature("h0", offset=0, length=8) # interior, within processed range
|
||||
with pytest.raises(RuntimeError, match="Encoder cache miss"):
|
||||
_gather([f0], [], num_scheduled=8, shift=1)
|
||||
|
||||
@@ -219,8 +219,7 @@ def test_append_block_ids_rejects_write_past_row_capacity():
|
||||
|
||||
def _make_capture_runner(captured: bool) -> GPUModelRunner:
|
||||
"""Minimal V2 runner for capture_model: fakes everything except the
|
||||
cudagraph_manager's needs_capture decision.
|
||||
"""
|
||||
cudagraph_manager's needs_capture decision."""
|
||||
runner = GPUModelRunner.__new__(GPUModelRunner)
|
||||
runner.model_state = SimpleNamespace(supports_mm_inputs=False)
|
||||
runner.cudagraph_manager = SimpleNamespace(
|
||||
@@ -246,8 +245,7 @@ def _make_capture_runner(captured: bool) -> GPUModelRunner:
|
||||
def test_capture_model_locks_workspace_after_capture(monkeypatch):
|
||||
"""A workspace resize after capture frees the buffer the captured graphs
|
||||
baked in, so capture_model must lock the workspace before returning
|
||||
(https://github.com/vllm-project/vllm/issues/55336).
|
||||
"""
|
||||
(https://github.com/vllm-project/vllm/issues/55336)."""
|
||||
runner = _make_capture_runner(captured=True)
|
||||
monkeypatch.setattr(
|
||||
model_runner_module, "freeze_gc_for_cudagraph_capture", contextlib.nullcontext
|
||||
@@ -268,8 +266,7 @@ def test_capture_model_locks_workspace_after_capture(monkeypatch):
|
||||
|
||||
def test_capture_model_skips_lock_when_nothing_captured(monkeypatch):
|
||||
"""With no graphs to capture (e.g. enforce_eager) there is nothing baked
|
||||
into the workspace, so the early return must not lock it.
|
||||
"""
|
||||
into the workspace, so the early return must not lock it."""
|
||||
runner = _make_capture_runner(captured=False)
|
||||
lock_calls = []
|
||||
monkeypatch.setattr(
|
||||
@@ -283,8 +280,7 @@ def test_capture_model_skips_lock_when_nothing_captured(monkeypatch):
|
||||
def test_capture_model_profile_only_skips_lock(monkeypatch):
|
||||
"""The memory-profiling capture pass runs before kernel warmup and the
|
||||
real capture; locking there would stop the warmup from growing the
|
||||
workspace to its scheduler-realistic size.
|
||||
"""
|
||||
workspace to its scheduler-realistic size."""
|
||||
runner = _make_capture_runner(captured=True)
|
||||
monkeypatch.setattr(
|
||||
model_runner_module, "freeze_gc_for_cudagraph_capture", contextlib.nullcontext
|
||||
|
||||
@@ -82,8 +82,7 @@ def _make_profiling_runner(
|
||||
|
||||
class _FakePlatform:
|
||||
"""Stands in for current_platform; the global graph pool is a class attr,
|
||||
matching vllm.platforms.Platform's lazy singleton.
|
||||
"""
|
||||
matching vllm.platforms.Platform's lazy singleton."""
|
||||
|
||||
_global_graph_pool: Any = GLOBAL_POOL
|
||||
|
||||
|
||||
@@ -120,8 +120,7 @@ def test_max_iterations(default_profiler_config):
|
||||
def test_restart_after_max_iterations(default_profiler_config):
|
||||
"""A start_profile after an auto-stop must actually restart, not be
|
||||
silently ignored (regression test: auto-stop used to leave _active
|
||||
True forever, so start() always bailed out early).
|
||||
"""
|
||||
True forever, so start() always bailed out early)."""
|
||||
default_profiler_config.max_iterations = 2
|
||||
profiler = ConcreteWorkerProfiler(default_profiler_config)
|
||||
|
||||
@@ -332,8 +331,7 @@ class TestAnnotateProfile:
|
||||
|
||||
def test_profiler_entered_during_capture():
|
||||
"""Profiler is used as a context manager in _warmup_and_capture,
|
||||
confirming it is active during the actual graph capture run.
|
||||
"""
|
||||
confirming it is active during the actual graph capture run."""
|
||||
runner = MagicMock()
|
||||
runner.compilation_config.cudagraph_num_of_warmups = 0
|
||||
mock_profiler = MagicMock()
|
||||
|
||||
@@ -34,8 +34,7 @@ def _run(
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
"""Run rejection_sample on a batch of uniform k=2 requests, with the
|
||||
request under test at request index `roi_req` and draft-logits row
|
||||
`req_state_idx`. Returns that request's (sampled, num_sampled).
|
||||
"""
|
||||
`req_state_idx`. Returns that request's (sampled, num_sampled)."""
|
||||
num_logits = num_reqs * LOGITS_PER_REQ
|
||||
roi_row = roi_req * LOGITS_PER_REQ
|
||||
|
||||
|
||||
@@ -288,8 +288,7 @@ def test_v2_thinking_budget_clamps_oversized_budget():
|
||||
|
||||
def test_v2_thinking_budget_continues_end_prefix_from_prompt():
|
||||
"""A resumed prompt ending with a partial forced-end marker must not
|
||||
restart the marker sequence and duplicate its first token.
|
||||
"""
|
||||
restart the marker sequence and duplicate its first token."""
|
||||
req_states = _make_req_states([1, START, 10, 11, END_A], prompt_len=5)
|
||||
state = ThinkingBudgetState(req_states, MockMultiTokenEndReasoningConfig())
|
||||
state.add_request(3, SamplingParams(thinking_token_budget=3))
|
||||
|
||||
@@ -701,8 +701,7 @@ def test_microbatches_recompute_dcp_lens_from_truncated_seq_lens(dcp_rank: int):
|
||||
@pytest.mark.skipif(not torch.cuda.is_available(), reason="triton kernel needs CUDA")
|
||||
def test_each_microbatch_owns_its_dcp_buffer():
|
||||
"""Microbatch DCP lengths live in per-microbatch persistent buffers so
|
||||
CPU-visible shapes stay valid under CUDA graph capture and replay.
|
||||
"""
|
||||
CPU-visible shapes stay valid under CUDA graph capture and replay."""
|
||||
input_batch, _ = _make_cuda_input_batch([4, 4, 4, 4], [8, 9, 10, 11])
|
||||
|
||||
ubatches, dcp_buffers = _slice_with_dcp(input_batch, dcp_rank=0)
|
||||
|
||||
@@ -49,8 +49,7 @@ def plan_env(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
|
||||
def test_startup_plan_fingerprint_sensitivity(plan_env):
|
||||
"""The fingerprint is the OOM-safety key: stable for identical inputs,
|
||||
different for anything the profiled value depends on.
|
||||
"""
|
||||
different for anything the profiled value depends on."""
|
||||
fp = startup_plan.compute_plan_fingerprint
|
||||
base = fp(_plan_worker().vllm_config, 0, 1)
|
||||
assert base == fp(_plan_worker().vllm_config, 0, 1)
|
||||
@@ -98,8 +97,7 @@ def _snapshot(free_memory, torch_memory=0):
|
||||
|
||||
def _profile_result(consumed, reserved_before=0, reserved_after=0):
|
||||
"""A result whose free-memory readings agree with `consumed`, which
|
||||
`memory_profiling` derives as the drop in free memory, negative when it grew.
|
||||
"""
|
||||
`memory_profiling` derives as the drop in free memory, negative when it grew."""
|
||||
return SimpleNamespace(
|
||||
total_consumed=consumed,
|
||||
transient_peak_headroom=0,
|
||||
@@ -127,8 +125,7 @@ def test_profiling_fallback_declines_when_free_memory_dropped(rocm):
|
||||
@pytest.mark.parametrize("rocm", [True], indirect=True)
|
||||
def test_profiling_fallback_replaces_a_released_measurement(rocm):
|
||||
"""A negative measurement describes the rest of the device, so it is replaced
|
||||
by this process's reservation, which the rest of the device cannot move.
|
||||
"""
|
||||
by this process's reservation, which the rest of the device cannot move."""
|
||||
result = _profile_result(
|
||||
consumed=-RELEASED_BY_OTHERS,
|
||||
reserved_after=TORCH_RESERVED,
|
||||
@@ -152,8 +149,7 @@ def test_profiling_fallback_never_returns_a_negative_amount(rocm):
|
||||
@pytest.mark.parametrize("rocm", [False], indirect=True)
|
||||
def test_profiling_fallback_declines_off_rocm(rocm):
|
||||
"""Platforms that account frees eagerly keep reporting the error, so the
|
||||
caller's assertion stays reachable there.
|
||||
"""
|
||||
caller's assertion stays reachable there."""
|
||||
result = _profile_result(consumed=-RELEASED_BY_OTHERS)
|
||||
|
||||
assert maybe_rocm_profiling_fallback(result) is None
|
||||
@@ -177,8 +173,7 @@ def test_execute_model_waits_previous_pp_send_before_forward(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
):
|
||||
"""Previous device handles are waited before the forward pass; the
|
||||
metadata handle is left to the GroupCoordinator's reaper.
|
||||
"""
|
||||
metadata handle is left to the GroupCoordinator's reaper."""
|
||||
import torch
|
||||
|
||||
from vllm.sequence import IntermediateTensors
|
||||
|
||||
@@ -358,8 +358,7 @@ def test_warmup_respects_available_block_count():
|
||||
def test_zeroes_exactly_one_block_per_layer(layout: KVCacheLayout):
|
||||
"""The zeroer must zero every byte of the target block in every layer and nothing
|
||||
outside it — per head-group region under LHBNC, and never past the target block's
|
||||
tile under block-major layouts (no out-of-bounds writes, no clobbering).
|
||||
"""
|
||||
tile under block-major layouts (no out-of-bounds writes, no clobbering)."""
|
||||
device = torch.device("cuda")
|
||||
num_blocks, num_layers = 4, 2
|
||||
spec = FullAttentionSpec(
|
||||
|
||||
@@ -645,8 +645,7 @@ def test_mamba_groups_support_mixed_specs_in_uniform_group():
|
||||
|
||||
def _make_staging_ctx(max_num_reqs: int, device: torch.device) -> MagicMock:
|
||||
"""Build a MambaSpecDecodeGPUContext stand-in exposing only the four
|
||||
per-request staging buffers touched by stage_postprocess_inputs_to_gpu.
|
||||
"""
|
||||
per-request staging buffers touched by stage_postprocess_inputs_to_gpu."""
|
||||
ctx = MagicMock()
|
||||
ctx.mamba_state_idx_buf = _MockCpuGpuBuffer(max_num_reqs, torch.int32, device)
|
||||
ctx.num_scheduled_tokens_buf = _MockCpuGpuBuffer(max_num_reqs, torch.int32, device)
|
||||
@@ -658,8 +657,7 @@ def _make_staging_ctx(max_num_reqs: int, device: torch.device) -> MagicMock:
|
||||
def test_stage_postprocess_inputs_to_gpu_fills_pinned_views():
|
||||
"""stage_postprocess_inputs_to_gpu writes each request's state_idx and
|
||||
scheduled/computed/draft counts into slot `i` for `req_ids[i]`, leaves
|
||||
slots past `num_reqs` untouched, and mirrors the values to the GPU buffers.
|
||||
"""
|
||||
slots past `num_reqs` untouched, and mirrors the values to the GPU buffers."""
|
||||
device = torch.device("cpu")
|
||||
max_num_reqs = 8
|
||||
ctx = _make_staging_ctx(max_num_reqs, device)
|
||||
@@ -731,8 +729,7 @@ def test_stage_postprocess_inputs_to_gpu_fills_pinned_views():
|
||||
|
||||
def test_stage_postprocess_inputs_to_gpu_asserts_on_missing_state_idx():
|
||||
"""If preprocess_mamba didn't populate mamba_state_idx for a req in the
|
||||
batch, staging must fail loudly rather than silently writing a stale index.
|
||||
"""
|
||||
batch, staging must fail loudly rather than silently writing a stale index."""
|
||||
device = torch.device("cpu")
|
||||
ctx = _make_staging_ctx(max_num_reqs=4, device=device)
|
||||
scheduler_output = _make_postprocess_scheduler_output(
|
||||
@@ -810,8 +807,7 @@ def _run_gpu_postprocess(
|
||||
device: torch.device,
|
||||
) -> None:
|
||||
"""Initialize the GPU context against `block_table`, run the fused
|
||||
postprocess kernel for `req_ids`, and synchronize.
|
||||
"""
|
||||
postprocess kernel for `req_ids`, and synchronize."""
|
||||
|
||||
def t(values):
|
||||
return torch.tensor(values, dtype=torch.int32, device=device)
|
||||
|
||||
@@ -17,8 +17,7 @@ def _fail(*args, **kwargs):
|
||||
@pytest.mark.parametrize("max_num_reqs", [1, 0])
|
||||
def test_mixed_warmup_skipped_for_single_seq(max_num_reqs):
|
||||
"""A mixed prefill+decode step needs >=2 requests; with max_num_reqs < 2
|
||||
the warmup must be skipped without touching the worker callbacks.
|
||||
"""
|
||||
the warmup must be skipped without touching the worker callbacks."""
|
||||
runner = SimpleNamespace(is_pooling_model=False, max_num_reqs=max_num_reqs)
|
||||
|
||||
assert (
|
||||
|
||||
@@ -78,8 +78,7 @@ def _apply(
|
||||
def test_overlay_chunked_prefill_and_decode():
|
||||
"""Rows within the embeds range come from prompt_embeds at the
|
||||
num_computed offset; requests without embeds and requests past their
|
||||
embeds length (decode) keep the base embedding.
|
||||
"""
|
||||
embeds length (decode) keep the base embedding."""
|
||||
state = _make_state()
|
||||
embeds_a = torch.randn(6, HIDDEN, dtype=torch.float32)
|
||||
embeds_b = torch.randn(5, HIDDEN, dtype=torch.float32)
|
||||
@@ -98,8 +97,7 @@ def test_overlay_chunked_prefill_and_decode():
|
||||
|
||||
def test_overlay_clamps_to_embeds_length():
|
||||
"""A window straddling the end of the prompt embeds writes only the
|
||||
in-range rows (e.g. final prefill chunk + sampled token).
|
||||
"""
|
||||
in-range rows (e.g. final prefill chunk + sampled token)."""
|
||||
state = _make_state()
|
||||
embeds = torch.randn(4, HIDDEN, dtype=torch.float32)
|
||||
state.add_request(3, _NewReqData("a", embeds))
|
||||
@@ -114,8 +112,7 @@ def test_overlay_clamps_to_embeds_length():
|
||||
|
||||
def test_overlay_respects_is_token_ids_mask():
|
||||
"""Mixed mode: positions marked as real token ids keep the base
|
||||
embedding; only embed positions are overwritten.
|
||||
"""
|
||||
embedding; only embed positions are overwritten."""
|
||||
state = _make_state()
|
||||
embeds = torch.randn(5, HIDDEN, dtype=torch.float32)
|
||||
is_token_ids = [True, False, False, True, False]
|
||||
@@ -133,8 +130,7 @@ def test_overlay_respects_is_token_ids_mask():
|
||||
|
||||
def test_index_reuse_clears_stale_entry():
|
||||
"""A request added at a previously-used index without embeds must not
|
||||
inherit the prior occupant's pointer-table entry.
|
||||
"""
|
||||
inherit the prior occupant's pointer-table entry."""
|
||||
state = _make_state()
|
||||
state.add_request(0, _NewReqData("a", torch.randn(4, HIDDEN, dtype=torch.float32)))
|
||||
# A second live embeds request so the kernel actually launches (the
|
||||
|
||||
@@ -84,8 +84,7 @@ def test_workspace_lanes_compose_with_ubatches(monkeypatch) -> None:
|
||||
|
||||
def test_workspace_lock_blocks_growth_and_unlock_restores(monkeypatch) -> None:
|
||||
"""Once locked, oversized requests fail loudly instead of reallocating the
|
||||
buffer that captured CUDA graphs point at; unlock restores growth.
|
||||
"""
|
||||
buffer that captured CUDA graphs point at; unlock restores growth."""
|
||||
monkeypatch.setattr(workspace, "dbo_current_ubatch_id", lambda: 0)
|
||||
manager = workspace.WorkspaceManager(torch.device("cpu"), num_lanes=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user