Skip to content

feat: Expand Eagle Speculator to Support Multiple Transformer Layer Types#49

Merged
markurtz merged 7 commits intomainfrom
feat/other_decoder_layers
Jul 13, 2025
Merged

feat: Expand Eagle Speculator to Support Multiple Transformer Layer Types#49
markurtz merged 7 commits intomainfrom
feat/other_decoder_layers

Conversation

@fynnsu
Copy link
Copy Markdown
Collaborator

@fynnsu fynnsu commented Jul 10, 2025

Closes #44

Expands support for other decoder layer types (MistralDecoderLayer, Qwen3DecoderLayer, etc.)

Tasks

  • Research and identify transformer layer classes within Hugging Face for each targeted architecture.
  • Update EagleSpeculatorConfig to include architecture type selection.

This is handled using the existing transformer_layer_architecture field to specify the decoder layer class.

The transformer_layer_config must also match the decoder layer type. i.e. to use LlamaDecoderLayer transformer_layer_config must be an instance of LlamaConfig, for MistralDecoderLayer it must be an instance of MistralConfig, etc.

  • Update EagleSpeculator to construct the selected transformer layer type correctly.

We find the corresponding decoder layer class (and also layer norm class), using the config class to determine the model type / import path. This generalizes the approach so that we can use any decoder layer and config combination in the transformers library.

  • Update or create relevant tests in:
    • tests/unit/models/test_eagle_config.py
    • tests/unit/models/test_eagle_model.py

Added explicit tests for the architectures listed in #44 (Llama, Mistral, Qwen, DeepSeek, Mistral, Gemma, Granite)

  • Ensure compatibility with SpeculatorModelConfig.from_pretrained and SpeculatorModel.from_pretrained.
fynnsu added 6 commits July 10, 2025 19:05
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
…test_eagle_config.py

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
…test_eagle_model.py

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
…s model

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 10, 2025

📦 Build Artifacts Available
The build artifacts (`.whl` and `.tar.gz`) have been successfully generated and are available for download: https://github.com/neuralmagic/speculators/actions/runs/16230733555/artifacts/3516837477.
They will be retained for up to 30 days.
Commit: d9871a5

@fynnsu fynnsu requested a review from markurtz July 10, 2025 23:52
Copy link
Copy Markdown
Collaborator

@markurtz markurtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, take a look through and let me know what you think @fynnsu

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
@fynnsu fynnsu requested a review from markurtz July 11, 2025 22:19
@fynnsu
Copy link
Copy Markdown
Collaborator Author

fynnsu commented Jul 11, 2025

Hi @markurtz, I implemented the changes requested. Let me know what you think

Copy link
Copy Markdown
Collaborator

@markurtz markurtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@markurtz markurtz merged commit 5279aa6 into main Jul 13, 2025
10 checks passed
@markurtz markurtz deleted the feat/other_decoder_layers branch July 13, 2025 22:16
shanjiaz pushed a commit that referenced this pull request Jul 14, 2025
…ypes (#49)

Closes #44 

Expands support for other decoder layer types (MistralDecoderLayer,
Qwen3DecoderLayer, etc.)
> # Tasks 
> * [x] Research and identify transformer layer classes within Hugging
Face for each targeted architecture.
> * [x] Update `EagleSpeculatorConfig` to include architecture type
selection.

This is handled using the existing `transformer_layer_architecture`
field to specify the decoder layer class.

The `transformer_layer_config` must also match the decoder layer type.
i.e. to use `LlamaDecoderLayer` `transformer_layer_config` must be an
instance of `LlamaConfig`, for `MistralDecoderLayer` it must be an
instance of `MistralConfig`, etc.

> * [x] Update `EagleSpeculator` to construct the selected transformer
layer type correctly.

We find the corresponding decoder layer class (and also layer norm
class), using the config class to determine the model type / import
path. This generalizes the approach so that we can use **any** decoder
layer and config combination in the transformers library.

> * [x]   Update or create relevant tests in:
>     * `tests/unit/models/test_eagle_config.py`
>     * `tests/unit/models/test_eagle_model.py`

Added explicit tests for the architectures listed in #44 (Llama,
Mistral, Qwen, DeepSeek, Mistral, Gemma, Granite)

> * [x] Ensure compatibility with
`SpeculatorModelConfig.from_pretrained` and
`SpeculatorModel.from_pretrained`.

---------

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants