Transformers documentation

MuseGlimmerAssistant

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.14.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

This model was contributed to Hugging Face Transformers on 2026-08-09.

FlashAttention SDPA

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

MuseGlimmerAssistantConfig

class transformers.MuseGlimmerAssistantConfig

< >

( 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 to 6656) — Dimension of the hidden representations.
  • intermediate_size (int, optional, defaults to 19968) — Dimension of the MLP representations.
  • num_hidden_layers (int, optional, defaults to 5) — Number of hidden layers in the Transformer decoder.
  • num_attention_heads (int, optional, defaults to 32) — Number of attention heads for each attention layer in the Transformer decoder.
  • num_key_value_heads (int, optional, defaults to 8) — This is the number of key_value heads that should be used to implement Grouped Query Attention. If num_key_value_heads=num_attention_heads, the model will use Multi Head Attention (MHA), if num_key_value_heads=1 the 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 to num_attention_heads.
  • head_dim (int, optional, defaults to 128) — The attention head dimension. If None, it will default to hidden_size // num_attention_heads
  • rms_norm_eps (float, optional, defaults to 1e-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 for rope_theta and optionally parameters used for scaling in case you want to use RoPE with longer max_position_embeddings.
  • max_position_embeddings (int, optional, defaults to 131072) — The maximum sequence length that this model might ever be used with.
  • sliding_window (int, optional, defaults to 2048) — Sliding window attention window size. If None, 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 to 0) — The dropout ratio for the attention probabilities.
  • hidden_act (str, optional, defaults to silu) — The non-linear activation function (function or string) in the decoder. For example, "gelu", "relu", "silu", etc.
  • bos_token_id (int, optional, defaults to 200000) — Token id used for beginning-of-stream in the vocabulary.
  • eos_token_id (int, optional, defaults to 200001) — Token id used for end-of-stream in the vocabulary.
  • pad_token_id (int, optional, defaults to 200018) — 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.config

MuseGlimmerAssistantPreTrainedModel

class transformers.MuseGlimmerAssistantPreTrainedModel

< >

( 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

< >

( 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

< >

( 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 ) BaseModelOutputWithPast or tuple(torch.FloatTensor)

Parameters

  • 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.
  • past_key_values (~cache_utils.DFlashCache, optional) — Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention blocks) that can be used to speed up sequential decoding. This typically consists in the past_key_values returned by the model at a previous stage of decoding, when use_cache=True or config.use_cache=True.

    Only Cache instance is allowed as input, see our kv cache guide. If no past_key_values are passed, DynamicCache will be initialized by default.

    The model will output the same cache format that is fed as input.

    If past_key_values are used, the user is expected to input only unprocessed input_ids (those that don’t have their past key value states given to this model) of shape (batch_size, unprocessed_length) instead of all input_ids of shape (batch_size, sequence_length).

  • use_cache (bool, optional) — If set to True, past_key_values key value states are returned and can be used to speed up decoding (see past_key_values).

Returns

BaseModelOutputWithPast or tuple(torch.FloatTensor)

A BaseModelOutputWithPast or a tuple of torch.FloatTensor (if return_dict=False is passed or when config.return_dict=False) comprising various elements depending on the configuration (MuseGlimmerAssistantConfig) and inputs.

The MuseGlimmerAssistantModel forward method, overrides the __call__ special method.

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the pre and post processing steps while the latter silently ignores them.

  • last_hidden_state (torch.FloatTensor of shape (batch_size, sequence_length, hidden_size)) — Sequence of hidden-states at the output of the last layer of the model.

    If past_key_values is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size) is output.

  • past_key_values (Cache, optional, returned when use_cache=True is passed or when config.use_cache=True) — It is a Cache instance. For more details, see our kv cache guide.

    Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if config.is_encoder_decoder=True in the cross-attention blocks) that can be used (see past_key_values input) to speed up sequential decoding.

  • hidden_states (tuple(torch.FloatTensor), optional, returned when output_hidden_states=True is passed or when config.output_hidden_states=True) — Tuple of torch.FloatTensor (one for the output of the embeddings, if the model has an embedding layer, + one for the output of each layer) of shape (batch_size, sequence_length, hidden_size).

    Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.

  • attentions (tuple(torch.FloatTensor), optional, returned when output_attentions=True is passed or when config.output_attentions=True) — Tuple of torch.FloatTensor (one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length).

    Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.

Update on GitHub