Repository navigation
[Refactor] Drop worker overrides that duplicate upstream - #23047
Ronald1995 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes LoRA-related methods (add_lora, remove_lora, list_loras, and pin_lora) and the unused LoRARequest import from the Ascend worker implementation in vllm_ascend/worker/worker.py. I have no feedback to provide on these changes.
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. 🤖 How to trigger CI
Note Until the CI gate has run on a commit, the required |
932497f to
37fa4c0
Compare
Coverage
More info see: Summary |
NPUWorker overrides a set of worker RPCs that upstream vllm/v1/worker/gpu_worker.py::Worker already implements with the same behavior. Every method declared on the class was audited 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 a normalized AST comparison. The methods deleted here only restate upstream: - 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 - reset_mm_cache: upstream calls model_runner.reset_mm_cache() directly; the getattr/callable guard protected a runner shape that no longer exists - get_draft_model: was a NotImplementedError stub; every supported runner implements the accessor (MRv2 returns the speculator's draft model) - compute_weight_checksums / reset_weights: upstream reads the model via model_runner.get_model(), and MRv2's get_model() is literally "return self.model", so the local _weight_checksum_model() fallback was dead code. reset_weights keeps upstream's zero_weights() semantics but no longer logs the weight_nz_mode advisory; the NZ guard in the weight-update path (_check_nz_disabled) is untouched. Dead code that only those methods used goes away with them: the _weight_checksum_model() helper and the LoRARequest / SupportedTask / DraftTokenIds / compute_tensor_digests / zero_weights imports. Tests that asserted the removed behavior are dropped, and tests/ut/worker/test_worker_inheritance.py now asserts that these RPCs are inherited from gpu_worker.Worker. Static checks only: ruff check, ruff format --check and py_compile pass, and the audit re-runs to zero duplicated methods on both lanes. Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
37fa4c0 to
2e130de
Compare
zhenwenqi2024
left a comment
There was a problem hiding this comment.
Could we replace the get_draft_model inheritance assertion with a small behavior test that exercises both a configured draft-model speculator and no drafter? Unlike the LoRA delegates, this RPC used to raise on Ascend. The hardware check covers the new None result, but not that the RPC returns the actual draft module when configured. The other accessor checks can stay as they are.
The identity assertion for get_draft_model only pinned that NPUWorker resolves the RPC to the upstream method, but this RPC used to raise on Ascend, so review asked for behavior coverage of a configured drafter. Bind the upstream runner implementation that this RPC resolves to (Model Runner V2) and cover its three states: no speculator, a DraftModelSpeculator carrying a draft module, and a non-draft speculator. The draft module is returned by identity only in the configured case; the other two yield None. The identity checks for the remaining accessors stay unchanged. Verified on both supported vLLM lanes (v0.33.0 and main@c410543d) on NPU: 116 passed on each. Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
|
@zhenwenqi2024 thanks - done in 7d382db.
Ran on real NPU under both supported vLLM lanes (v0.33.0 tag and main@c410543d): 116 passed on each for Separately: the PR description had mojibake from a local encoding round-trip (BOM + cp1252 mangling of the em dashes). It is now rewritten clean (ASCII only, no BOM) and includes the A/B evidence on NPU: identical weight checksums, identical greedy generations with and without LoRA, identical LoRA lifecycle results, and identical post- |
|
Last updated: 2026-11-25 00:04 UTC+8 for commit ci-gate failed. Reason:
See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted). |
test_get_draft_model_reports_the_runner_drafter bound the speculator variable to MagicMock in the first parametrization branch, so assigning object() in the 'other-speculator' branch tripped mypy with 'Incompatible types in assignment (expression has type object, variable has type MagicMock)' on Python 3.10, 3.11 and 3.12, failing the pre-commit job and with it the ci-gate. Declare the object | None union before the branches and keep the mock in its own local so the attribute write stays typed. The generated objects are unchanged, so the test still exercises the same three drafter states. Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
|
/run |
|
/rerun Rerun (failed jobs only):
|
What this PR does / why we need it?
NPUWorkeroverrides a set of worker RPCs that upstreamvllm/v1/worker/gpu_worker.py::Workeralready implements with the same behavior. I audited every method declared on the class against the effective upstream implementation -gpu_worker.Worker, falling back toWorkerBasewhere the concrete worker does not override it - on both supported vLLM lanes, and deleted the ones that only restate upstream.Method: normalized AST comparison (
ast.dumpof eachFunctionDef, covering decorators, arguments, annotations, defaults and body) between the Ascend method and the upstream method that MRO resolves to once the override is removed, plus a second pass that compares bodies with annotations stripped to catch annotation-only copies.Deleted - 13 declarations, all pure delegation to upstream:
c410543dadd_lora,remove_lora,list_loras,pin_lorareturn self.model_runner.<m>(...)get_model,reset_encoder_cache,take_draft_token_idsget_supported_tasks"tuple[SupportedTask, ...]"differedreset_mm_cachemodel_runner.reset_mm_cache()directly; the localgetattr+callable()guard protected a runner shape that no longer existsget_draft_modelNotImplementedErrorstubcompute_weight_checksums,reset_weightsmodel_runner.get_model(); MRv2'sget_model()is literallyreturn self.model, so the local_weight_checksum_model()fallback was dead code_weight_checksum_model(private helper)Imports that only those methods used go away too:
LoRARequest,SupportedTask,DraftTokenIds, andcompute_tensor_digests/zero_weights.The only intended behavior change is
get_draft_model: the Ascend stub used to raiseNotImplementedError, and it now delegates to the runner like every other worker. Everything else is byte-for-byte equivalent, which the NPU runs below confirm. Two further notes:reset_weightsno longer logs theweight_nz_modeadvisory. The zeroing behavior is unchanged; the NZ guard that actually rejects unsupported usage (_check_nz_disabled, reached from_start_weight_update) is untouched..model-only runner shape is no longer supported by the weight-checker RPCs. No such runner exists: the upstream MRv2 runner definesget_model()returningself.modelon both lanes, and the v1 runner defines it too.The same audit listed pass-through-looking methods that do differ on at least one lane, so they are deliberately kept:
synchronize_device(torch.npu.synchronize()),sample_tokens(no@with_gpu_sync_check/@finish_iteration_timing),update_config,reload_weights,check_health,get_supported_pooling_tasks, and the remainingNotImplementedErrorstubs.Does this PR introduce any user-facing change?
No user-visible behavior change beyond removing one
NotImplementedErrorfrom a worker RPC that no engine path calls on Ascend. Internal refactor; no release note fragment needed.How was this patch tested?
On real NPU hardware, A/B, under both vLLM lanes (v0.33.0 tag and main@
c410543d), comparing the PR against its parent commit7fcd50906:7fcd50906(base) vs the PR head, selected viaPYTHONPATHenable_lora=True, eager,max_model_len=512, plus a small PEFT adapter (q_proj, r=8) generated for the testVLLM_ENABLE_V1_MULTIPROCESSING=0to reach the worker object in-process, andVLLM_BATCH_INVARIANT=1because the container's prebuilt custom-op set predates this tree (aclnnAddRmsNormBiasunavailable). Both settings are applied identically to base and PR, so the comparison is valid.7fcd50906compute_weight_checksums()over 226 tensors, sha256 of all digestsde0b7ab0...de0b7ab0...(identical)" Paris. The capital of France is also..."" Paris, and the capital of Italy is Rome..."add_lora/pin_lora/remove_lora/list_lorasTrue/True/False/[]get_model,get_supported_tasks,take_draft_token_ids,reset_encoder_cache,reset_mm_cacheQwen3ForCausalLM(151936x1024)/["generate"]/DraftTokenIds(req_ids=[], draft_token_ids=[])/None/Nonereset_weights()-> all params zero + post-reset checksums990b038d...990b038d...(identical)get_draft_model()NotImplementedError(the removed stub)None(runner's value) - intendedUnit tests on the same machine, PR tree, both lanes:
pytest -q tests/ut/worker/test_worker_weight_checker.py tests/ut/worker/test_worker_inheritance.py tests/ut/worker/test_worker_v1.pytests/ut/worker/test_worker_inheritance.py::test_get_draft_model_reports_the_runner_drafter(added after review) binds the upstream runner method this RPC resolves to and checks all three states: no speculator, aDraftModelSpeculatorcarrying a draft module (returned by identity), and a non-draft speculator.Also run locally:
ruff check,ruff format --check,py_compile, and the audit re-run ->0 redundant,0 annotation-onlyon both lanes.Checklist
Testing
Boundary / edge-case coverage:
get_draft_modelnow covers configured / absent / non-draft speculator; the deleted pass-throughs add no new input domain.Regression test:
test_model_accessors_are_inheritedpinsNPUWorker.<m> is GPUWorker.<m>for the remaining accessors, and the new behavior test pins the one RPC whose behavior changed.Error / failure path coverage: the removed
NotImplementedErrorpath is exactly what the new test replaces.Meaningful & reliable tests: tests that asserted deleted behavior were removed rather than weakened; A/B evidence on real NPU is in the table above.
Performance impact: not applicable - no hot-path or kernel change.
vLLM main: vllm-project/vllm@c410543