[EC Connector] Added Build Connector Worker Meta for EC Connector (#49585)
Signed-off-by: yewentao256 <zhyanwentao@126.com> Signed-off-by: omerpaz95 <omerpaz95@gmail.com> Signed-off-by: omerpaz95 <73347585+omerpaz95@users.noreply.github.com> Co-authored-by: yewentao256 <zhyanwentao@126.com> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
This commit is contained in:
co-authored by
yewentao256
Wentao Ye
parent
c94cdd0ae0
commit
fa9d67f782
@@ -9,7 +9,11 @@ import torch
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.distributed.ec_transfer import get_ec_transfer, has_ec_transfer
|
||||
from vllm.distributed.ec_transfer.ec_connector.base import ECConnectorBase
|
||||
from vllm.v1.outputs import ECConnectorOutput
|
||||
from vllm.v1.outputs import (
|
||||
EMPTY_MODEL_RUNNER_OUTPUT,
|
||||
ECConnectorOutput,
|
||||
ModelRunnerOutput,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.v1.core.sched.output import SchedulerOutput
|
||||
@@ -25,6 +29,12 @@ class ECConnector:
|
||||
) -> Generator[ECConnectorOutput | None, None, None]:
|
||||
yield None
|
||||
|
||||
def no_forward(
|
||||
self,
|
||||
scheduler_output: "SchedulerOutput",
|
||||
) -> ModelRunnerOutput:
|
||||
return EMPTY_MODEL_RUNNER_OUTPUT
|
||||
|
||||
|
||||
class ActiveECConnector(ECConnector):
|
||||
def __init__(
|
||||
@@ -33,9 +43,11 @@ class ActiveECConnector(ECConnector):
|
||||
encoder_cache: dict[str, torch.Tensor],
|
||||
) -> None:
|
||||
self.encoder_cache = encoder_cache
|
||||
self.save_new_caches = vllm_config.is_ec_producer_only
|
||||
self.ec_connector = get_ec_transfer()
|
||||
assert isinstance(self.ec_connector, ECConnectorBase)
|
||||
# Every producer offloads freshly computed encoder outputs, including
|
||||
# an ec_both node that also reloads them.
|
||||
self.save_new_caches = self.ec_connector.is_producer
|
||||
|
||||
@contextmanager
|
||||
def maybe_get_output(
|
||||
@@ -65,8 +77,19 @@ class ActiveECConnector(ECConnector):
|
||||
output.finished_sending, output.finished_recving = (
|
||||
ec_connector.get_finished(scheduler_output.finished_req_ids)
|
||||
)
|
||||
output.ec_connector_worker_meta = ec_connector.build_connector_worker_meta()
|
||||
ec_connector.clear_connector_metadata()
|
||||
|
||||
def no_forward(
|
||||
self,
|
||||
scheduler_output: "SchedulerOutput",
|
||||
) -> ModelRunnerOutput:
|
||||
# EC send/recv even if no work to do.
|
||||
with self.maybe_get_output(scheduler_output) as ec_connector_output:
|
||||
pass
|
||||
|
||||
return ModelRunnerOutput.with_ec_conn_output_only(ec_connector_output)
|
||||
|
||||
|
||||
NO_OP_EC_CONNECTOR = ECConnector()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user