Transformers documentation
MuseGlimmerAssistant
This model was contributed to Hugging Face Transformers on 2026-08-09.
MuseGlimmerAssistant
MuseGlimmerAssistant is the DFlash drafter for MuseGlimmer. It is not a standalone language model. It has 5 sliding window layers and no embeddings of its own. It borrows the main model’s input and output embeddings, and reads the main model’s hidden states at target_layer_ids (layers 1, 13, 25, 37, and 49 by default) as context.
Rather than drafting one token at a time, the drafter denoises a whole block of block_size masked tokens in a single forward pass, like a diffusion window. The main model then verifies the block in one step. Meta reports 3.1x faster decoding on an RTX 5090 and 1.5-1.8x on Apple M-series chips.
Pass the drafter to generate() as assistant_model and set speculation_type="dflash". The drafter must be loaded in the same dtype and on the same device as the main model.
from transformers import AutoProcessor, MuseGlimmerAssistantModel, MuseGlimmerForConditionalGeneration
processor = AutoProcessor.from_pretrained("meta-models/Muse-Glimmer-30B")
model = MuseGlimmerForConditionalGeneration.from_pretrained(
"meta-models/Muse-Glimmer-30B",
device_map="auto",
)
drafter = MuseGlimmerAssistantModel.from_pretrained(
"meta-models/Muse-Glimmer-30B-assistant",
device_map="auto",
)
messages = [
{
"role": "user",
"content": [{"type": "text", "text": "Write a bash one-liner that counts lines of Python in a repo."}],
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
input_len = inputs["input_ids"].shape[-1]
outputs = model.generate(
**inputs,
assistant_model=drafter,
speculation_type="dflash",
max_new_tokens=256,
)
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
print(response)Notes
- The drafter needs the main model’s hidden states, so
generateforcesoutput_hidden_states=Truefor the target model whenspeculation_type="dflash". - See the Meta is back with Muse Glimmer: local, agentic, multimodal, and open source! blog post for more details and example usage.
MuseGlimmerAssistantConfig
class transformers.MuseGlimmerAssistantConfig
< source >( transformers_version: str | None = Nonearchitectures: list[str] | None = Noneoutput_hidden_states: bool | None = Falsereturn_dict: bool | None = Truedtype: typing.Union[str, ForwardRef('torch.dtype'), NoneType] = Nonechunk_size_feed_forward: int = 0is_encoder_decoder: bool = Falseid2label: dict[int, str] | dict[str, str] | None = Nonelabel2id: dict[str, int] | dict[str, str] | None = Noneproblem_type: typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = Nonehidden_size: int = 6656intermediate_size: int = 19968num_hidden_layers: int = 5num_attention_heads: int = 32num_key_value_heads: int = 8head_dim: int = 128rms_norm_eps: float = 1e-05rope_parameters: dict | None = Nonemax_position_embeddings: int = 131072sliding_window: int = 2048layer_types: list[str] | None = Noneattention_dropout: float | int = 0hidden_act: str = 'silu'bos_token_id: int | None = 200000eos_token_id: int | None = 200001pad_token_id: int | None = 200018block_size: int = 16mask_token_id: int = 201818target_layer_ids: list[int] | None = None )
Parameters
- hidden_size (
int, optional, defaults to6656) — Dimension of the hidden representations. - intermediate_size (
int, optional, defaults to19968) — Dimension of the MLP representations. - num_hidden_layers (
int, optional, defaults to5) — Number of hidden layers in the Transformer decoder. - num_attention_heads (
int, optional, defaults to32) — Number of attention heads for each attention layer in the Transformer decoder. - num_key_value_heads (
int, optional, defaults to8) — This is the number of key_value heads that should be used to implement Grouped Query Attention. Ifnum_key_value_heads=num_attention_heads, the model will use Multi Head Attention (MHA), ifnum_key_value_heads=1the model will use Multi Query Attention (MQA) otherwise GQA is used. When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group. For more details, check out this paper. If it is not specified, will default tonum_attention_heads. - head_dim (
int, optional, defaults to128) — The attention head dimension. If None, it will default to hidden_size // num_attention_heads - rms_norm_eps (
float, optional, defaults to1e-05) — The epsilon used by the rms normalization layers. - rope_parameters (
dict, optional) — Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain a value forrope_thetaand optionally parameters used for scaling in case you want to use RoPE with longermax_position_embeddings. - max_position_embeddings (
int, optional, defaults to131072) — The maximum sequence length that this model might ever be used with. - sliding_window (
int, optional, defaults to2048) — Sliding window attention window size. IfNone, no sliding window is applied. - layer_types (
list[str], optional) — A list that explicitly maps each layer index with its layer type. If not provided, it will be automatically generated based on config values. - attention_dropout (
Union[float, int], optional, defaults to0) — The dropout ratio for the attention probabilities. - hidden_act (
str, optional, defaults tosilu) — The non-linear activation function (function or string) in the decoder. For example,"gelu","relu","silu", etc. - bos_token_id (
int, optional, defaults to200000) — Token id used for beginning-of-stream in the vocabulary. - eos_token_id (
int, optional, defaults to200001) — Token id used for end-of-stream in the vocabulary. - pad_token_id (
int, optional, defaults to200018) — Token id used for padding in the vocabulary. - block_size (
int, optional) — The block size of noise inputs that will be denoised. - mask_token_id (
int, optional) — Mask token ids used as noisey input to model. - target_layer_ids (
list[int], optional) — Zero indexed layer ids whose hidden states are concatenated as context for the model.
This is the configuration class to store the configuration of a MuseGlimmerAssistantModel. It is used to instantiate a Muse Glimmer Assistant model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the meta-models/Muse-Glimmer-30B-assistant
Configuration objects inherit from PreTrainedConfig and can be used to control the model outputs. Read the documentation from PreTrainedConfig for more information.
Example:
>>> from transformers import MuseGlimmerAssistantConfig, MuseGlimmerAssistantModel
>>> # Initializing a Muse Glimmer Assistant config similar to `meta-models/Muse-Glimmer-30B-assistant`.
>>> configuration = MuseGlimmerAssistantConfig(text_config)
>>> # Initializing a model from the `meta-models/Muse-Glimmer-30B-assistant` configuration.
>>> model = MuseGlimmerAssistantModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.configMuseGlimmerAssistantPreTrainedModel
class transformers.MuseGlimmerAssistantPreTrainedModel
< source >( config: PreTrainedConfig*inputs**kwargs )
Parameters
- config (PreTrainedConfig) — Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the from_pretrained() method to load the model weights.
This model inherits from PreTrainedModel. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.)
This model is also a PyTorch torch.nn.Module subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
MuseGlimmerAssistantModel
class transformers.MuseGlimmerAssistantModel
< source >( config: MuseGlimmerAssistantConfig )
Parameters
- config (MuseGlimmerAssistantConfig) — Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the from_pretrained() method to load the model weights.
The bare Muse Glimmer Assistant Model outputting raw hidden-states without any specific head on top.
This model inherits from PreTrainedModel. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.)
This model is also a PyTorch torch.nn.Module subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
forward
< source >( noise_embeds: FloatTensorcontext_hidden_states: FloatTensorattention_mask: typing.Optional[torch.Tensor] = Noneposition_ids: typing.Optional[torch.LongTensor] = Nonepast_key_values: transformers.cache_utils.DFlashCache | None = Noneuse_cache: bool | None = None**kwargs: Unpack )
noise_embeds (torch.FloatTensor of shape [batch_size, config.block_size, dim]):
Input embedding for the last generated anchor token and mask tokens to be denoised.
context_hidden_states (torch.FloatTensor of shape [batch_size, number_of_previous_accepted_tokens, dim * len(config.target_layer_ids)]):
Context hidden states from target model’s selected layer ids concatenated in the last dim.
attention_mask (torch.Tensor of shape [batch_size, number_of_previous_accepted_tokens + config.block_size]):
Similar to the usual attention_mask, but note that it has length number_of_previous_accepted_tokens + config.block_size,
because the Attention will first concatenate context_hidden_states and the hidden states derived from noise_embeds, so that
k/v states do not have the same length as q_states, even before the cache.update() call. Thus the kv_seq_len dimension of
the attention mask needs to span the additional positions.
position_ids (torch.Tensor of shape [batch_size, number_of_previous_accepted_tokens + config.block_size]):
Similar to the usual position_ids, but note that it has length number_of_previous_accepted_tokens + config.block_size,
because the Attention will first concatenate context_hidden_states and the hidden states derived from noise_embeds, so that
k/v states do not have the same length as q_states, even before the cache.update() call. Thus the position_ids and the derived position_embeddings need to span all the additional positions.