noamaanMulla-03/transformers-issues huggingface dataset:
Fix mel length computation in Qwen2-Audio
Author: anferico
Pull request: yes

# What does this PR do?

1. Updates the misleading docstring in `Qwen2AudioEncoder.forward` stating that _"Qwen2Audio does not support masking of the `input_features`"_, while in fact it _does_ make use of it. This is likely a mistake made while copying the docstring over from Whisper
2. Fixes a bug that causes the last "valid" (i.e. not masked) frame of the sequence coming out of the first two convolutional layers to be masked incorrectly when `max_mel_seq_len` is an odd number

Here's a more elaborate explanation for point 2:
`max_seq_len` represents the maximum sequence length after the first 2 convolutional layers, of which only the first one compresses the input sequences (due to `stride=2`). The compression applied by the first convolutional layer can be computed using this expression (cf. [torch.nn.Conv1d](https://docs.pytorch.org/docs/stable/generated/torch.nn.Conv1d.html)): 
```
output_length = (input_length + 2*padding - dilation * (kernel_size - 1) - 1) // stride + 1
```
which, given that:
- `padding` = 1
- `dilation` = 1
- `kernel_size` = 3
- `stride` = 2

can be simplified to:

```
output_length = (input_length - 1) // 2 + 1
```

## Before submitting
- [x] 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.
- [x] 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?


## Who can review?
@ylacombe @amyeroberts @faychu 


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

run-slow: qwen2_audio

@ylacombe @amyeroberts @faychu any news?

cc @eustlb @ebezzam
[loading/saving] Reverse all loading operations when saving
Author: Cyrilvallez
Pull request: yes
Labels: name: Core: Modeling

name: for_v5?

# What does this PR do?

As per the title! We can now revert back all our custom Operation performed during weight loading, and it's the default for BC!

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42396). 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: granite_speech, timm_wrapper
Fix fp8 UT bugs
Author: YangKai0616
Pull request: yes

# What does this PR do?

When running the tests with the command `pytest -rA tests/quantization/finegrained_fp8/test_fp8.py`, the current output reports the following errors:

```
FAILED tests/quantization/finegrained_fp8/test_fp8.py::FP8QuantizerTest::test_quantized_model - AssertionError: 'Once upon a time, there was a man who was a farmer.' != 'Once upon a time, there was a man who was very rich.'
FAILED tests/quantization/finegrained_fp8/test_fp8.py::FP8QuantizerTest::test_quantized_model_conversion - AssertionError: 122 != 146
FAILED tests/quantization/finegrained_fp8/test_fp8.py::FP8QuantizerTest::test_quantized_model_multi_accelerator - AssertionError: 'Once upon a time, there was a man who was a farmer.' != 'Once upon a time, there was a man who was very rich.'
FAILED tests/quantization/finegrained_fp8/test_fp8.py::FP8QuantizerTest::test_save_pretrained - AssertionError: 'Once upon a time, there was a man who was a farmer.' != 'Once upon a time, there was a man who was very rich.'
FAILED tests/quantization/finegrained_fp8/test_fp8.py::FP8QuantizerTest::test_save_pretrained_offload - AssertionError: 'Once upon a time, there was a man who was a farmer.' != 'Once upon a time, there was a man who was very rich.'

```

 The errors can be categorized into **two types:**

1. Model output does not match `EXPECTED_OUTPUT`

Root cause: The `_dtype` used meta model parameter dtype in [here](https://github.com/huggingface/transformers/blob/1ae4d917ed3badbdb1ffc167e0529f5a6d3c080d/src/transformers/core_model_loading.py#L741), while the `EXPECTED_OUTPUT` appears to be the result obtained with a fixed dtype of `torch.float32`. After I explicitly set `_dtype` to `torch.float32`, the result matches the expected output.

This PR updates the `EXPECTED_OUTPUT` accordingly. Please let me know your insights, thx!

2. [`nb_linears - 25 ≠ nb_fp8_linear`](https://github.com/huggingface/transformers/blob/1ae4d917ed3badbdb1ffc167e0529f5a6d3c080d/tests/quantization/finegrained_fp8/test_fp8.py#L153)

Root cause: The replacement operation in [here](https://github.com/huggingface/transformers/blob/1ae4d917ed3badbdb1ffc167e0529f5a6d3c080d/src/transformers/integrations/finegrained_fp8.py#L506) can lead to patterns like `XX.fc1.XX → XX.fc*.XX`, in which case the layer name `fc1` listed in `modules_to_not_convert` fails to match the actual layer.

This PR fixes the string matching logic.

Comments:
@SunMarc , @ydshieh , please help review, thanks!

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

run-slow: finegrained_fp8

This is a bit more complex to fix those due to the refactor, so I decided to open a PR to fix those. I've added you as a co-author. Thanks for running those tests ;) 

Alright, I will follow the changes in the new PR and close this PR.
[`RFC v5`] Encoder-decoder support for Bert-related models and GPT2
Author: vasqu
Pull request: no
Labels: name: for_v5?

Background:
- Encoder-decoder models have been introduced via incorporating already trained encoder- and decoder-only models. See https://huggingface.co/papers/1908.08345
- It relies on the fact that these models can be customized on the fly.

Issues/Motivation:
- Transformers tries to actively keep a clean code of modeling files so that users can see the direct architecture without much bloat.
- With the aforementioned feature, a lot of bloat code was introduced with multiple branches which makes maintenance harder.
- These models are now overloaded and dont have the essentials only anymore.

Proposal:
- There are 3 paths we can go from here
  - 1. Keep everything as is
  - 2. Split the modeling files properly to have a Bert encoder-only, decoder-only etc
  - 3. Drop support for encoder-decoder models composed of different models

Nothing is set yet but I'm interested in the community's usage/view on these related features, e.g. see https://huggingface.co/docs/transformers/model_doc/encoder-decoder - suggestions are greatly appreciated!

cc @ArthurZucker @Cyrilvallez @LysandreJik 

Comments:
hey i'd like to take this up can we discuss?

There is no decision yet on how we handle this concretely, i.e. see the proposal part. Would you have any preferences @Namit24?

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 T5 tests: use generation_config for generation parameters
Author: Abdennacer-Badaoui
Pull request: yes

- Update T5 integration tests to use `model.generation_config` instead of  `model.config` for generation parameters. Updated `use_task_specific_params()` to properly separate generation and config parameters, and fixed affected 
tests to comply with the new generation configuration system. 

Fix : 
`test_small_generation`
`test_summarization`
`test_translation_en_to_de` 
`test_translation_en_to_fr` 
`test_translation_en_to_ro` 


- Update expectation for `meta-llama/Llama-2-7b-hf` on rocm 

Fix: 
`test_model_7b_logits_bf16`

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

@remi-or 

run-slow: t5

This comment contains `run-slow`, running the specified jobs: 

models: ["models/t5"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19707991729)

✅ No failing test specific to this PR 🎉 !


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

run-slow: llama, t5
remove reference to TF models from docs
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

As per title

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42443). 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: albert, bart, bert, blenderbot, blenderbot_small, bros, camembert, convbert, ctrl, data2vec, deberta, deberta_v2, distilbert, electra, ernie, flaubert
Have to import cv2 and pop up window frist, or else it stuck forever
Author: leemengwei
Pull request: no

> @SSacSim Yes    One have to import cv2 and pop up window frist. Thats really annoying.
> 
> ![Image](https://github.com/user-attachments/assets/37cc08c1-9a21-4fd1-965b-6625b90f6f08)
> 
> 
> transformers             4.48.3
> opencv-python            4.10.0.84
> 
> @purusharthmalik  

 _Originally posted by @leemengwei in [#37239](https://github.com/huggingface/transformers/issues/37239#issuecomment-2882648658)_

Comments:
I'm not sure what we can do with this error! Have you tried opening an issue with openCV?

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.

Same issue  importing transformers in a conda env with cv2 causes to freeze with the first frame indefinitely,

However in the same env cv2.imshow() works when transformers is commented. 

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.

I also ran into this and I can repro this issue.

Versions:
Python 3.10.19
transformers 4.53.2

The following code gets stuck "Try to show image":

```python
import cv2
import numpy as np
from transformers import AutoImageProcessor

image = np.zeros((200, 400))
print("Try to show image")
cv2.imshow("Debug", image)
print("Success")
cv2.waitKey(2000)  # 2 seconds
```

The following unusual work around is possible:

```python
import cv2
cv2.namedWindow("Debug")
from transformers import AutoImageProcessor
import numpy as np

image = np.zeros((200, 400))
print("Try to show image")
cv2.imshow("Debug", image)
print("Success")
cv2.waitKey(2000)  # 2 seconds
```

Please re-open, this seems pretty specific to transformers; it does not happen with `import torch` alone.
replace source_keys and target_keys
Author: SunMarc
Pull request: yes

# What does this PR do?

This PR replaces `source_keys` to `source_patterns` and `target_keys` to `target_patterns`. @Cyrilvallez  forgot to update those probably because the PR was merged quite recently. Pls merge this direct as the CI is struggling

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

run-slow: mxfp4
🚨 Move `rotary_partial_emb` to RopeParams and delete unnecessary code 🔪 
Author: zucchini-nlp
Pull request: yes
Labels: name: for_v5?

# What does this PR do?

To finalize the work on rope config, I am moving `rotary_partial_emb` to rope parameter dict as well. Along with it, I did some clean-up on standardization because we can make a few assumptions with the models we have

Note, PR is breaking BC completely and users will no longer have access to `config.rope_theta` since I pop it from config kwargs manually. That way is more clear imo than having two rope thetas in different places 

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

run-slow: llama, gemma3, qwen2, qwen2_vl, mistral, mixtral, modernbert, llava

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

run-slow: apertus, arcee, aria, bamba, bitnet, blt, chameleon, cohere, cohere2, csm, cwm, dbrx, deepseek_v2, deepseek_v3, dia, diffllama

This comment contains `run-slow`, running the specified jobs: 

models: ["models/gemma3", "models/llama", "models/llava", "models/mistral", "models/mixtral", "models/modernbert", "models/qwen2", "models/qwen2_vl"]
quantizations: []

Doc-builder and weight tying tests will fail but are not related

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19761713366)

✅ No failing test specific to this PR 🎉 !
Fix doc builds
Author: Rocketknight1
Pull request: yes

Doc builds on main are currently failing with errors in this segment. For simplicity before the launch, I'll just remove the example for now!

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

run-slow: llama

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42478). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Nightly / Nvidia CI workflows trigger on forks and fail due to missing org-specific runners
Author: AvinashDwivedi
Pull request: no
Labels: name: bug

### System Info

When forking the huggingface/transformers repository, certain GitHub Actions workflows (like “Nvidia CI with nightly torch” and “Nightly PyTorch build”) are automatically triggered on the forked repo’s default branch (main) — even though they depend on organization-specific GPU runners and secrets.

This leads to immediate workflow failures and email notifications such as:

Run failed: Nvidia CI with nightly torch - main (...)

<img width="1750" height="1205" alt="Image" src="https://github.com/user-attachments/assets/513427b6-3992-4f95-aae4-c50676b2dc29" />


### Who can help?

_No response_

### 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

Fork the upstream repository huggingface/transformers on GitHub (press Fork in the web UI).

### Expected behavior


Forked repositories should:

1. not trigger organization-specific CI pipelines, or
2. gracefully skip such jobs without failure.

Comments:
cc @ydshieh

Hello @AvinashDwivedi 

You can follow

https://github.com/huggingface/transformers/pull/41515#issuecomment-3411212852

to disable the workflow on the forked repository

Thank you, @ydshieh. I'll do that right away, but I still don't feel that this is the right solution, as it should automatically select whether to start the workflows or not whenever someone forks the repository. Please let me know if you have something in mind that I can work on in a PR.

Hi @AvinashDwivedi 

It's a design of Github, I agree with you, however we will simply suggest people to disable the workflows on their forked repositories.

You can try to open a discussion https://github.com/orgs/community/discussions?discussions_q=label%3AActions

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.

I will close the issue as the best way we can do without too much unnecessary effort is provided. Thank you for understanding.
[cleanup] Don't use Repository in create_dummy_models.py script
Author: Wauplin
Pull request: yes
Labels: name: for_v5?

Hopefully last cleanup PR from me before v5 :)

Mentioned as a TODO in https://github.com/huggingface/transformers/pull/40889. This PR updates `create_dummy_models.py` to use `upload_folder` instead of `Repository` class (which doesn't exist anymore).

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

Thank you @Wauplin , this would push me to really rework the script to make it better (currently failing to create quite many tiny models )
Skip failing irrelevant test for ColQwen2
Author: Rocketknight1
Pull request: yes

ColQwen2 doesn't do weight tying in the normal way, so this test fails and isn't too relevant anyway.

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

run-slow: colqwen2

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

The CI is red right now, so let's just merge for launch and figure it out after!
[quantization] make torchao tests slow
Author: MekkCyber
Pull request: yes

# What does this PR do?

Simply makes the tests slow

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

run-slow: torchao_integration

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42482). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix gpt2 tokenizer `add_prefix_space` default value 
Author: SunMarc
Pull request: yes

# What does this PR do?

This PR fixes a regression wrt gpt2 tokenizer. `add_prefix_space` should be `False`, not sure if there are other regression like that cc @itazap 

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

run-slow: gpt2

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42481). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[`Docs`] Fix build on other langs
Author: vasqu
Pull request: yes

As per title

Comments:
build-doc

[Building docs for all languages...](https://github.com/huggingface/transformers/actions/runs/19771241973)

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

build-doc

[Building docs for all languages...](https://github.com/huggingface/transformers/actions/runs/19771519330)
Fix broken models due to modeling/weight mapping
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. A few models got broken in https://github.com/huggingface/transformers/pull/41580, but it was silent issues on the fast tests.
Mostly discovered in https://github.com/huggingface/transformers/pull/42396, because the new tests added were not passing for those models, due to the models and not the logic of that PR.

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

actually needing this for https://github.com/huggingface/transformers/pull/42456 for jamba + lfm2

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

run-slow: lfm2_moe, sam3, sam3_tracker, sam3_tracker_video

Yes will enforce it with ast later for sure! Along with the `post_init`
Fix minor bugs in ConversionOps and WeightConverter
Author: SunMarc
Pull request: yes

# What does this PR do?

This fixes a couple of minor details in ConversionOps and WeightConverter. We still need to pass `full_layer_name` as we won't be able to get the module otherwise. Also dim is not always defined, so the __repr__ was failing.

cc @Cyrilvallez for vis

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

run-slow: gpt2

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42479). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Added fast image processing for ImageGPT - initial commit
Author: wadkisson
Pull request: yes

Summary - 
The PR modified the ImageGPT processor to implement PyTorch and TorchVision to replace NumPy and PIL operations for more efficient preprocessing. This PR keeps the same functionality of the original, slow processor but implemented BaseImageProcessorFast for more optimal speed.

Notes - 
Hi everyone -- this is my first ever pull request! I tried to keep changes minimal and adhere to all the conventions I came across as strictly as I could. Any feedback on this would be greatly appreciated!
Thanks guys.

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

cc @yonigozlan 

Hello! Just wanted to check up on this. Let me know if there's anything I need to to!

Hi again! I just resubmitted my updated code. I'm still pretty new to this, so let me know what else I need to do, and I'll be right on it!

gentle ping @yonigozlan!