vllm.model_executor.models.diffusion_gemma_sampler
¶
One-pass row statistics for the DiffusionGemma denoise sampler.
The step needs, for every canvas position, the argmax of the
temperature-scaled logits, a Gumbel-max sample from them, the entropy of
their softmax, and the softmax itself in the model dtype for the
self-conditioning matmul. As PyTorch ops these are several passes over a
[rows, vocab] fp32 tensor plus a same-sized noise tensor. The Triton
kernel reads each row once with an online max and sum, draws the noise
inline, and writes the probabilities once.
The logprobs of a converging slot are written to a per-slot stash by
stash_converged_logprobs, which skips the rows of slots that did not
converge.
Functions:
-
sample_row_stats–Argmax, Gumbel-max sample, entropy and (optionally) softmax per row.
-
sample_row_stats_reference–The PyTorch form of the same statistics, for tests and non-CUDA runs.
-
stash_converged_logprobs–Write the logprobs of the converged requests' rows to the stash.
_lp_topk_kernel(logits_ptr, logits_stride, src_ptr, keep_ptr, valid_ptr, temps_ptr, slots_ptr, num_ids_ptr, block_max_ptr, cand_ptr, K, W, V, NUM_CHUNKS, NUM_BLOCKS, HAS_IDS, BLOCK, BLOCKS_PER_CHUNK, BLOCKS_POW2, KP)
¶
The KP largest keys of one chunk of a row, unordered.
A key orders by value, then by lower index: the fp32 bits mapped to an order-preserving int32 in the high word, the inverted index in the low. Keys are distinct, so the top-k under them is unique.
Source code in vllm/model_executor/models/diffusion_gemma_sampler.py
sample_row_stats(logits, temps, canvas_len, seed, probs_dtype)
¶
Argmax, Gumbel-max sample, entropy and (optionally) softmax per row.
logits is [rows, vocab] and row i uses temperature
temps[i // canvas_len]. A zero temperature is greedy: the sample is
the argmax, and the entropy is the reference's, which clamps the
temperature at 1e-10.
Source code in vllm/model_executor/models/diffusion_gemma_sampler.py
sample_row_stats_reference(logits, temps, canvas_len, probs_dtype)
¶
The PyTorch form of the same statistics, for tests and non-CUDA runs.
Source code in vllm/model_executor/models/diffusion_gemma_sampler.py
stash_converged_logprobs(logits, canvas_len, src, slots, keep, valid, temps, num_topk, num_token_ids, token_ids, out_ids, out_logprobs, out_ranks, logits_mode)
¶
Write the logprobs of the converged requests' rows to the stash.
Request j owns logits rows src[j] * canvas_len + p for
p < valid[j], divided by temps[j]. Where keep[j], they go to
out_*[slots[j], p], laid out as compute_topk_scores lays out a row:
the argmax, then the request's token_ids if it has any, else the
num_topk largest (tied ids by lower id), padded with token 0 at -inf.
Rows not kept exit at once; the others are split into chunks so a few
kept rows still fill the GPU.
Source code in vllm/model_executor/models/diffusion_gemma_sampler.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |