Skip to content

Commit 37fa4c0

Browse files
committed
refactor: drop worker passthroughs that duplicate upstream
NPUWorker overrides several worker RPC methods whose implementation is already identical in upstream vllm/v1/worker/gpu_worker.py::Worker. I audited every method on the class against the effective upstream implementation (gpu_worker.Worker, falling back to WorkerBase) on both supported vLLM lanes - v0.33.0 and the pinned main commit c410543d - with an AST comparison, and deleted the ones that only restate the upstream delegation to self.model_runner: - add_lora / remove_lora / list_loras / pin_lora: byte-identical bodies - get_model / reset_encoder_cache / take_draft_token_ids: byte-identical - get_supported_tasks: body and decorators identical, the only difference was a redundant quoted return annotation The LoRA feature itself, the punica wrapper, the model-runner implementation and every Ascend-specific override stay untouched; the deleted methods keep resolving to the same code through inheritance. The imports that only those methods used (LoRARequest, SupportedTask, DraftTokenIds) go away with them. Methods that look like pass-throughs but differ from upstream on at least one lane were deliberately kept, e.g. reset_mm_cache (tolerates runners without the method), synchronize_device (torch.npu.synchronize), sample_tokens (no with_gpu_sync_check) and reload_weights. Static checks only: ruff check, ruff format --check and py_compile pass on vllm_ascend/worker/worker.py. Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
1 parent 7fcd509 commit 37fa4c0

1 file changed

Lines changed: 1 addition & 27 deletions

File tree

‎vllm_ascend/worker/worker.py‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@
5151
from vllm.distributed.kv_transfer.kv_connector.v1.base import KVConnectorHandshakeMetadata
5252
from vllm.distributed.parallel_state import get_pp_group, get_tp_group
5353
from vllm.logger import logger
54-
from vllm.lora.request import LoRARequest
5554
from vllm.model_executor.model_loader.weight_checksum import compute_tensor_digests, zero_weights
5655
from vllm.platforms import current_platform
5756
from vllm.sequence import IntermediateTensors
58-
from vllm.tasks import SupportedTask
5957
from vllm.utils.mem_constants import GiB_bytes
6058
from vllm.utils.mem_utils import MemorySnapshot, format_gib, memory_profiling
6159
from vllm.utils.torch_utils import STR_DTYPE_TO_TORCH_DTYPE
@@ -71,7 +69,7 @@
7169
SlidingWindowSpec,
7270
UniformTypeKVCacheSpecs,
7371
)
74-
from vllm.v1.outputs import EMPTY_MODEL_RUNNER_OUTPUT, AsyncModelRunnerOutput, DraftTokenIds, ModelRunnerOutput
72+
from vllm.v1.outputs import EMPTY_MODEL_RUNNER_OUTPUT, AsyncModelRunnerOutput, ModelRunnerOutput
7573
from vllm.v1.utils import report_usage_stats
7674
from vllm.v1.worker import gpu_worker
7775
from vllm.v1.worker.gpu_worker import AsyncIntermediateTensors
@@ -1169,9 +1167,6 @@ def _warm_up_atb(self):
11691167
c = torch.rand((4, 4), dtype=torch.float32).npu()
11701168
torch_npu._npu_matmul_add_fp32(x, weight, c)
11711169

1172-
def get_model(self) -> nn.Module:
1173-
return self.model_runner.get_model()
1174-
11751170
def _weight_checksum_model(self) -> nn.Module:
11761171
# The v1 model runner exposes get_model(); the v2 runner (still under
11771172
# development) only exposes the model attribute.
@@ -1360,21 +1355,6 @@ def profile(
13601355
return
13611356
profiler.stop()
13621357

1363-
def add_lora(self, lora_request: LoRARequest) -> bool:
1364-
return self.model_runner.add_lora(lora_request)
1365-
1366-
def remove_lora(self, lora_id: int) -> bool:
1367-
return self.model_runner.remove_lora(lora_id)
1368-
1369-
def list_loras(self) -> set[int]:
1370-
return self.model_runner.list_loras()
1371-
1372-
def pin_lora(self, lora_id: int) -> bool:
1373-
return self.model_runner.pin_lora(lora_id)
1374-
1375-
def reset_encoder_cache(self) -> None:
1376-
self.model_runner.reset_encoder_cache()
1377-
13781358
def synchronize_device(self) -> None:
13791359
torch.npu.synchronize()
13801360

@@ -1439,12 +1419,6 @@ def _init_worker_distributed_environment(self) -> None:
14391419
def get_supported_pooling_tasks(self):
14401420
return self.model_runner.get_supported_pooling_tasks()
14411421

1442-
def get_supported_tasks(self) -> "tuple[SupportedTask, ...]":
1443-
return self.model_runner.get_supported_tasks()
1444-
1445-
def take_draft_token_ids(self) -> DraftTokenIds | None:
1446-
return self.model_runner.take_draft_token_ids()
1447-
14481422
def update_config(self, overrides: dict[str, Any]) -> None:
14491423
self.model_runner.update_config(overrides)
14501424

0 commit comments

Comments
 (0)