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_muse_spark
The DSpark draft of Muse Spark.
MuseSparkDSpark
class max.pipelines.architectures.dspark_muse_spark.MuseSparkDSpark(config, kv_params, *, max_seq_len, device)
Bases: Module
The drafter: context projection, layers and heads.
-
Parameters:
-
- config (MuseSparkDraftConfig)
- kv_params (KVCacheParams)
- max_seq_len (int)
- device (Any)
confidence()
confidence(hidden, markov_embed)
Each slot’s predicted acceptance probability.
forward()
forward(embeds, kv_collection, input_row_offsets)
Runs the embedded block; returns its final-normed rows.
has_own_lm_head
has_own_lm_head = True
markov_embed()
markov_embed(previous)
The rank-r embedding of each row’s previous token.
materialize()
materialize(taps, kv_collection, input_row_offsets)
Writes every layer’s K and V of the context rows.
prepare_freq_cis()
prepare_freq_cis(mesh)
Places the RoPE table on mesh in bfloat16.
-
Parameters:
-
mesh (DeviceMesh)
-
Return type:
-
None
slot_logits()
slot_logits(base, markov_embed)
One slot’s fp32 logits: the base, the Markov bias, the transform.
MuseSparkDSparkDraftArchConfig
class max.pipelines.architectures.dspark_muse_spark.MuseSparkDSparkDraftArchConfig(max_position_embeddings=262144)
Bases: DSparkSpeculatorsDraftArchConfig
The Muse Spark DSpark draft’s config, which builds its module.
The draft is only served as –draft-model beside a Muse Spark target.
-
Parameters:
-
max_position_embeddings (int)
build_module()
classmethod build_module(context)
Builds the drafter for the draft checkpoint context names.
The module holds no weights: it compiles with those
checkpoint_weights() returns.
-
Raises:
-
ValueError – If the method isn’t dspark, or the drafter can’t run beside the target.
-
Parameters:
-
context (ModelLoadContext)
-
Return type:
checkpoint_weights()
classmethod checkpoint_weights(context, config)
Returns the weights the built drafter compiles with.
-
Parameters:
-
- context (ModelLoadContext)
- config (MuseSparkDraftConfig)
-
Return type:
construct_kv_params()
classmethod construct_kv_params(huggingface_config, pipeline_config, devices, kv_cache_config, cache_dtype)
Returns the drafter’s own KV leaf, BF16 and full-length.
The drafter’s sliding window is its attention mask’s, not its cache’s.
-
Parameters:
-
- huggingface_config (AutoConfig)
- pipeline_config (PipelineConfig)
- devices (list[DeviceRef])
- kv_cache_config (KVCacheConfig)
- cache_dtype (DType)
-
Return type:
MuseSparkDraftConfig
class max.pipelines.architectures.dspark_muse_spark.MuseSparkDraftConfig(spec, post_norm_eps, qk_scale_factor, residual_gate_temperature, output_multiplier, final_logit_softcapping, confidence_with_markov, target_num_hidden_layers)
Bases: object
The drafter’s hyperparameters, from its checkpoint config.
-
Parameters:
block_size
property block_size: int
The drafter’s block width.
confidence_with_markov
confidence_with_markov: bool
final_logit_softcapping
final_logit_softcapping: float
from_huggingface_config()
classmethod from_huggingface_config(hf)
Parses the muse_spark_dspark config.
-
Raises:
-
ValueError – If the config describes a draft these layers do not build.
-
Parameters:
-
hf (Any)
-
Return type:
hidden_size
property hidden_size: int
The drafter’s hidden width.
mask_token_id
property mask_token_id: int
The id that fills the block’s draft slots.
num_target_layers
property num_target_layers: int
The target model’s layer count.
output_multiplier
output_multiplier: float
post_norm_eps
post_norm_eps: float
qk_scale_factor
qk_scale_factor: float
residual_gate_temperature
residual_gate_temperature: float
spec
spec: DSparkSpeculatorsDraftConfig
The fields every speculators-format DSpark draft has.
target_layer_ids
The target layers whose outputs the drafter reads.
target_num_hidden_layers
target_num_hidden_layers: int
vocab_size
property vocab_size: int
The drafter’s vocabulary size.
check_pairing()
max.pipelines.architectures.dspark_muse_spark.check_pairing(target_text, draft)
Checks the drafter against the target it runs beside.
-
Parameters:
-
- target_text (Any) – The target’s Hugging Face
text_config. - draft (MuseSparkDraftConfig) – The parsed drafter config.
- target_text (Any) – The target’s Hugging Face
-
Raises:
-
ValueError – If the pair cannot run together.
-
Return type:
-
None