IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python module

max.pipelines.architectures.dspark_qwen3

The DSpark draft of Nemotron-H, a Qwen3-style block drafter.

DSparkQwen3​

class max.pipelines.architectures.dspark_qwen3.DSparkQwen3(config, kv_params, *, num_devices, max_seq_len, device)

source

Bases: Module

The DSpark draft: context projection, layers and Markov head.

Builds the draft.

Parameters:

  • config (DSparkQwen3DraftConfig) – The draft’s hyperparameters.
  • kv_params (KVCacheParams) – The draft’s KV cache leaf.
  • num_devices (int) – The tensor-parallel degree.
  • max_seq_len (int) – The longest sequence, which sizes the rope table.
  • device (Any) – The device the rope table is built on.

forward()​

forward(embeds, kv_collection, input_row_offsets)

source

Alias for forward_block().

Parameters:

  • embeds (Tensor)
  • kv_collection (PagedCacheValues)
  • input_row_offsets (Tensor)

Return type:

Tensor

forward_block()​

forward_block(embeds, kv_collection, input_row_offsets)

source

Runs the block, whose K and V land at the cache’s lengths.

Parameters:

  • embeds (Tensor)
  • kv_collection (PagedCacheValues)
  • input_row_offsets (Tensor)

Return type:

Tensor

materialize()​

materialize(ctx, kv_collection, input_row_offsets)

source

Writes every layer’s K and V of the context rows into the cache.

Parameters:

  • ctx (Tensor)
  • kv_collection (PagedCacheValues)
  • input_row_offsets (Tensor)

Return type:

None

project_context()​

project_context(taps)

source

Projects the concatenated target taps to the draft’s context.

Parameters:

taps (Tensor)

Return type:

Tensor

DSparkQwen3DraftConfig​

class max.pipelines.architectures.dspark_qwen3.DSparkQwen3DraftConfig(hidden_size, intermediate_size, num_hidden_layers, num_attention_heads, num_key_value_heads, head_dim, rms_norm_eps, vocab_size, rope_theta, sliding_window, max_position_embeddings, block_size, mask_token_id, target_layer_ids, markov_rank, sample_from_anchor, quantized)

source

Bases: object

The DSpark draft’s hyperparameters, from its checkpoint config.

Parameters:

  • hidden_size (int)
  • intermediate_size (int)
  • num_hidden_layers (int)
  • num_attention_heads (int)
  • num_key_value_heads (int)
  • head_dim (int)
  • rms_norm_eps (float)
  • vocab_size (int)
  • rope_theta (float)
  • sliding_window (int)
  • max_position_embeddings (int)
  • block_size (int)
  • mask_token_id (int)
  • target_layer_ids (tuple[int, ...])
  • markov_rank (int)
  • sample_from_anchor (bool)
  • quantized (bool)

block_size​

block_size: int

source

head_dim​

head_dim: int

source

hidden_size​

hidden_size: int

source

intermediate_size​

intermediate_size: int

source

markov_rank​

markov_rank: int

source

mask_token_id​

mask_token_id: int

source

max_position_embeddings​

max_position_embeddings: int

source

num_attention_heads​

num_attention_heads: int

source

num_context_features​

property num_context_features: int

source

How many target taps feed the fc projection.

num_drafts​

property num_drafts: int

source

How many tokens a block proposes.

num_hidden_layers​

num_hidden_layers: int

source

num_key_value_heads​

num_key_value_heads: int

source

quantized​

quantized: bool

source

Whether the checkpoint stores its linears NVFP4 weight-only.

rms_norm_eps​

rms_norm_eps: float

source

rope_theta​

rope_theta: float

source

sample_from_anchor​

sample_from_anchor: bool

source

Whether the anchor slot of the block predicts a draft token.

False is the DFlash layout: the block’s first slot holds the committed token and predicts nothing, so a block of block_size carries block_size - 1 drafts.

sliding_window​

sliding_window: int

source

tap_layer_inputs​

property tap_layer_inputs: tuple[int, ...]

source

The target layers whose inputs the target taps.

The checkpoint names layer outputs and the target taps layer inputs, and a layer’s output is the next layer’s input.

target_layer_ids​

target_layer_ids: tuple[int, ...]

source

The target layers whose outputs the draft reads, as the checkpoint names them. Tapping a layer’s output is tapping the next layer’s input.

vocab_size​

vocab_size: int

source