vllm.models.muse_spark.nvidia.specialized_decode.runtime.markov
¶
The Muse Spark DSpark draft's fused Markov sampling loop.
DSparkSpeculator samples the draft tokens left to right, adding each
step's Markov bias to the base draft logits. MarkovSampler runs that loop
with each step's tail as one CuTe DSL kernel (cutedsl/draft/markov.py),
bitwise equal to the speculator's eager loop on rows without NaN.
Each row samples the lowest vocab id whose noised logit is NaN, else the
lowest id of the maximum (the torch.argmax order), at every block size and
vocab shard. On a row with a NaN the eager loop's pick depends on its block
layout, so the two can differ there.
With a vocab-parallel Markov w2 each rank samples its own vocab range
(VocabParallelMarkovHead) and the ranks exchange one packet per request
and step. The draft model builds it on the first call of its
sample_sequential hook, from the speculator's sampling state.
Classes:
-
FusedMarkovParams–Static inputs of the fused loop, fixed once the draft model loads.
-
MarkovCall–The views one call of the fused loop runs on (
MarkovSampler.call_views). -
MarkovSampler–The fused Markov loop of one draft model, with its per-call buffers.
-
MarkovVocabShard–This rank's contiguous vocab range of the draft lm_head and Markov w2.
-
VocabParallelMarkovHead–DSparkMarkovHeadwithmarkov_w2sharded like the draft lm_head:
Functions:
-
build_markov_sampler–The fused loop over
model, which the specialized decode's draft -
compute_local_draft_logits–This rank's vocab shard of
model.compute_draft_logits, ungathered. -
fused_markov_params–Inputs of the fused Markov loop for a draft
unsupportedaccepts. -
markov_vocab_shard–This rank's
[start, end)draft-vocab range of a vocab-parallel -
step_block–markov_step's block for a call over
num_rowsrows. -
unsupported–Why only the speculator's eager Markov loop computes this draft's
-
vocab_shard–The sharded loop's view of this rank's draft-vocab range.
FusedMarkovParams
dataclass
¶
Static inputs of the fused loop, fixed once the draft model loads.
Attributes:
-
inv_soft_cap(float) –fp32(1) / fp32(soft_cap): torch divides by a scalar this way. -
output_multiplier(float) –Rounded to fp32, as torch multiplies an fp32 tensor by it.
-
soft_cap(float | None) –Rounded to fp32;
Nonewithout a soft cap. -
vocab_shard(MarkovVocabShard | None) –Set when
markov_w2is vocab-parallel. -
w1(Tensor) –Markov w1 table
[V, R](bf16, R a power of two).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
inv_soft_cap
instance-attribute
¶
fp32(1) / fp32(soft_cap): torch divides by a scalar this way.
output_multiplier
instance-attribute
¶
Rounded to fp32, as torch multiplies an fp32 tensor by it.
soft_cap
instance-attribute
¶
Rounded to fp32; None without a soft cap.
vocab_shard = None
class-attribute
instance-attribute
¶
Set when markov_w2 is vocab-parallel.
w1
instance-attribute
¶
Markov w1 table [V, R] (bf16, R a power of two).
MarkovCall
¶
Bases: NamedTuple
The views one call of the fused loop runs on (MarkovSampler.call_views).
Attributes:
-
base_logits(Tensor) –[rows, n_spec, width]BF16. -
cache(Tensor) –The draft-logits cache, or with a shard
[rows, n_spec, width]. -
flat_cache(Tensor | None) –With a shard, the flat cache the all-gather moves (else None).
-
markov_embeds(Tensor) –[n_spec + 1, rows, rank]. -
offset(int) –The first vocab id of this rank's shard (0 without a shard).
-
packets(Tensor) –[rows, 4]FP32: a row's packet (with a shard). -
width(int) –Vocab entries per rank: the whole vocab, or this rank's shard.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
base_logits
instance-attribute
¶
[rows, n_spec, width] BF16.
cache
instance-attribute
¶
The draft-logits cache, or with a shard [rows, n_spec, width].
flat_cache
instance-attribute
¶
With a shard, the flat cache the all-gather moves (else None).
markov_embeds
instance-attribute
¶
[n_spec + 1, rows, rank].
offset
instance-attribute
¶
The first vocab id of this rank's shard (0 without a shard).
packets
instance-attribute
¶
[rows, 4] FP32: a row's packet (with a shard).
width
instance-attribute
¶
Vocab entries per rank: the whole vocab, or this rank's shard.
MarkovSampler
¶
The fused Markov loop of one draft model, with its per-call buffers.
Methods:
-
call_views–The base logits of a call over
num_reqsrows and the views of -
sample–The eager Markov loop with each step's tail as one kernel.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 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 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 | |
_heads()
¶
(base logits, Markov bias) of a call: the draft's full-vocab
heads, or with a vocab shard this rank's (neither all-gathers).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
_step_variants(max_rows, width, draft_logits)
¶
The (block, PDL, vector) of every step a call over 1 to
max_rows rows launches (MarkovKernels.step picks vector
from its operands).
The base logits and the bias of a call are fresh outputs of the
heads (_heads): their row strides are the heads' own (a padded
lm_head or Markov w2 leaves its padded rows' stride under the
[..., :vocab] view the logits processor returns), read here from
one call of each on zeros, and they start as aligned as these
probes do (allocator blocks).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
call_views(num_reqs, head_hidden, *, sample_indices, sample_idx_mapping, sample_pos, draft_logits)
¶
The base logits of a call over num_reqs rows and the views of
its buffers that the loop's kernels run on (sample).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
sample(num_reqs, head_hidden, *, sample_indices, sample_idx_mapping, sample_pos, input_ids, anchor_idx, seeds, temperature, draft_tokens, draft_logits)
¶
The eager Markov loop with each step's tail as one kernel.
Writes draft_tokens and the draft_logits cache for the first
num_reqs requests, as DSparkSpeculator's eager loop does over
the same buffers. (The specialized decode refuses adaptive
verification, so there is no confidence head to run.)
With a vocab shard each rank samples its own vocab range, the ranks exchange one packet per request and step, and one all-gather after the loop fills the full-vocab draft-logits cache.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
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 | |
MarkovVocabShard
dataclass
¶
This rank's contiguous vocab range of the draft lm_head and Markov w2.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
VocabParallelMarkovHead
¶
Bases: DSparkMarkovHead
DSparkMarkovHead with markov_w2 sharded like the draft lm_head:
each rank computes its vocab range of the transition bias
(local_bias).
Methods:
-
align_vocab_shard–Back the rank's unquantized
markov_w2rows with storage padded -
local_bias–This rank's vocab shard of the transition bias ([B, r] -> [B, V/tp]).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
align_vocab_shard()
¶
Back the rank's unquantized markov_w2 rows with storage padded
by zero rows to a 16-byte multiple, read by :meth:local_bias.
cuBLAS picks its GEMV kernel by shape; the padded shard keeps the replicated head's sums, an unaligned one does not.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
local_bias(markov_embed)
¶
This rank's vocab shard of the transition bias ([B, r] -> [B, V/tp]).
The result is a view with the row stride of the padded storage.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
build_markov_sampler(model, *, draft_logits, draft_topk, watermarked, use_fp64_gumbel, sample_from_anchor, max_num_reqs, num_steps)
¶
The fused loop over model, which the specialized decode's draft
runs: a draft it does not reproduce fails at its first draft step, as the
vocab-parallel Markov w2 has no eager loop.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
compute_local_draft_logits(model, hidden_states)
¶
This rank's vocab shard of model.compute_draft_logits, ungathered.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
fused_markov_params(model, draft_logits)
¶
Inputs of the fused Markov loop for a draft unsupported accepts.
The fused loop rounds each step's logits to bf16 before sampling, as the eager loop does through the bf16 d2t scatter buffer, and it applies the draft's output-logit transform in its epilogue. A draft without a d2t map runs the same loop as one with the all-zero (identity) map.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
markov_vocab_shard(model)
¶
This rank's [start, end) draft-vocab range of a vocab-parallel
Markov w2, or None when the w2 is replicated.
Called once the weights are loaded; prepares the padded w2 storage
VocabParallelMarkovHead.local_bias reads. Fails where the local
computations would not return this range's columns of
model.compute_draft_logits and model.markov_bias on the default
GEMM (under --linear-backend they match to rounding only).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
step_block(num_rows)
¶
unsupported(model, *, draft_logits, draft_topk, watermarked, use_fp64_gumbel, sample_from_anchor)
¶
Why only the speculator's eager Markov loop computes this draft's tokens and draft-logits cache, or None when the fused loop does.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/markov.py
vocab_shard(params, start, end)
¶
The sharded loop's view of this rank's draft-vocab range.
The packets and cache shards are gathered in TP rank order, so rank k must hold the k-th equal slice of the draft vocabulary. The w2 is never replicated in this mode, so a draft the loop does not take fails at its first draft step instead of running the eager loop on gathered shards.