Skip to content

[Refactor] Drop worker overrides that duplicate upstream - #23047

Open
Ronald1995 wants to merge 3 commits into
vllm-project:mainfrom
Ronald1995:drop-redundant-lora-passthrough
Open

Ronald1995 wants to merge 3 commits into
vllm-project:mainfrom
Ronald1995:drop-redundant-lora-passthrough

Conversation

@Ronald1995

@Ronald1995 Ronald1995 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

NPUWorker overrides a set of worker RPCs that upstream vllm/v1/worker/gpu_worker.py::Worker already implements with the same behavior. I audited every method declared on the class against the effective upstream implementation - gpu_worker.Worker, falling back to WorkerBase where 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.dump of each FunctionDef, 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:

# method vs v0.33.0 vs pinned main c410543d note
1-4 add_lora, remove_lora, list_loras, pin_lora identical identical return self.model_runner.<m>(...)
5-7 get_model, reset_encoder_cache, take_draft_token_ids identical identical same
8 get_supported_tasks body + decorators identical same only a redundant quoted return annotation "tuple[SupportedTask, ...]" differed
9 reset_mm_cache differs (guard) differs (guard) upstream calls model_runner.reset_mm_cache() directly; the local getattr + callable() guard protected a runner shape that no longer exists
10 get_draft_model was a NotImplementedError stub same every supported runner implements the accessor; MRv2 returns the speculator's draft model
11-12 compute_weight_checksums, reset_weights differ only in model access same upstream uses model_runner.get_model(); MRv2's get_model() is literally return self.model, so the local _weight_checksum_model() fallback was dead code
13 _weight_checksum_model (private helper) Ascend-only Ascend-only became unused with #11-12

Imports that only those methods used go away too: LoRARequest, SupportedTask, DraftTokenIds, and compute_tensor_digests/zero_weights.

The only intended behavior change is get_draft_model: the Ascend stub used to raise NotImplementedError, 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_weights no longer logs the weight_nz_mode advisory. The zeroing behavior is unchanged; the NZ guard that actually rejects unsupported usage (_check_nz_disabled, reached from _start_weight_update) is untouched.
  • The .model-only runner shape is no longer supported by the weight-checker RPCs. No such runner exists: the upstream MRv2 runner defines get_model() returning self.model on 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 remaining NotImplementedError stubs.

Does this PR introduce any user-facing change?

No user-visible behavior change beyond removing one NotImplementedError from 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 commit 7fcd50906:

  • Hardware: Ascend 910 (single die), CANN 9.1.0, torch 2.10.0, torch_npu 2.10.0.post4
  • vllm-ascend: 7fcd50906 (base) vs the PR head, selected via PYTHONPATH
  • Engine: Qwen/Qwen3-0.6B, enable_lora=True, eager, max_model_len=512, plus a small PEFT adapter (q_proj, r=8) generated for the test
  • VLLM_ENABLE_V1_MULTIPROCESSING=0 to reach the worker object in-process, and VLLM_BATCH_INVARIANT=1 because the container's prebuilt custom-op set predates this tree (aclnnAddRmsNormBias unavailable). Both settings are applied identically to base and PR, so the comparison is valid.
check (same for both vLLM lanes) base 7fcd50906 PR
compute_weight_checksums() over 226 tensors, sha256 of all digests de0b7ab0... de0b7ab0... (identical)
greedy generation, no LoRA " Paris. The capital of France is also..." identical
greedy generation with the LoRA adapter " Paris, and the capital of Italy is Rome..." identical
add_lora / pin_lora / remove_lora / list_loras True / True / False / [] identical
get_model, get_supported_tasks, take_draft_token_ids, reset_encoder_cache, reset_mm_cache Qwen3ForCausalLM(151936x1024) / ["generate"] / DraftTokenIds(req_ids=[], draft_token_ids=[]) / None / None identical
reset_weights() -> all params zero + post-reset checksums zeroed, 990b038d... zeroed, 990b038d... (identical)
get_draft_model() raises NotImplementedError (the removed stub) returns None (runner's value) - intended

Unit 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.py
  • tests/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, a DraftModelSpeculator carrying 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-only on both lanes.


Checklist

Testing

  • Boundary / edge-case coverage: get_draft_model now covers configured / absent / non-draft speculator; the deleted pass-throughs add no new input domain.

  • Regression test: test_model_accessors_are_inherited pins NPUWorker.<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 NotImplementedError path 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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.

@Ronald1995
Ronald1995 force-pushed the drop-redundant-lora-passthrough branch from 932497f to 37fa4c0 Compare November 24, 2026 08:39
@Ronald1995 Ronald1995 changed the title [Refactor] Drop LoRA worker passthroughs duplicated from upstream [Refactor] Drop worker passthroughs duplicated from upstream Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 156814 lines 1 line
Missing 45772 lines 0 lines
Coverage 71% 100%

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>
@Ronald1995
Ronald1995 force-pushed the drop-redundant-lora-passthrough branch from 37fa4c0 to 2e130de Compare November 24, 2026 08:56
@Ronald1995
Ronald1995 requested a review from wenjun91 as a code owner November 24, 2026 08:56
@Ronald1995 Ronald1995 changed the title [Refactor] Drop worker passthroughs duplicated from upstream [Refactor] Drop worker overrides that duplicate upstream Nov 24, 2026

@zhenwenqi2024 zhenwenqi2024 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Ronald1995

Copy link
Copy Markdown
Collaborator Author

@zhenwenqi2024 thanks - done in 7d382db.

test_model_accessors_are_inherited now keeps only the three accessors whose contract is pure inheritance (reset_mm_cache, compute_weight_checksums, reset_weights). get_draft_model instead gets test_get_draft_model_reports_the_runner_drafter, which:

  • binds the real upstream runner implementation this RPC resolves to (GPUModelRunner.get_draft_model from vllm/v1/worker/gpu/model_runner.py) onto a minimal runner object, so both branches of its isinstance(speculator, DraftModelSpeculator) gate actually execute, instead of stubbing the return value;
  • covers three states: no speculator -> None; a DraftModelSpeculator carrying a draft module -> that exact module returned (identity assert); a non-draft speculator -> None.

Ran on real NPU under both supported vLLM lanes (v0.33.0 tag and main@c410543d): 116 passed on each for test_worker_weight_checker.py + test_worker_inheritance.py + test_worker_v1.py.

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-reset_weights checksums under both vLLM lanes - the only difference is get_draft_model, which is exactly the behavior this test now pins.

@wxsIcey wxsIcey added the ready-precise run selected e2e test for pr label Nov 24, 2026
@wxsIcey
wxsIcey enabled auto-merge (squash) November 24, 2026 12:49
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-25 00:04 UTC+8 for commit 49a2db1.

ci-gate failed. Reason:

The 'ready-precise' selected tests failed. Open the failed job(s) inside the run-selected-tests matrix above and fix the failing test(s) or the code change that broke them.

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>
@Ronald1995

Ronald1995 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 49a2db1297c3126ec3fe406fd0451c9a01208a22 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added the ci-run E2E requested manually on the latest commit label Nov 24, 2026
@Ronald1995

Ronald1995 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

/rerun
[Bot]: rerun completed.

Rerun (failed jobs only):

  • E2E

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-run E2E requested manually on the latest commit module:tests ready-precise run selected e2e test for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants