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.unified_dspark_deepseekV4

DeepSeek-V4 speculative decoding with its in-checkpoint DSpark stages.

UnifiedDSparkDeepseekV4​

class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4(config, speculative_config, *, enable_structured_output=False)

source

Bases: BlockDriver[tuple[list[TensorValue], list[RaggedRows]], TensorValue]

Verify through the trunk, draft a block through the DSpark stages.

Target and draft are one DeepseekV4; draft names its mtp stages so the driver’s module tree has both roles, but the weights are loaded and registered through target alone. On more than one device both roles run tensor-parallel on the target’s per-device copies (shard()).

Parameters:

shard()​

shard(devices)

source

Runs both roles on per-device copies of target.

Call it once, after the weights are loaded into target, which stays the module the weights registry is built from.

Parameters:

devices (Sequence[DeviceRef])

Return type:

None

target​

target: DeepseekV4

source

UnifiedDSparkDeepseekV4BatchProcessor​

class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4BatchProcessor(config, runtime)

source

Bases: UnifiedSpecDecodeBatchProcessor[UnifiedDSparkDeepseekV4Inputs, DeepseekV4Config]

Ragged batching with the spec-decode seed.

Parameters:

UnifiedDSparkDeepseekV4Inputs​

class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4Inputs(tokens, input_row_offsets, return_n_logits, signal_buffers, *, kv_cache_inputs=None, lora_buffers=(), vision_embeddings=<factory>, vision_scatter_indices=<factory>, hidden_states=None, draft_tokens=None, draft_probs_full=None, seed=None, temperature=None, top_k=None, max_k=None, top_p=None, min_top_p=None, in_thinking_phase=None, draft_slot_ids=None, draft_block_offsets=None, pinned_bitmask=None, wait_payload=None, device_bitmask_scratch=None, structured_output=False)

source

Bases: UnifiedSpecDecodeInputs

The ragged prefix, the signal buffers (more than one device only), the V4 leaves, then the spec tail.

Parameters:

buffers​

property buffers: tuple[Buffer, ...]

source

Returns positional Buffer inputs for model ABI calls.

input_row_offsets​

input_row_offsets: Buffer

source

return_n_logits​

return_n_logits: Buffer

source

signal_buffers​

signal_buffers: list[Buffer]

source

tokens​

tokens: Buffer

source

UnifiedDSparkDeepseekV4Model​

class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4Model(*args, **kwargs)

source

Bases: _UnifiedSpecDecodeModelMixin, DeepseekV4Model

DeepSeek-V4 with DSpark: merge + verify + accept + draft in one graph.

The KV tree is the trunk’s own: the stages’ windows are already layers of its window leaf, so there is no separate draft cache to size or feed.

Parameters:

batch_processor_cls​

batch_processor_cls

source

alias of UnifiedDSparkDeepseekV4BatchProcessor

load_graphs()​

load_graphs(session)

source

Loads the fused graph as the decoder.

The base registers DeepSeek-V4’s own graph through graph specs; this graph still builds through load_model().

Parameters:

session (InferenceSession)

Return type:

dict[str, Model]