[Mini-VLLM] Remove LoRA, plugins, speech-to-text and scale-out surfaces
Production runs one static model behind the OpenAI-compatible API. Every adapter path and non-OpenAI HTTP surface is unreachable there. - Delete the LoRA stack: vllm/lora, LoRARequest on the engine wire, the scheduler, worker, cudagraph and MoE plumbing, LoRA metrics, the lora CLI group, and the LoRA tests. - Drop the plugin loader in vllm/plugins. Platform resolution is now CUDA-only and the general/stat-logger plugin hooks are gone. - Delete the speech-to-text and realtime entrypoints, the scale-out render routes, and vllm/config/speech_to_text.py. GenerationTask is generate-only. - Cut DecodeBenchConnector and the disagg-prefill doc and image. The Multi, Offloading and Example connectors stay; production uses the CPU KV offload tier. - Delete the ROCm-only fused KDA chunk kernel (2346 lines) with its CMake arch gate, declarations and op registrations. The CUDA build never defined the guard and no Python caller existed. - Delete the orphan Mistral and Pixtral chat fixtures and examples/. - Fix _check_model: removing the LoRA early return made every request fail with "The model ... does not exist. Valid aliases: ...". Verified on an RTX 3090: import sweep reports 1242 modules with 7 known optional-dependency failures; a live server answers chat, completions, responses, tokenize and detokenize with zero log errors and 404 for the removed surfaces; collection yields 8558 tests with the 3 pre-existing errors; ruff adds no new finding; the incremental _C build succeeds. Co-authored-by: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
+117
-272
@@ -56,7 +56,6 @@ from vllm.forward_context import (
|
||||
set_forward_context,
|
||||
)
|
||||
from vllm.logger import init_logger
|
||||
from vllm.lora.layers import LoRAMapping, LoRAMappingType
|
||||
from vllm.model_executor.layers.attention import Attention
|
||||
from vllm.model_executor.layers.attention_layer_base import AttentionLayerBase
|
||||
from vllm.model_executor.layers.fused_moe.all2all_utils import get_ep_all2all_manager
|
||||
@@ -76,8 +75,6 @@ from vllm.model_executor.models.interfaces import (
|
||||
supports_eagle3,
|
||||
supports_mrope,
|
||||
supports_multimodal_pruning,
|
||||
supports_realtime,
|
||||
supports_transcription,
|
||||
)
|
||||
from vllm.model_executor.models.interfaces_base import (
|
||||
VllmModelForPooling,
|
||||
@@ -208,7 +205,6 @@ from vllm.v1.worker.gpu.eplb_utils import (
|
||||
from vllm.v1.worker.gpu_input_batch import CachedRequestState, InputBatch
|
||||
from vllm.v1.worker.gpu_ubatch_wrapper import UBatchWrapper
|
||||
from vllm.v1.worker.kv_connector_model_runner_mixin import KVConnectorModelRunnerMixin
|
||||
from vllm.v1.worker.lora_model_runner_mixin import LoRAModelRunnerMixin
|
||||
from vllm.v1.worker.ubatch_utils import (
|
||||
UBatchSlices,
|
||||
check_ubatch_thresholds,
|
||||
@@ -463,9 +459,7 @@ class ExecuteModelState(NamedTuple):
|
||||
slot_mappings: dict[str, torch.Tensor] | list[dict[str, torch.Tensor]] | None
|
||||
|
||||
|
||||
class GPUModelRunner(
|
||||
LoRAModelRunnerMixin, KVConnectorModelRunnerMixin, ECConnectorModelRunnerMixin
|
||||
):
|
||||
class GPUModelRunner(KVConnectorModelRunnerMixin, ECConnectorModelRunnerMixin):
|
||||
@JitWarmupRegistry.capture
|
||||
def __init__(
|
||||
self,
|
||||
@@ -477,7 +471,6 @@ class GPUModelRunner(
|
||||
self.cache_config = vllm_config.cache_config
|
||||
self.offload_config = vllm_config.offload_config
|
||||
self.compilation_config = vllm_config.compilation_config
|
||||
self.lora_config = vllm_config.lora_config
|
||||
self.load_config = vllm_config.load_config
|
||||
self.parallel_config = vllm_config.parallel_config
|
||||
self.scheduler_config = vllm_config.scheduler_config
|
||||
@@ -1279,7 +1272,6 @@ class GPUModelRunner(
|
||||
block_ids=new_req_data.block_ids,
|
||||
num_computed_tokens=new_req_data.num_computed_tokens,
|
||||
output_token_ids=[],
|
||||
lora_request=new_req_data.lora_request,
|
||||
)
|
||||
self.requests[req_id] = req_state
|
||||
self.late_interaction_runner.register_request(req_id, pooling_params)
|
||||
@@ -2225,16 +2217,6 @@ class GPUModelRunner(
|
||||
self.num_decode_draft_tokens.np[num_reqs:].fill(-1)
|
||||
self.num_decode_draft_tokens.copy_to_gpu()
|
||||
|
||||
# Hot-Swap lora model
|
||||
if self.lora_config:
|
||||
assert (
|
||||
np.sum(num_sampled_tokens)
|
||||
<= self.vllm_config.scheduler_config.max_num_batched_tokens
|
||||
)
|
||||
self.set_active_loras(
|
||||
self.input_batch, num_scheduled_tokens, num_sampled_tokens
|
||||
)
|
||||
|
||||
return (
|
||||
logits_indices,
|
||||
spec_decode_metadata,
|
||||
@@ -2731,10 +2713,10 @@ class GPUModelRunner(
|
||||
inputs.
|
||||
|
||||
Returns:
|
||||
A tuple of (mm_hashes, mm_kwargs, mm_lora_refs) where:
|
||||
A tuple of (mm_hashes, mm_kwargs, mm_req_refs) where:
|
||||
- mm_hashes: List of multimodal hashes for each item
|
||||
- mm_kwargs: List of multimodal kwargs for each item
|
||||
- mm_lora_refs: List of (req_id, placeholder_range) for each item
|
||||
- mm_req_refs: List of (req_id, placeholder_range) for each item
|
||||
|
||||
"""
|
||||
scheduled_encoder_inputs = scheduler_output.scheduled_encoder_inputs
|
||||
@@ -2743,9 +2725,9 @@ class GPUModelRunner(
|
||||
|
||||
mm_hashes = list[str]()
|
||||
mm_kwargs = list[tuple[str, MultiModalKwargsItem]]()
|
||||
# Multimodal LoRA reference info to map each multimodal item
|
||||
# Multimodal reference info to map each multimodal item
|
||||
# back to its request & position
|
||||
mm_lora_refs = list[tuple[str, PlaceholderRange]]()
|
||||
mm_req_refs = list[tuple[str, PlaceholderRange]]()
|
||||
for req_id, encoder_input_ids in scheduled_encoder_inputs.items():
|
||||
req_state = self.requests[req_id]
|
||||
|
||||
@@ -2756,7 +2738,7 @@ class GPUModelRunner(
|
||||
|
||||
mm_hashes.append(mm_feature.identifier)
|
||||
mm_kwargs.append((mm_feature.modality, mm_feature.data))
|
||||
mm_lora_refs.append((req_id, mm_feature.mm_position))
|
||||
mm_req_refs.append((req_id, mm_feature.mm_position))
|
||||
|
||||
# Stable-sort by modality so each modality is encoded in as few batches
|
||||
# as possible. Encoder outputs are cached by mm_hash, so order is free.
|
||||
@@ -2764,7 +2746,7 @@ class GPUModelRunner(
|
||||
return (
|
||||
[mm_hashes[i] for i in order],
|
||||
[mm_kwargs[i] for i in order],
|
||||
[mm_lora_refs[i] for i in order],
|
||||
[mm_req_refs[i] for i in order],
|
||||
)
|
||||
|
||||
def _cache_encoder_output(
|
||||
@@ -2782,7 +2764,7 @@ class GPUModelRunner(
|
||||
def _execute_mm_encoder(
|
||||
self, scheduler_output: "SchedulerOutput"
|
||||
) -> list[torch.Tensor]:
|
||||
mm_hashes, mm_kwargs, mm_lora_refs = self._batch_mm_inputs_from_scheduler(
|
||||
mm_hashes, mm_kwargs, mm_req_refs = self._batch_mm_inputs_from_scheduler(
|
||||
scheduler_output
|
||||
)
|
||||
|
||||
@@ -2810,13 +2792,11 @@ class GPUModelRunner(
|
||||
scheduler_output.ec_manager_metadata,
|
||||
scheduler_output.free_encoder_mm_hashes,
|
||||
)
|
||||
# Filter out `prompt_embeds` items from mm_kwargs/mm_hashes/mm_lora_refs
|
||||
# Filter out `prompt_embeds` items from mm_kwargs/mm_hashes/mm_req_refs
|
||||
# since they don't require further encoder processing.
|
||||
mm_hashes = [h for i, h in enumerate(mm_hashes) if i not in pe_indices]
|
||||
mm_kwargs = [k for i, k in enumerate(mm_kwargs) if i not in pe_indices]
|
||||
mm_lora_refs = [
|
||||
r for i, r in enumerate(mm_lora_refs) if i not in pe_indices
|
||||
]
|
||||
mm_req_refs = [r for i, r in enumerate(mm_req_refs) if i not in pe_indices]
|
||||
if not mm_kwargs:
|
||||
return [] # nothing left to encode after filtering out `prompt_embeds`
|
||||
|
||||
@@ -2828,76 +2808,8 @@ class GPUModelRunner(
|
||||
|
||||
model = cast(SupportsMultiModal, self.model)
|
||||
|
||||
if self.lora_config and self.lora_manager.supports_tower_connector_lora():
|
||||
# Build LoRA mappings independently for encoder inputs
|
||||
# (encoder batch structure is different from main batch)
|
||||
prompt_lora_mapping = []
|
||||
token_lora_mapping = []
|
||||
lora_requests = set()
|
||||
encoder_token_counts = []
|
||||
connector_token_counts = []
|
||||
|
||||
for (req_id, pos_info), (modality, mm_item) in zip(
|
||||
mm_lora_refs,
|
||||
mm_kwargs,
|
||||
):
|
||||
req_idx = self.input_batch.req_id_to_index[req_id]
|
||||
lora_id = int(self.input_batch.request_lora_mapping[req_idx])
|
||||
|
||||
tower_tokens, connector_tokens = self.model.get_mm_lora_token_counts( # type: ignore[attr-defined]
|
||||
modality=modality,
|
||||
mm_kwargs=mm_item,
|
||||
num_mm_embeds=pos_info.get_num_embeds(),
|
||||
)
|
||||
prompt_lora_mapping.append(lora_id)
|
||||
token_lora_mapping.extend([lora_id] * tower_tokens)
|
||||
encoder_token_counts.append(tower_tokens)
|
||||
connector_token_counts.append(connector_tokens)
|
||||
|
||||
if lora_id > 0:
|
||||
lora_request = self.input_batch.lora_id_to_lora_request.get(lora_id)
|
||||
if lora_request is not None:
|
||||
lora_requests.add(lora_request)
|
||||
|
||||
# Set tower adapter mapping
|
||||
tower_mapping = LoRAMapping(
|
||||
tuple(token_lora_mapping),
|
||||
tuple(prompt_lora_mapping),
|
||||
is_prefill=True,
|
||||
type=LoRAMappingType.TOWER,
|
||||
)
|
||||
self.lora_manager.set_active_adapters(lora_requests, tower_mapping)
|
||||
|
||||
# Only set connector mapping if the model actually has a connector
|
||||
# and reports connector token counts.
|
||||
mm_mapping = (
|
||||
self.model.get_mm_mapping() # type: ignore[attr-defined]
|
||||
if hasattr(self.model, "get_mm_mapping")
|
||||
else None
|
||||
)
|
||||
if (
|
||||
mm_mapping is not None
|
||||
and mm_mapping.connector
|
||||
and all(count is not None for count in connector_token_counts)
|
||||
):
|
||||
connector_token_mapping = np.repeat(
|
||||
np.array(prompt_lora_mapping, dtype=np.int32),
|
||||
np.array(connector_token_counts, dtype=np.int32),
|
||||
)
|
||||
connector_mapping = LoRAMapping(
|
||||
index_mapping=tuple(connector_token_mapping.tolist()),
|
||||
prompt_mapping=tuple(prompt_lora_mapping),
|
||||
is_prefill=True,
|
||||
type=LoRAMappingType.CONNECTOR,
|
||||
)
|
||||
|
||||
self.lora_manager.set_active_adapters(
|
||||
lora_requests,
|
||||
connector_mapping,
|
||||
)
|
||||
|
||||
encoder_outputs: list[torch.Tensor] = []
|
||||
# Track the current index in mm_kwargs/mm_lora_refs to map groups to request IDs
|
||||
# Track the current index in mm_kwargs/mm_req_refs to map groups to request IDs
|
||||
current_item_idx = 0
|
||||
for modality, num_items, mm_kwargs_batch in group_and_batch_mm_kwargs(
|
||||
mm_kwargs, device=self.device, pin_memory=PIN_MEMORY
|
||||
@@ -2928,7 +2840,7 @@ class GPUModelRunner(
|
||||
for video_idx in range(num_items):
|
||||
video_mm_kwargs_item = mm_kwargs[current_item_idx + video_idx]
|
||||
with self.timed_encoder_operation(
|
||||
should_time, mm_lora_refs, current_item_idx + video_idx, 1
|
||||
should_time, mm_req_refs, current_item_idx + video_idx, 1
|
||||
):
|
||||
_, _, micro_batch_mm_inputs = next(
|
||||
group_and_batch_mm_kwargs(
|
||||
@@ -2955,7 +2867,7 @@ class GPUModelRunner(
|
||||
# size is dynamic depending on the input multimodal items.
|
||||
|
||||
with self.timed_encoder_operation(
|
||||
should_time, mm_lora_refs, current_item_idx, num_items
|
||||
should_time, mm_req_refs, current_item_idx, num_items
|
||||
):
|
||||
cudagraph_output = None
|
||||
if (
|
||||
@@ -3132,15 +3044,6 @@ class GPUModelRunner(
|
||||
if is_text_generation_model(model):
|
||||
supported_tasks.append("generate")
|
||||
|
||||
if supports_transcription(model):
|
||||
if model.supports_transcription_only:
|
||||
return ["transcription"]
|
||||
|
||||
supported_tasks.append("transcription")
|
||||
|
||||
if supports_realtime(model):
|
||||
supported_tasks.append("realtime")
|
||||
|
||||
return supported_tasks
|
||||
|
||||
def get_supported_pooling_tasks(self) -> list[PoolingTask]:
|
||||
@@ -3723,8 +3626,6 @@ class GPUModelRunner(
|
||||
# For cudagraph capture TODO(lucas): Refactor how we capture cudagraphs (will
|
||||
# be improved in model runner v2)
|
||||
force_uniform_decode: bool | None = None,
|
||||
force_has_lora: bool | None = None,
|
||||
force_num_active_loras: int | None = None,
|
||||
num_encoder_reqs: int = 0,
|
||||
) -> tuple[
|
||||
CUDAGraphMode,
|
||||
@@ -3746,20 +3647,10 @@ class GPUModelRunner(
|
||||
self.model_config.is_encoder_decoder and num_encoder_reqs > 0
|
||||
)
|
||||
|
||||
# Compute LoRA state for cudagraph dispatch
|
||||
num_active_loras = (
|
||||
force_num_active_loras
|
||||
if force_num_active_loras is not None
|
||||
else len(self.input_batch.lora_id_to_lora_request)
|
||||
)
|
||||
has_lora = num_active_loras > 0 if force_has_lora is None else force_has_lora
|
||||
|
||||
def dispatch_cudagraph(num_tokens, disable_full=False, valid_modes=None):
|
||||
return self.cudagraph_dispatcher.dispatch(
|
||||
num_tokens=num_tokens,
|
||||
has_lora=has_lora,
|
||||
uniform_decode=uniform_decode,
|
||||
num_active_loras=num_active_loras,
|
||||
valid_modes={CUDAGraphMode.NONE} if force_eager else valid_modes,
|
||||
invalid_modes={CUDAGraphMode.FULL} if disable_full else None,
|
||||
)
|
||||
@@ -5031,10 +4922,6 @@ class GPUModelRunner(
|
||||
self.lookback_token_ids = self._make_buffer(
|
||||
self.max_num_reqs, lookback_depth, dtype=torch.int32
|
||||
)
|
||||
if self.lora_config:
|
||||
self.model = self.load_lora_model(
|
||||
self.model, self.vllm_config, self.device
|
||||
)
|
||||
if hasattr(self, "drafter"):
|
||||
logger.info_once("Loading drafter model...")
|
||||
if hasattr(self.drafter, "load_model"):
|
||||
@@ -5267,7 +5154,6 @@ class GPUModelRunner(
|
||||
weights_path=weights_path,
|
||||
is_checkpoint_format=is_checkpoint_format,
|
||||
)
|
||||
self.reset_lora_state()
|
||||
self.reset_encoder_cache()
|
||||
self.reset_mm_cache()
|
||||
|
||||
@@ -5483,9 +5369,7 @@ class GPUModelRunner(
|
||||
skip_eplb: bool = False,
|
||||
is_profile: bool = False,
|
||||
create_mixed_batch: bool = False,
|
||||
remove_lora: bool = True,
|
||||
is_graph_capturing: bool = False,
|
||||
num_active_loras: int = 0,
|
||||
profile_seq_lens: int | None = None,
|
||||
randomize_inputs: bool = False,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
@@ -5508,9 +5392,6 @@ class GPUModelRunner(
|
||||
is_profile: If True, this is a profile run.
|
||||
create_mixed_batch: If True, create a mixed batch with both decode
|
||||
(1 token) and prefill (multiple tokens) requests.
|
||||
remove_lora: If False, dummy LoRAs are not destroyed after the run
|
||||
num_active_loras: Number of distinct active LoRAs to capture for.
|
||||
LoRA is activated when num_active_loras > 0.
|
||||
profile_seq_lens: If provided, use this value for seq_lens instead
|
||||
of max_query_len. Used to profile attention workspace that
|
||||
scales with context length.
|
||||
@@ -5548,7 +5429,7 @@ class GPUModelRunner(
|
||||
max_query_len = self.uniform_decode_query_len if uniform_decode else num_tokens
|
||||
|
||||
# Set num_scheduled_tokens based on num_tokens and max_num_seqs
|
||||
# for dummy run with LoRA so that the num_reqs collectively
|
||||
# for dummy run so that the num_reqs collectively
|
||||
# has num_tokens in total.
|
||||
assert num_tokens <= self.max_num_tokens
|
||||
max_num_reqs = self.scheduler_config.max_num_seqs
|
||||
@@ -5581,8 +5462,6 @@ class GPUModelRunner(
|
||||
num_scheduled_tokens = np.array(num_scheduled_tokens_list, dtype=np.int32)
|
||||
num_tokens_unpadded = int(num_scheduled_tokens.sum())
|
||||
|
||||
num_sampled_tokens = np.ones(num_reqs, dtype=np.int32)
|
||||
|
||||
_cudagraph_mode, batch_desc, should_ubatch, num_tokens_across_dp, _ = (
|
||||
self._determine_batch_execution_and_padding(
|
||||
num_tokens=num_tokens_unpadded,
|
||||
@@ -5598,13 +5477,6 @@ class GPUModelRunner(
|
||||
# num_tokens == num_reqs which looks like a uniform decode batch to the
|
||||
# dispatcher; but we actually want to capture a piecewise cudagraph
|
||||
force_uniform_decode=uniform_decode,
|
||||
# `force_has_lora` is used for cudagraph capture; because LoRA is
|
||||
# activated later in the context manager, but we need to know the
|
||||
# LoRA state when determining the batch descriptor for capture
|
||||
force_has_lora=num_active_loras > 0,
|
||||
# `force_num_active_loras` is used for cudagraph capture; because we
|
||||
# need to capture graphs for specific num_active_loras counts
|
||||
force_num_active_loras=num_active_loras,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5733,138 +5605,117 @@ class GPUModelRunner(
|
||||
use_spec_decode=self.speculative_config is not None,
|
||||
)
|
||||
|
||||
with self.maybe_dummy_run_with_lora(
|
||||
self.lora_config,
|
||||
num_scheduled_tokens,
|
||||
num_sampled_tokens,
|
||||
remove_lora,
|
||||
num_active_loras,
|
||||
):
|
||||
# Make sure padding doesn't exceed max_num_tokens
|
||||
assert num_tokens_padded <= self.max_num_tokens
|
||||
# Make sure padding doesn't exceed max_num_tokens
|
||||
assert num_tokens_padded <= self.max_num_tokens
|
||||
model_kwargs = self._init_model_kwargs(num_reqs=0)
|
||||
if self.supports_mm_inputs and not self.model_config.is_encoder_decoder:
|
||||
input_ids, inputs_embeds = self._prepare_mm_inputs(num_tokens_padded)
|
||||
|
||||
model_kwargs = {
|
||||
**model_kwargs,
|
||||
**self._dummy_mm_kwargs(num_reqs),
|
||||
}
|
||||
elif self.enable_prompt_embeds:
|
||||
input_ids = None
|
||||
inputs_embeds = self.inputs_embeds.gpu[:num_tokens_padded]
|
||||
model_kwargs = self._init_model_kwargs(num_reqs=0)
|
||||
if self.supports_mm_inputs and not self.model_config.is_encoder_decoder:
|
||||
input_ids, inputs_embeds = self._prepare_mm_inputs(num_tokens_padded)
|
||||
else:
|
||||
input_ids = self.input_ids.gpu[:num_tokens_padded]
|
||||
inputs_embeds = None
|
||||
|
||||
model_kwargs = {
|
||||
**model_kwargs,
|
||||
**self._dummy_mm_kwargs(num_reqs),
|
||||
}
|
||||
elif self.enable_prompt_embeds:
|
||||
input_ids = None
|
||||
inputs_embeds = self.inputs_embeds.gpu[:num_tokens_padded]
|
||||
model_kwargs = self._init_model_kwargs(num_reqs=0)
|
||||
else:
|
||||
input_ids = self.input_ids.gpu[:num_tokens_padded]
|
||||
inputs_embeds = None
|
||||
if self.uses_mrope:
|
||||
positions = self.mrope_positions.gpu[:, :num_tokens_padded]
|
||||
else:
|
||||
positions = self.positions[:num_tokens_padded]
|
||||
|
||||
if self.uses_mrope:
|
||||
positions = self.mrope_positions.gpu[:, :num_tokens_padded]
|
||||
else:
|
||||
positions = self.positions[:num_tokens_padded]
|
||||
|
||||
if get_pp_group().is_first_rank:
|
||||
intermediate_tensors = None
|
||||
else:
|
||||
if self.intermediate_tensors is None:
|
||||
self.intermediate_tensors = (
|
||||
self.model.make_empty_intermediate_tensors(
|
||||
batch_size=self.max_num_tokens,
|
||||
dtype=self.model_config.dtype,
|
||||
device=self.device,
|
||||
)
|
||||
)
|
||||
|
||||
intermediate_tensors = self.sync_and_gather_intermediate_tensors(
|
||||
num_tokens_padded, None, False
|
||||
if get_pp_group().is_first_rank:
|
||||
intermediate_tensors = None
|
||||
else:
|
||||
if self.intermediate_tensors is None:
|
||||
self.intermediate_tensors = self.model.make_empty_intermediate_tensors(
|
||||
batch_size=self.max_num_tokens,
|
||||
dtype=self.model_config.dtype,
|
||||
device=self.device,
|
||||
)
|
||||
|
||||
num_tokens_unpadded = num_tokens_padded if is_profile else 0
|
||||
is_padding = self._prepare_padding_mask(
|
||||
num_tokens_unpadded, num_tokens_padded
|
||||
intermediate_tensors = self.sync_and_gather_intermediate_tensors(
|
||||
num_tokens_padded, None, False
|
||||
)
|
||||
|
||||
if ubatch_slices_padded is not None:
|
||||
# Adjust values to reflect a single ubatch.
|
||||
# TODO(sage,lucas): this is cruft that should be addressed in
|
||||
# the padding refactor.
|
||||
num_tokens_padded = ubatch_slices_padded[0].num_tokens
|
||||
if num_tokens_across_dp is not None:
|
||||
num_tokens_across_dp[:] = num_tokens_padded
|
||||
num_tokens_unpadded = num_tokens_padded if is_profile else 0
|
||||
is_padding = self._prepare_padding_mask(num_tokens_unpadded, num_tokens_padded)
|
||||
|
||||
with (
|
||||
self.maybe_randomize_inputs(
|
||||
input_ids, inputs_embeds, randomize_inputs=randomize_inputs
|
||||
),
|
||||
set_forward_context(
|
||||
attn_metadata,
|
||||
self.vllm_config,
|
||||
num_tokens=num_tokens_padded,
|
||||
num_tokens_across_dp=num_tokens_across_dp,
|
||||
cudagraph_runtime_mode=cudagraph_runtime_mode,
|
||||
batch_descriptor=batch_desc,
|
||||
ubatch_slices=ubatch_slices_padded,
|
||||
slot_mapping=slot_mappings,
|
||||
is_padding=is_padding,
|
||||
),
|
||||
):
|
||||
outputs = self.model(
|
||||
input_ids=input_ids,
|
||||
positions=positions,
|
||||
intermediate_tensors=intermediate_tensors,
|
||||
inputs_embeds=inputs_embeds,
|
||||
**model_kwargs,
|
||||
if ubatch_slices_padded is not None:
|
||||
# Adjust values to reflect a single ubatch.
|
||||
# TODO(sage,lucas): this is cruft that should be addressed in
|
||||
# the padding refactor.
|
||||
num_tokens_padded = ubatch_slices_padded[0].num_tokens
|
||||
if num_tokens_across_dp is not None:
|
||||
num_tokens_across_dp[:] = num_tokens_padded
|
||||
|
||||
with (
|
||||
self.maybe_randomize_inputs(
|
||||
input_ids, inputs_embeds, randomize_inputs=randomize_inputs
|
||||
),
|
||||
set_forward_context(
|
||||
attn_metadata,
|
||||
self.vllm_config,
|
||||
num_tokens=num_tokens_padded,
|
||||
num_tokens_across_dp=num_tokens_across_dp,
|
||||
cudagraph_runtime_mode=cudagraph_runtime_mode,
|
||||
batch_descriptor=batch_desc,
|
||||
ubatch_slices=ubatch_slices_padded,
|
||||
slot_mapping=slot_mappings,
|
||||
is_padding=is_padding,
|
||||
),
|
||||
):
|
||||
outputs = self.model(
|
||||
input_ids=input_ids,
|
||||
positions=positions,
|
||||
intermediate_tensors=intermediate_tensors,
|
||||
inputs_embeds=inputs_embeds,
|
||||
**model_kwargs,
|
||||
)
|
||||
|
||||
if self.use_aux_hidden_state_outputs:
|
||||
hidden_states, _ = outputs
|
||||
else:
|
||||
hidden_states = outputs
|
||||
|
||||
if self.speculative_config and (
|
||||
self.speculative_config.use_eagle()
|
||||
or self.speculative_config.uses_draft_model()
|
||||
or self.speculative_config.uses_extract_hidden_states()
|
||||
):
|
||||
assert isinstance(
|
||||
self.drafter,
|
||||
EagleProposer
|
||||
| DFlashProposer
|
||||
| DraftModelProposer
|
||||
| ExtractHiddenStatesProposer
|
||||
| Gemma4Proposer,
|
||||
)
|
||||
assert self.speculative_config is not None
|
||||
# Eagle currently only supports PIECEWISE cudagraphs.
|
||||
# Therefore only use cudagraphs if the main model uses PIECEWISE
|
||||
# NOTE(lucas): this is a hack, need to clean up.
|
||||
use_cudagraphs = (
|
||||
(
|
||||
is_graph_capturing
|
||||
and cudagraph_runtime_mode == CUDAGraphMode.PIECEWISE
|
||||
)
|
||||
|
||||
if self.use_aux_hidden_state_outputs:
|
||||
hidden_states, _ = outputs
|
||||
else:
|
||||
hidden_states = outputs
|
||||
|
||||
if self.speculative_config and (
|
||||
self.speculative_config.use_eagle()
|
||||
or self.speculative_config.uses_draft_model()
|
||||
or self.speculative_config.uses_extract_hidden_states()
|
||||
):
|
||||
assert isinstance(
|
||||
self.drafter,
|
||||
EagleProposer
|
||||
| DFlashProposer
|
||||
| DraftModelProposer
|
||||
| ExtractHiddenStatesProposer
|
||||
| Gemma4Proposer,
|
||||
or (
|
||||
not is_graph_capturing
|
||||
and cudagraph_runtime_mode != CUDAGraphMode.NONE
|
||||
)
|
||||
assert self.speculative_config is not None
|
||||
# Eagle currently only supports PIECEWISE cudagraphs.
|
||||
# Therefore only use cudagraphs if the main model uses PIECEWISE
|
||||
# NOTE(lucas): this is a hack, need to clean up.
|
||||
use_cudagraphs = (
|
||||
(
|
||||
is_graph_capturing
|
||||
and cudagraph_runtime_mode == CUDAGraphMode.PIECEWISE
|
||||
)
|
||||
or (
|
||||
not is_graph_capturing
|
||||
and cudagraph_runtime_mode != CUDAGraphMode.NONE
|
||||
)
|
||||
) and not self.speculative_config.enforce_eager
|
||||
) and not self.speculative_config.enforce_eager
|
||||
|
||||
# Note(gnovack) - We need to disable cudagraphs for one of the two
|
||||
# lora cases when cudagraph_specialize_lora is enabled. This is a
|
||||
# short term mitigation for issue mentioned in
|
||||
# https://github.com/vllm-project/vllm/issues/28334
|
||||
if (
|
||||
self.compilation_config.cudagraph_specialize_lora
|
||||
and num_active_loras > 0
|
||||
):
|
||||
use_cudagraphs = False
|
||||
|
||||
self.drafter.dummy_run(
|
||||
num_tokens,
|
||||
use_cudagraphs=use_cudagraphs,
|
||||
is_graph_capturing=is_graph_capturing,
|
||||
slot_mappings=slot_mappings,
|
||||
)
|
||||
self.drafter.dummy_run(
|
||||
num_tokens,
|
||||
use_cudagraphs=use_cudagraphs,
|
||||
is_graph_capturing=is_graph_capturing,
|
||||
slot_mappings=slot_mappings,
|
||||
)
|
||||
|
||||
# We register layerwise NVTX hooks here after the first dynamo tracing is
|
||||
# done to avoid nvtx operations in hook functions being traced by
|
||||
@@ -6422,7 +6273,6 @@ class GPUModelRunner(
|
||||
for key_set in self.cudagraph_dispatcher.cudagraph_keys.values():
|
||||
key_set.clear()
|
||||
self.cudagraph_dispatcher.keys_initialized = False
|
||||
self.maybe_remove_all_loras(self.lora_config)
|
||||
self._cleanup_profiling_kv_cache()
|
||||
compilation_counter.num_cudagraph_captured = saved_num_cudagraph_captured
|
||||
|
||||
@@ -6571,8 +6421,6 @@ class GPUModelRunner(
|
||||
uniform_decode=desc.uniform,
|
||||
allow_microbatching=allow_microbatching,
|
||||
skip_eplb=True,
|
||||
remove_lora=False,
|
||||
num_active_loras=desc.num_active_loras,
|
||||
profile_seq_lens=profile_seq_lens,
|
||||
)
|
||||
if num_warmups > 0:
|
||||
@@ -6591,8 +6439,6 @@ class GPUModelRunner(
|
||||
uniform_decode=desc.uniform,
|
||||
allow_microbatching=allow_microbatching,
|
||||
skip_eplb=True,
|
||||
remove_lora=False,
|
||||
num_active_loras=desc.num_active_loras,
|
||||
is_graph_capturing=True,
|
||||
profile_seq_lens=profile_seq_lens,
|
||||
)
|
||||
@@ -6647,7 +6493,6 @@ class GPUModelRunner(
|
||||
profiler=profiler,
|
||||
)
|
||||
torch.accelerator.synchronize()
|
||||
self.maybe_remove_all_loras(self.lora_config)
|
||||
|
||||
def initialize_attn_backend(
|
||||
self,
|
||||
@@ -7180,7 +7025,7 @@ class GPUModelRunner(
|
||||
def timed_encoder_operation(
|
||||
self,
|
||||
should_time: bool,
|
||||
group_lora_refs: list[tuple[str, Any]],
|
||||
group_req_refs: list[tuple[str, Any]],
|
||||
current_item_idx: int,
|
||||
num_items: int,
|
||||
):
|
||||
@@ -7188,7 +7033,7 @@ class GPUModelRunner(
|
||||
|
||||
Args:
|
||||
should_time: Whether timing is enabled
|
||||
group_lora_refs: Full list of (request_id, pos_info) tuples
|
||||
group_req_refs: Full list of (request_id, pos_info) tuples
|
||||
current_item_idx: Starting index for this group
|
||||
num_items: Number of items in this group
|
||||
|
||||
@@ -7197,7 +7042,7 @@ class GPUModelRunner(
|
||||
yield
|
||||
return
|
||||
|
||||
group_refs = group_lora_refs[current_item_idx : current_item_idx + num_items]
|
||||
group_refs = group_req_refs[current_item_idx : current_item_idx + num_items]
|
||||
group_request_ids = {req_id for req_id, _ in group_refs}
|
||||
|
||||
torch.accelerator.synchronize()
|
||||
|
||||
Reference in New Issue
Block a user