Repository navigation
Commit 526141c
authored
[Performance]Reduce sampling (vllm-project#8308)
What this PR does / why we need it?
This PR introduces a significant optimization to the sampling process in
a distributed (Tensor Parallel) environment, named "reduce sampling".
The core goal is to minimize communication overhead during token
selection, thereby improving the performance of vLLM Ascend in
distributed deployment scenarios.
In traditional distributed sampling, full vocabulary gathering across
tensor parallel ranks leads to high communication costs, especially in
large-scale parallel settings. This optimization addresses the issue by
designing specialized sampling logic that intelligently aggregates and
processes vocabulary information, reducing unnecessary data transmission
while ensuring sampling accuracy.
Does this PR introduce any user-facing change?
No breaking user-facing changes. A new configuration option
enable_reduce_sample is added to AscendConfig, which users can
optionally enable to activate the optimized distributed sampling scheme.
Existing sampling behaviors remain unchanged by default.
How was this patch tested?
Tested with vLLM version based on v0.20.1.
- Validation of distributed greedy sampling logic, ensuring correct
global argmax selection across tensor parallel ranks.
- Verification of distributed top-k/top-p sampling, confirming accurate
candidate aggregation and filtering.
- Functional testing of speculative decoding rejection sampling with the
new compressed vocabulary mode.
- End-to-end testing of the integrated sampling pipeline in
ModelRunnerV1, covering both regular and speculative decoding workflows.
Summary of Changes
- Optimized Distributed Sampling Scheme: Added enable_reduce_sample in
AscendConfig to toggle the optimized sampling mode for Tensor
Parallelism, reducing communication overhead.
- Distributed Greedy Sampling: Implemented a new greedy_sample function
that gathers local maximum logits and their global indices across ranks
to determine the global argmax, avoiding full vocabulary gathering.
- Distributed Top-K/Top-P Sampling: Enhanced top-k/top-p logic to
perform local top-k selection first, then gather candidates across ranks
and apply top-p filtering on the combined global candidates.
- Updated Rejection Sampling: Modified core rejection sampling functions
(rejection_sample, rejection_random_sample_kernel, etc.) to support
compressed vocabulary mode, working with reduced candidate tokens and
global indices for efficiency.
- Model-Specific Logits Handling: Patched
Eagle3LlamaForCausalLM.compute_logits to return only selected draft
token IDs (and bias) when reduce sampling is enabled, optimizing draft
generation.
- Pipeline Integration: IntegratedAscendRejectionSampler and
AscendTopKTopPSampler into ModelRunnerV1’s sampling pipeline, adding
prepare_sampling calls to pass max_topk dynamically.
- vLLM version: v0.20.1
---------
Signed-off-by: hzx55906 <513464215@qq.com>1 parent f11845b commit 526141c
14 files changed
Lines changed: 1461 additions & 447 deletions
File tree
- tests/ut
- sample
- spec_decode
- worker
- vllm_ascend
- _310p/sample
- ops
- triton
- patch/worker
- sample
- spec_decode
- worker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 1 | | |
16 | 2 | | |
17 | 3 | | |
| |||
225 | 211 | | |
226 | 212 | | |
227 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
228 | 416 | | |
229 | 417 | | |
230 | 418 | | |
| |||
276 | 464 | | |
277 | 465 | | |
278 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
279 | 525 | | |
280 | 526 | | |
281 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2161 | 2161 | | |
2162 | 2162 | | |
2163 | 2163 | | |
2164 | | - | |
| 2164 | + | |
2165 | 2165 | | |
| 2166 | + | |
2166 | 2167 | | |
2167 | 2168 | | |
2168 | 2169 | | |
| |||
2186 | 2187 | | |
2187 | 2188 | | |
2188 | 2189 | | |
2189 | | - | |
| 2190 | + | |
2190 | 2191 | | |
2191 | 2192 | | |
2192 | 2193 | | |
2193 | 2194 | | |
| 2195 | + | |
| 2196 | + | |
2194 | 2197 | | |
2195 | 2198 | | |
2196 | 2199 | | |
| |||
2414 | 2417 | | |
2415 | 2418 | | |
2416 | 2419 | | |
2417 | | - | |
| 2420 | + | |
2418 | 2421 | | |
2419 | 2422 | | |
2420 | 2423 | | |
| |||
2510 | 2513 | | |
2511 | 2514 | | |
2512 | 2515 | | |
2513 | | - | |
| 2516 | + | |
2514 | 2517 | | |
2515 | 2518 | | |
2516 | 2519 | | |
| |||
2531 | 2534 | | |
2532 | 2535 | | |
2533 | 2536 | | |
| 2537 | + | |
| 2538 | + | |
2534 | 2539 | | |
2535 | 2540 | | |
| 2541 | + | |
2536 | 2542 | | |
2537 | 2543 | | |
2538 | 2544 | | |
| |||
2594 | 2600 | | |
2595 | 2601 | | |
2596 | 2602 | | |
2597 | | - | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
2598 | 2609 | | |
2599 | 2610 | | |
2600 | 2611 | | |
| |||
2644 | 2655 | | |
2645 | 2656 | | |
2646 | 2657 | | |
| 2658 | + | |
| 2659 | + | |
2647 | 2660 | | |
2648 | 2661 | | |
| 2662 | + | |
2649 | 2663 | | |
2650 | 2664 | | |
2651 | 2665 | | |
| |||
2700 | 2714 | | |
2701 | 2715 | | |
2702 | 2716 | | |
| 2717 | + | |
| 2718 | + | |
2703 | 2719 | | |
2704 | 2720 | | |
2705 | 2721 | | |
| |||
2710 | 2726 | | |
2711 | 2727 | | |
2712 | 2728 | | |
2713 | | - | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
2714 | 2733 | | |
2715 | 2734 | | |
2716 | 2735 | | |
| |||
0 commit comments