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)
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:
-
- config (DeepseekV4Config)
- speculative_config (SpeculativeConfig)
- enable_structured_output (bool)
shard()
shard(devices)
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.
target
target: DeepseekV4
UnifiedDSparkDeepseekV4BatchProcessor
class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4BatchProcessor(config, runtime)
Bases: UnifiedSpecDecodeBatchProcessor[UnifiedDSparkDeepseekV4Inputs, DeepseekV4Config]
Ragged batching with the spec-decode seed.
-
Parameters:
-
- config (ArchConfigT_co)
- runtime (BatchProcessorRuntime)
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)
Bases: UnifiedSpecDecodeInputs
The ragged prefix, the signal buffers (more than one device only), the V4 leaves, then the spec tail.
-
Parameters:
-
- tokens (Buffer)
- input_row_offsets (Buffer)
- return_n_logits (Buffer)
- signal_buffers (list[Buffer])
- kv_cache_inputs (KVCacheInputs[Buffer, Buffer] | None)
- lora_buffers (tuple[Buffer, ...])
- vision_embeddings (list[Buffer])
- vision_scatter_indices (list[Buffer])
- hidden_states (Buffer | list[Buffer] | None)
- draft_tokens (Buffer | None)
- draft_probs_full (Buffer | None)
- seed (Buffer | None)
- temperature (Buffer | None)
- top_k (Buffer | None)
- max_k (Buffer | None)
- top_p (Buffer | None)
- min_top_p (Buffer | None)
- in_thinking_phase (Buffer | None)
- draft_slot_ids (Buffer | None)
- draft_block_offsets (Buffer | None)
- pinned_bitmask (Buffer | None)
- wait_payload (Buffer | None)
- device_bitmask_scratch (Buffer | None)
- structured_output (bool)
buffers
Returns positional Buffer inputs for model ABI calls.
input_row_offsets
input_row_offsets: Buffer
return_n_logits
return_n_logits: Buffer
signal_buffers
tokens
tokens: Buffer
UnifiedDSparkDeepseekV4Model
class max.pipelines.architectures.unified_dspark_deepseekV4.UnifiedDSparkDeepseekV4Model(*args, **kwargs)
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.
batch_processor_cls
batch_processor_cls
load_graphs()
load_graphs(session)
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: