[1/2][Model Runner V2] DBO support, eager mode (#50945)
Signed-off-by: specture724 <specture724@gmail.com> Signed-off-by: Anjie Hou <149605198+specture724@users.noreply.github.com> Co-authored-by: jiangkuaixue123 <jiangxiaozhou111@163.com> Co-authored-by: Lucas Wilkinson <lwilkins@redhat.com>
This commit is contained in:
co-authored by
jiangkuaixue123
Lucas Wilkinson
parent
784cac7c42
commit
3f41d102c5
@@ -161,6 +161,11 @@ from vllm.v1.worker.gpu.spec_decode.speculator import DraftModelSpeculator
|
||||
from vllm.v1.worker.gpu.spec_decode.utils import DraftTokensHandler
|
||||
from vllm.v1.worker.gpu.states import RequestState
|
||||
from vllm.v1.worker.gpu.structured_outputs import StructuredOutputsWorker
|
||||
from vllm.v1.worker.gpu.ubatch_utils import (
|
||||
UBatchRunner,
|
||||
UBatchState,
|
||||
maybe_build_ubatch_runner,
|
||||
)
|
||||
from vllm.v1.worker.lora_model_runner_mixin import LoRAModelRunnerMixin
|
||||
from vllm.v1.worker.utils import (
|
||||
KVBlockZeroer,
|
||||
@@ -230,6 +235,10 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
self.dp_size = self.parallel_config.data_parallel_size
|
||||
self.dp_rank = self.parallel_config.data_parallel_rank
|
||||
|
||||
# Dual batch overlap. Created in initialize_kv_cache(), once everything
|
||||
# it runs the microbatched forward with exists.
|
||||
self.ubatch_runner: UBatchRunner | None = None
|
||||
|
||||
# Detect EP all2all peer faults to prevent emitting corrupted output.
|
||||
# Only meaningful for MoE + DP with an FT-capable all2all backend.
|
||||
self.check_ep_fault = False
|
||||
@@ -634,6 +643,14 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
self.block_tables,
|
||||
cls=self.pcp_manager_cls,
|
||||
)
|
||||
self.ubatch_runner = maybe_build_ubatch_runner(
|
||||
self.vllm_config,
|
||||
self.device,
|
||||
self.model_state,
|
||||
self.attn_groups,
|
||||
self.kv_cache_config,
|
||||
self.max_num_reqs,
|
||||
)
|
||||
initialize_mamba_ssu_backend(
|
||||
self.vllm_config.mamba_config,
|
||||
self.kv_cache_config,
|
||||
@@ -1597,6 +1614,11 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
max_query_len=max_query_len,
|
||||
need_eager=is_profile or skip_compiled,
|
||||
num_active_loras=num_active_loras,
|
||||
parallel_config=self.parallel_config,
|
||||
allow_ubatching=(
|
||||
self.ubatch_runner is not None and not skip_attn_for_dummy_run
|
||||
),
|
||||
uniform_decode=uniform_tok_count == self.decode_query_len,
|
||||
)
|
||||
|
||||
if batch_desc.num_tokens == 0:
|
||||
@@ -1665,7 +1687,14 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
|
||||
attn_metadata = None
|
||||
slot_mappings_by_layer = None
|
||||
if not (dummy_run and skip_attn_for_dummy_run):
|
||||
ubatch_state: UBatchState | None = None
|
||||
if batch_desc.num_ubatches > 1:
|
||||
assert self.ubatch_runner is not None
|
||||
assert block_tables is not None and slot_mappings is not None
|
||||
ubatch_state = self.ubatch_runner.prepare(
|
||||
input_batch, block_tables, slot_mappings
|
||||
)
|
||||
elif not (dummy_run and skip_attn_for_dummy_run):
|
||||
assert slot_mappings is not None
|
||||
slot_mappings_by_layer = build_slot_mappings_by_layer(
|
||||
slot_mappings, self.kv_cache_config
|
||||
@@ -1751,7 +1780,10 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
del intermediate_tensors
|
||||
|
||||
# Update the EPLB meta.
|
||||
self.eplb.prepare_forward(self.model_config, input_batch.num_tokens)
|
||||
ubatch_slices = ubatch_state.slices if ubatch_state is not None else None
|
||||
self.eplb.prepare_forward(
|
||||
self.model_config, input_batch.num_tokens, ubatch_slices
|
||||
)
|
||||
|
||||
self.step_timing.record_batch(
|
||||
input_batch, batch_desc.cg_mode == CUDAGraphMode.FULL
|
||||
@@ -1783,12 +1815,18 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
dp_sync.num_tokens_across_dp if dp_sync is not None else None
|
||||
),
|
||||
batch_descriptor=batch_descriptor,
|
||||
ubatch_slices=ubatch_slices,
|
||||
slot_mapping=slot_mappings_by_layer,
|
||||
skip_compiled=skip_compiled,
|
||||
is_padding=input_batch.is_padding,
|
||||
):
|
||||
self.kv_connector.pre_forward(scheduler_output)
|
||||
if batch_desc.cg_mode == CUDAGraphMode.PIECEWISE:
|
||||
if ubatch_state is not None:
|
||||
assert self.ubatch_runner is not None
|
||||
model_output = self.ubatch_runner.run(
|
||||
self.model, model_inputs, ubatch_state
|
||||
)
|
||||
elif batch_desc.cg_mode == CUDAGraphMode.PIECEWISE:
|
||||
# Run the PIECEWISE graph (compiled PW cudagraph or breakable
|
||||
# cudagraph, chosen inside run_pw_graph). cg_mode is only
|
||||
# PIECEWISE after the cudagraph manager exists.
|
||||
|
||||
Reference in New Issue
Block a user