Skip to content

Override Transformers defaults by GGUF defaults#42770

Merged
SunMarc merged 3 commits intohuggingface:mainfrom
a4lg:gguf-config-override-defaults
Dec 10, 2025
Merged

Override Transformers defaults by GGUF defaults#42770
SunMarc merged 3 commits intohuggingface:mainfrom
a4lg:gguf-config-override-defaults

Conversation

@a4lg
Copy link
Copy Markdown
Contributor

@a4lg a4lg commented Dec 10, 2025

What does this PR do?

In some models, GGUF uses default or fixed values different from this library.
To integrate GGUF-based models without additional configuration (and/or individual config.json), we need some kind of compatibility layer (like tensor processors in src/transformers/modeling_gguf_pytorch_utils.py while loading/converting GGUF-based model tensors).

This commit provides additional mapping to provide GGUF-specific default values to initialize parameters in this library.

Currently, only fixed norm_topk_prob value of Qwen3 MoE (True) is defined because:

  1. It differs from the default value of this library (False) and
  2. If this parameter is incorrectly set, it results in almost completely garbled output (see [Model][Quantization] Override HF defaults to GGUF ones (incl. Qwen3 MoE) vllm-project/vllm#30118 for examples).

I'm sure that Qwen3 MoE + GGUF issue should be addressed somehow but I'm not sure whether this PR is the right way to fix the issue.
So, feel free to leave a review!

I could not check all parameters but at least I checked important parameters for MoE models with GGUF support in this library.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Cyrilvallez @SunMarc @MekkCyber

Copy link
Copy Markdown
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this @a4lg !

Comment thread src/transformers/integrations/ggml.py
@a4lg a4lg force-pushed the gguf-config-override-defaults branch from 39a970b to cfd48f7 Compare December 10, 2025 13:13
In some models, GGUF uses default or fixed values different from this
library.  To integrate GGUF-based models without additional configuration,
we need some kind of compatibility layer.

This commit provides additional mapping to provide GGUF-specific default
values to initialize parameters in this library.

Currently, only fixed "norm_topk_prob" value of Qwen3 MoE (True) is
defined because (a) it differs from the default value of this library
(False) and (b) if this parameter is incorrectly set, it results in
almost completely garbled output.

Signed-off-by: Tsukasa OI <floss_llm@irq.a4lg.com>
@a4lg a4lg force-pushed the gguf-config-override-defaults branch from cfd48f7 to 68d2175 Compare December 10, 2025 13:16
Copy link
Copy Markdown
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Thank you for iterating

Comment thread src/transformers/integrations/ggml.py
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

a4lg and others added 2 commits December 10, 2025 22:42
Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
Copy link
Copy Markdown
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks !

@SunMarc SunMarc enabled auto-merge (squash) December 10, 2025 14:26
@SunMarc SunMarc merged commit 51a6673 into huggingface:main Dec 10, 2025
25 checks passed
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
* Override Transformers defaults by GGUF defaults

In some models, GGUF uses default or fixed values different from this
library.  To integrate GGUF-based models without additional configuration,
we need some kind of compatibility layer.

This commit provides additional mapping to provide GGUF-specific default
values to initialize parameters in this library.

Currently, only fixed "norm_topk_prob" value of Qwen3 MoE (True) is
defined because (a) it differs from the default value of this library
(False) and (b) if this parameter is incorrectly set, it results in
almost completely garbled output.

Signed-off-by: Tsukasa OI <floss_llm@irq.a4lg.com>

* Apply suggestions from code review

Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>

---------

Signed-off-by: Tsukasa OI <floss_llm@irq.a4lg.com>
Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants