noamaanMulla-03/transformers-issues huggingface dataset:
Incorrect `norm_topk_prob` config for loading Qwen3 MoE GGUF
Author: yuko29
Pull request: no

For Qwen3 MoE models (e.g., `Qwen/Qwen3-30B-A3B-Instruct-2507`), the released [`config.json`](https://huggingface.co/Qwen/Qwen3-30B-A3B-Instruct-2507/blob/main/config.json#L20) specifies `norm_topk_prob = True`. However, when loading with GGUF format, this parameter defaults to `False` instead of inheriting the correct setting. In particular, `norm_topk_prob` is not currently configured in the GGUF format.

It leads to incorrect forward process for the models.

I'm not sure if the correct fix is to explicitly set `norm_topk_prob = True` by default when loading Qwen3 MoE GGUF models.

Comments:
cc @sunmarc maybe?

Hey `@yuko29`, Instead of adding an architecture-specific default, a more robust and scalable solution is to ensure the loader inherits parameters from the original `config.json`. The `from_pretrained` method has access to both the GGUF file and the original model repository. The correct fix is to modify the loader to **first load the `config.json`** from the Hub to get all the correct base parameters (like `norm_topk_prob=True`). Then, it should load the GGUF-specific parameters and **merge the two configurations**. This approach is future-proof, avoids hardcoding model-specific logic, and ensures that any configuration parameter missing from the GGUF metadata is correctly inherited from the original model.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
Fix initialization guard for pytest
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. Otherwise, when running multiple tests at once with `pytest`, we sometimes hit the following error: `RuntimeError: dictionary changed size during iteration` due to how multiple tests are handled with `pytest`.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42234). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
💡 Bounty Platform for Hugging Face Transformers
Author: dineshroxonn
Pull request: no

Hi Hugging Face Transformers team! 👋

I wanted to share **Roxonn** - a decentralized bounty platform for accelerating AI/ML development.

**What is Roxonn?**
✅ Fund GitHub issues with crypto bounties (XDC, USDC, ROXN)
✅ Notify 300+ AI/ML developers
✅ Auto-pay when PRs merge via blockchain
✅ Zero crypto setup needed

**Quick flow:**
1. Register repo (GitHub App)
2. Fund pool with USDC (stable pricing)
3. Assign bounties to features
4. PR merged → automatic payment

**Perfect for AI/ML:**
- Access to research community
- **Only 1% total platform fee**
- Transparent payments

Learn more: **https://roxonn.com**

*No pressure - sharing a resource!*

Comments:
Closing this issue in compliance with GitHub's Acceptable Use Policy. I apologize for creating off-topic promotional content.

lol
Fix TP plans for MoE models
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title! After https://github.com/huggingface/transformers/pull/41580, the MoE structures have changed so the TP-plans need to be updated accordingly!

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42236). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: deepseek_v2, deepseek_v3, dots1, ernie4_5_moe, flex_olmo, glm4_moe, longcat_flash, minimax, mixtral, qwen3_moe, qwen3_next, qwen3_omni_moe
Rt_DETR loss attempts returning auxiliary_outputs when auxiliary_loss=False
Author: sinAshish
Pull request: no
Labels: name: bug

### System Info

I am trying to finetune RT-DETRv2, and while trying to load the model with updated config values such as 'auxiliary_loss=False' or 'use_focal_loss=False', it throws an error that I am trying to access a variable which is not initialized [here](https://github.com/huggingface/transformers/blob/16c7afd06f70e1ab7a8bb2e19e33e5473297dc55/src/transformers/loss/loss_rt_detr.py#L467)

A rudimentary fix is to set `auxiliary_outputs = None` at L450

```
- `transformers` version: 4.57.0
- Platform: Linux-6.8.0-78-generic-x86_64-with-glibc2.35
- Python version: 3.13.7
- Huggingface_hub version: 0.35.3
- Safetensors version: 0.6.2
- Accelerate version: 1.10.1
- Accelerate config:    not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.8.0+cu128 (CUDA)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?:
```

### Who can help?

Add auxiliary_outputs = None at L450

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

1. Update the model config for RT_DETRv2 with auxiliary_loss=False
2. Load the model
3. Run 1 step of training

### Expected behavior

Should get this error:

UnboundLocalError: cannot access local variable 'auxiliary_outputs' where it is not associated with a value

Comments:
# This patch prevents UnboundLocalError by always initializing auxiliary_outputs,
# even if auxiliary_loss=False in the RT-DETR loss function.
auxiliary_outputs = None


Should be fixed by #42224
Fix issue #41553: Improve error message for Voxtral tokenizer when mistral-common is missing
Author: akintunero
Pull request: yes
Labels: name: Code agent slop

## Description

This PR fixes issue #41553 by providing a clear error message when trying to load Voxtral tokenizer without the `mistral-common` library installed.

## Problem

Currently, when users try to load a Voxtral tokenizer without `mistral-common` installed, they get a confusing error:
```
TypeError: not a string
```

This happens because the code falls back to `LlamaTokenizer` when `mistral-common` is not available, but Voxtral models don't have a compatible vocab file, causing `vocab_file` to be `None`.

## Solution

Added a check in `AutoTokenizer.from_pretrained()` that:
- Detects when a Voxtral model is being loaded
- Checks if `mistral-common` is available
- Raises a clear `ImportError` with installation instructions before attempting to use the fallback tokenizer

## Changes

- **File**: `src/transformers/models/auto/tokenization_auto.py`
  - Added check for Voxtral model type before accessing `TOKENIZER_MAPPING`
  - Raises `ImportError` with helpful message when `mistral-common` is missing

- **File**: `tests/models/auto/test_tokenization_auto.py`
  - Added test `test_voxtral_tokenizer_missing_mistral_common_error()` to verify the fix

## Error Message Improvement

**Before:**
```
TypeError: not a string
```

**After:**
```
ImportError: The Voxtral tokenizer requires the `mistral-common` library to be installed. 
Please install it with: `pip install mistral-common` or `pip install transformers[mistral-common]`
```

## Testing

- Added unit test that verifies the error message is raised correctly
- Test uses mocking to simulate missing `mistral-common` dependency
- Verifies error message contains required keywords

## Checklist

- [x] The code follows the code style guidelines of this project
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (if applicable)
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published

Fixes #41553

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto
Fix encoding and improve tokenizer testing logic
Author: brittytino
Pull request: yes
Labels: name: Code agent slop

**Summary**

This pull request resolves multiple issues in the tokenizer parity testing script used to validate consistency between the slow (Python) and fast (Rust) tokenizers in the Hugging Face transformers library.
The changes correct dataset handling, fix incorrect API usage, and improve overall code clarity, performance, and maintainability.

**Key Changes**
1. Fixed Incorrect Dataset Field Access

> The original implementation attempted to access nested fields in the facebook/xnli dataset using:
> ```python
> for text in dataset[i]["premise"].values():
> for text in dataset[i]["hypothesis"]["translation"]:
> ```

However, the dataset structure is flat, with top-level premise and hypothesis keys. This caused TypeError exceptions during iteration.

**Updated Implementation:**
```python
for example in dataset:
    test_string(slow, fast, example["premise"])
    test_string(slow, fast, example["hypothesis"])
```

**2. Corrected Offset Mapping Handling in check_LTR_mark**

The previous code incorrectly accessed enc.offsets after calling encode_plus(), which returns a dictionary rather than an object.
This raised AttributeError exceptions.

**Fixed Implementation:**
```python
enc = fast.encode_plus(line, return_offsets_mapping=True)
offsets = enc["offset_mapping"]
```

Added proper boundary checks to handle cases where index positions are out of range.

**3. Added Missing Global Variable Declarations**

The counters (perfect, imperfect, wrong, total) were modified inside several functions without being declared as global.
This could lead to incorrect scope behavior or counter mismatches.

**Fix:**
Explicitly declared global variables inside the main execution block:
```python
if __name__ == "__main__":
    global imperfect, perfect, wrong, total
```
**4. Refactored Dataset Iteration**

Replaced index-based iteration with direct dataset iteration for cleaner and more memory-efficient looping:
```python
for example in dataset:
    ...
```

This improves readability and eliminates unnecessary indexing operations.

**5. General Cleanup and Minor Improvements**

- Improved logging consistency and readability.
- Removed redundant temporary variables.
- Ensured all tokenizer checks run safely without unhandled exceptions.
- Maintained full backward compatibility with existing functionality.

**Results**

- The script now executes without errors on the facebook/xnli dataset.
- Tokenizer output comparisons between slow and fast implementations complete successfully.
- Accuracy reporting and detailed mismatch diagnostics function as intended.
- The script produces consistent results across multiple tokenizer architectures.

**Testing**

- Validated using BertTokenizer, XLMRobertaTokenizer, and MBartTokenizer.
- Confirmed parity check logic and reporting are correct.
- No exceptions encountered during execution.
- Accuracy metrics print as expected.

**Files Modified**
tokenizer_equivalence_test.py

Comments:
Loading optimization
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

Since https://github.com/huggingface/transformers/pull/42191, the tied weight keys are gathered at init time, so we can use them directly without looping over all modules one more time. Also, this takes the config into account, i.e. if we _actually_ tie or not based on the config, which was not the case before

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42239). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
FIX Broken PEFT adapter loading
Author: BenjaminBossan
Pull request: yes

# What does this PR do?

For some time now, loading PEFT adapters directly with transformers is broken when using revisions or subfolders.

To check, run:

`RUN_SLOW=1 pytest tests/peft_integration/test_peft_integration.py -k test_peft_from_pretrained_hub_kwargs`

This PR makes the PEFT tests pass.

The PR causing this is #41445 (bad commit: `1ee3b288a62c9de658e8be117d869c2a9b835a7c`, previous good comit: `cad74496ca19c463a5fcc0b35ef4a1c9da2b8c4e`). However, that PR also caused other errors (see #41604), which is why this error was not immediately obvious.


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42187). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

AFAICT, the failing tests are unrelated.

ping @ArthurZucker 

@ArthurZucker The branch is now up-to-date. AFAICT, failing tests are unrelated. IMO there is need for a new test because the old one already covers the mentioned cases, it's just that on main, this test fails but apparently nobody noticed.

@ArthurZucker Hmm, it seems I can't merge because the PR is not up-to-date with main? I merged main twice now, but until CI is finished, it's already out of date. Auto-merge doesn't work, probably because of the red CI. Haaalp!

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto

OK, merge on behalf of @BenjaminBossan but I don't take any responsibility if anything is wrong :-)
Fix processor test for glm
Author: molbap
Pull request: yes

# What does this PR do?

As per title, seems like the wrong arg name was passed to processor 

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: glm46v

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42233). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Merging because I want the CI to be green, yell at me if this causes any problems and I'll fix them :sweat_smile:
Fix UnboundLocalError in RT-DETR loss computation
Author: yashwantbezawada
Pull request: yes

## Summary

Fixes an `UnboundLocalError` that occurs in the RT-DETR loss computation when `config.auxiliary_loss` is `False`.

## Problem

The variable `auxiliary_outputs` is conditionally assigned inside an `if config.auxiliary_loss:` block, but it's referenced later in the function regardless of whether the condition was true. When `auxiliary_loss` is disabled, this causes:

```
UnboundLocalError: local variable 'auxiliary_outputs' referenced before assignment
```

## Solution

Initialize `auxiliary_outputs = None` before the conditional block to ensure it's always defined before use.

## Changes

- Added `auxiliary_outputs = None` initialization in `src/transformers/loss/loss_rt_detr.py:450`

## Testing

This fix ensures the function works correctly whether `config.auxiliary_loss` is `True` or `False`.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42224). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Better defaults for assisted generation
Author: manueldeprada
Pull request: yes

#40657 inadvertently changed an implicit algorithmic bias: candidate_generator (the assistant model) was getting logits_processor while the decoding method (main model) was getting prepared_logits_processor. This meant that the assistant was running with T=1 while the main model was using lower temp.


We investigated and its good for speculation to have a hotter assistant model (so it was a good bug that we were not applying the lower temp to the assistant),

<img width="703" height="720" alt="image" src="https://github.com/user-attachments/assets/bd2e5459-fed1-4227-babb-2e5eca52ef2f" />
<img width="715" height="720" alt="image" src="https://github.com/user-attachments/assets/98b3f060-1673-42cb-9b00-c46d71a339a2" />
<img width="1034" height="1055" alt="image" src="https://github.com/user-attachments/assets/c2aa4d0f-61ed-4183-963e-ba5f9768cebc" />

But it should be explicitly set and not a hidden argument forwarding consequence. This PR does that, setting it by default to 1.5.

This PR also fixes:
```
FAILED tests/generation/test_utils.py::GenerationIntegrationTests::test_generated_length_assisted_generation - ValueError: Passing `MinLengthLogitsProcessor` when using `assisted_generation is disabled. Please pass in `min_length` into `.generate()` instead
```

which originates from the same change in LogitsProcessor passing.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_40976). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Stop inheriting tests (again)
Author: Rocketknight1
Pull request: yes

This is a follow up to #42192 - after discussion, we decided not to use `del` and instead to avoid importing `TestCase` classes.

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: cohere2, granitemoehybrid

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42247). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Reduce timing on CircleCI - part 1 (Use @slow for IntegrationTests)
Author: ydshieh
Pull request: yes

# What does this PR do?

Reduce timing on CircleCI.

Use `@slow` for some IntegrationTests.


Note that, for IntegrationTest class that have `setupClass`, even if a test method is fast, the `setupClass` might still take quite long time, if it downloads models. Even tokenizers may take 3 -5 seconds sometimes

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: aria, bark, hiera, imagegpt, jamba, llava, mamba, mbart, olmo2, plbart, rag, rt_detr, rt_detr_v2, speech_to_text, speecht5, tvp

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42206). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🚨 Delete generation params from model config
Author: zucchini-nlp
Pull request: yes
Labels: name: for_v5?

# What does this PR do?

Disentangles config and generation config. Now the model's config will throw an error if generation params are found. To keep BC, we'll still be loading models from the hub where generation params are in config, but we'll manually drop these params from being set as an attribute.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41695). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

cc @vasqu maybe since Joao left and I need someone to help merge generation PRs. This one particularly is blocking me. I'd love to clean-up and break BC for v5, since generation config is too complicated at this point

This PR particularly splits generation config away from model config, a dependency we had for a few ages due to legacy reasons. It's time to move on I think and raise a `ValueError` if users add manually generation params in a model config

NOTE: bad formatted configs from hub can still be loaded for BC  

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: bart, encoder_decoder, mvp, rag, speech_encoder_decoder, udop, vision_encoder_decoder

Rebased main, now the diff has no `audio`-related changes. Added the v5 tag and a rotation light as it's a bit breaking. Merging
Revert "Make tests run in less time by reducing `batch_size`"
Author: ydshieh
Pull request: yes

Reverts huggingface/transformers#42213

More tests are failing which are not detected by the CI of PR

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: albert, aria, audio_spectrogram_transformer, autoformer, bamba, bart, beit, bert, bert_generation, big_bird, bigbird_pegasus, biogpt, bitnet, blenderbot_small, bros, canine

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42258). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Cleanup reference to TFBertTokenizer and TFGPT2Tokenizer
Author: Rocketknight1
Pull request: yes

A reference to `TFBertTokenizer` was left behind after removing TF/JAX support, which caused some issues. This PR removes it!

Fixes #42175

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42182). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: bert, gpt2
delete already deprecated models
Author: ydshieh
Pull request: yes
Labels: name: for_v5?

# What does this PR do?

As discussed internally, we want to first delete these already deprecated models for V5.

(Before we add new models to deprecate)

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42235). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto

Merge , finally fixed all the issues. We have to make the process more easily in the future ... to many places to adjust