[Feat] Refactor rejection sampler (#4975)
### What this PR does / why we need it? Currently, we are using `AscendRejctionSampler` that extends from `RejctionSampler` in spec decoding. `AscendRejctionSampler` override `forward` of `RejctionSampler`, only aming to replace `rejection_sample` func. This causes a lot of code of `RejctionSampler` cannot be reused, for example: - https://github.com/vllm-project/vllm/pull/19482 - https://github.com/vllm-project/vllm/pull/26060 - https://github.com/vllm-project/vllm/pull/29223 #### Proposed Change: - Delete `AscendRejctionSampler` and use `RejctionSampler` directly in model runner. - Patch `RejctionSampler.expand_batch_to_tokens` and `RejctionSampler.rejection_sample`, maybe a better way is to make them as custom ops. - Modify `NPUModelRunner` following https://github.com/vllm-project/vllm/pull/26060 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - [x] test logits processor for spec decoding - [x] test logprobs for spec decoding - [x] test logprobs for spec decoding + async shcheduling (test with https://github.com/vllm-project/vllm-ascend/pull/4893/) - vLLM version: v0.12.0 - vLLM main: https://github.com/vllm-project/vllm/commit/ad32e3e19ccf0526cb6744a5fed09a138a5fb2f9 --------- Signed-off-by: realliujiaxu <realliujiaxu@163.com>
This commit is contained in:
1 parent
5f840696c1
commit
9e24bdd44c
6 files changed
+260
-236
No files matched your search
@@ -33,3 +33,4 @@ import vllm_ascend.patch.worker.patch_qwen2_5_omni # noqa
|
||||
import vllm_ascend.patch.worker.patch_qwen3_vl # noqa
|
||||
import vllm_ascend.patch.worker.patch_rope # noqa
|
||||
import vllm_ascend.patch.worker.patch_qwen3_next_mtp # noqa
|
||||
import vllm_ascend.patch.worker.patch_rejection_sampler # noqa
|
||||
@@ -0,0 +1,11 @@
|
||||
import vllm.v1.sample.rejection_sampler as rs
|
||||
|
||||
from vllm_ascend.sample.rejection_sampler import (apply_sampling_constraints,
|
||||
expand_batch_to_tokens,
|
||||
rejection_sample)
|
||||
|
||||
# TODO: delete this patch after apply_sampling_constraints and rejection_sample
|
||||
# are extracted to as class func of RejectionSampler
|
||||
rs.apply_sampling_constraints = apply_sampling_constraints
|
||||
rs.rejection_sample = rejection_sample
|
||||
rs.expand_batch_to_tokens = expand_batch_to_tokens
|
||||
Reference in new issue
Block a user