Skip to content

vllm.model_executor.models.nemotron_dllm

Nemotron Labs Diffusion: masked block denoising or causal AR generation.

Classes:

MaskedDiffusionSampler

Masked diffusion with per-request sampling temperatures.

The default threshold policy reveals all confident positions and guarantees at least one reveal per step. logprobs=0 returns each token's logprob at reveal time; top-k introspection uses the converged denoising distribution.

_canvas_logprobs(num_reqs, sampled, req_idx_np, slots_np, use_topk_np, width)

A canvas of logprobs rows for every logprobs request in decode.

Only committing requests read their rows (the scheduler slices num_sampled of them), so which requests commit never has to be known on the host.

_canvas_rows(sampled, req_idx_np, slots_np, use_topk_np, width)

[n, CL, width] logprobs rows for the requests at req_idx_np.

logprobs=0 requests report the at-unmask logprob; top-k requests read the stash written on their converging step.

_emitted_logprobs(num_reqs, sampled, num_sampled, req_idx_np, slots_np, num_logprobs_np, width)

Logprobs of the requests emitting this step, picked on the host.

For steps with a wide request: a canvas of rows for every logprobs request, padded to its top-k, would not fit.

_finish_prefills(input_batch, prefill_indices_np)

Transition requests whose prompt completes this step to denoising.

Initializes their all-mask canvas, seeds draft tokens, and flips is_encoder_phase to False. Mid-chunk requests (prompt longer than the token budget) are left untouched so is_encoder_phase stays True and prepare_attn keeps causal attention for their remaining chunks.

_pend_wide_logprobs(logits_3d, canvas_rows, wide_rows_np, slots_np, valid_len_np, keep, num_logprobs)

Compute the top-k of the wide decode rows that converged this step.

A per-slot stash for them would hold [CL, vocab] rows, and a top-k over all their rows every step is a full sort. So read back which of them converged and compute only those.

_stash_topk_logprobs(logits_3d, canvas_rows, slots, keep, num_logprobs)

Stash the top-k of slots where keep (the step they converged).

logits_3d is [n, CL, vocab] and canvas_rows the converged canvases [n, CL]. Rows past a truncated canvas are never emitted.

NemotronLabsDiffusionAttention

Bases: LlamaAttention

Llama attention + YaRN RoPE (HF attention factor) + per-token llama-4 Q scaling applied after RoPE.

NemotronLabsDiffusionForBlockDiffusion

Bases: Module, SupportsPP, SupportsQuant

Ministral masked block-diffusion LM for vLLM.

The backbone is a stock LlamaModel with Ministral parameters; the only architectural deltas live in the attention layer (YaRN factor and llama-4 Q scale). Mixed causal/bidirectional attention is driven by NemotronLabsDiffusionModelState.prepare_attn via a per-request causal tensor.

NemotronLabsDiffusionModelState

Bases: ModelState

ModelState for the Ministral masked block-diffusion LM.

Single backbone in two modes: - encoder mode (prefill/commit): causal attention, writes KV - denoise mode: bidirectional attention over the canvas

NemotronLabsDiffusionRequestStates

Pre-allocated GPU tensors for per-request masked-diffusion state.

Methods:

  • init_canvas –

    Reset the canvas to all-mask for the given slots.

init_canvas(slot_indices)

Reset the canvas to all-mask for the given slots.

_compiled_masked_step(logits, decode_slots, decode_idx, all_slots, valid_canvas_len, req_temps, canvas, step_tensor, is_encoder_phase, unmask_logprobs, unmask_ranks, sampled, num_sampled, draft_tokens, max_denoising_steps, mask_token_id, CL, all_greedy, capture_logprobs, leftmost, threshold_mode, log_threshold)

Update absorbing masked-token state and emit completed blocks.

Confidence uses the selected token's probability before temperature scaling. Capture token logprobs when positions are revealed, then refresh causal KV on the following commit step. Return logits for top-k introspection.

_filter_sampling_logits(logits, temperatures, top_k, top_p, mask_token_id)

Select sampling candidates after temperature scaling, excluding masks.

_hf_yarn_get_mscale(scale, mscale=1.0)

get_mscale from HF _compute_yarn_parameters.