noamaanMulla-03/transformers-issues huggingface dataset:
Should `compute_metrics` only run on the main process when doing DDP?
Author: TIE666
Pull request: no

Hi,  I want to know when doing training and evaluation on a multi-GPU setup (DDP using trainer and accelerate), does `compute_metrics` only need to be run on the main process?

The reason being that `trainer` itself already does `gather_for_metrics` ([here](https://github.com/huggingface/transformers/blob/v4.51-release/src/transformers/trainer.py#L4373)), which I suppose should collect all predictions (logits) and labels across processes, running `compute_metrics` from multiple processes again will be doing duplicated work, no?

to add:
I am using `batch_eval_metrics`, where I first spotted that if I run the training script (modified version of `run_clm.py`) with `accelerate launch`, the `compute_metrics` is always called multiple times, but the logits from `EvalPrediction` for each call is `per_device_eval_batch_size` * number of GPU I am using.

Comments:
cc @sunmarc

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.
video_auto_processing.py breaks everything
Author: lucasjinreal
Pull request: no
Labels: name: bug

### System Info

the video preprocessor now breaks everytthing,

I have a model which need Qwen2.5 VL preporssor, it's OK before, but now it can not load, breaks.

My model just need Qwen2.5 VL preprocessor, it doens't have Qwen2.5 VL arch, it's a customized model.
But now, the video prerproecssor will reading the config arch in my model, rather than just the preprocessor.config.json

This is weired.

You have video processor config saved in `preprocessor.json` file which is deprecated. Video processor configs should be saved in their own `video_preprocessor.json` file. You can rena
me the file or load and save the processor back which renames it automatically. Loading from `preprocessor.json` will be removed in v5.0.



```
from transformers import AutoProcessor, Qwen2_5_VLProcessor

processor_path = './checkpoints/Qwen3-VL-2B-Unofficial'
a = Qwen2_5_VLProcessor.from_pretrained(
                processor_path, trust_remote_code=True
            )
print(a)
```

This code can be used without `config.json` must be a registered model, but now, it need `confgi.sjon` must be a reigstered mdoel, even though I just need `preprocess_config.json`

Please remove the video processor code, it's useless and introduce many bug!

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

from transformers import AutoProcessor, Qwen2_5_VLProcessor

processor_path = './checkpoints/Qwen3-VL-2B-Unofficial'
a = Qwen2_5_VLProcessor.from_pretrained(
                processor_path, trust_remote_code=True
            )
print(a)

### Expected behavior

from transformers import AutoProcessor, Qwen2_5_VLProcessor

processor_path = './checkpoints/Qwen3-VL-2B-Unofficial'
a = Qwen2_5_VLProcessor.from_pretrained(
                processor_path, trust_remote_code=True
            )
print(a)

Comments:
Fixed by https://github.com/huggingface/transformers/pull/38840

Will 4.53.1 introduce this fix? Also, does it still will need config.json to load the video processor when users might have a customized model and only need image preprocessor?

Yes, it will be in the next v4.53 release and will not require to have `config.json` saved. For BC we'll check if there's an `image_processor` config first

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.
Make pytorch examples UV-compatible
Author: lhoestq
Pull request: yes

... by adding the dependencies headers

I'm adding them to all the pytorch examples except the "question-answering" folder since they're not single file scripts.

I also updated release.py to update the UV dependencies accordingly:
- for dev version, require `transformers @ git+https://github.com/huggingface/transformers`
- for release version, require `transformers==VERSION`

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

# What does this PR do?

Outdated `Cache` references in the Korean docs are breaking our full doc builder run -> https://github.com/huggingface/transformers/actions/runs/16446789118/job/46480867839

This PR copy-pastes `Cache` references from the English docs.

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

@manueldeprada not quite, I will have a look :)
fix(voxtral): correct typo in apply_transcription_request
Author: rev2607
Pull request: yes
Labels: name: Audio

# What does this PR do?

Fixes a typo in the method name `apply_transcrition_request` → `apply_transcription_request` inside `src/transformers/models/voxtral/processing_voxtral.py`.

This PR addresses [issue #39530](https://github.com/huggingface/transformers/issues/39530). The method was misspelled and is now corrected for clarity and consistency. This change may also require updates in model cards if this method is referenced there.

Fixes #39530

## Before submitting
- [x] This PR fixes a typo or improves the docs.
- [x] I have read the [contributor guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request).
- [x] This was discussed/approved via [issue #39530](https://github.com/huggingface/transformers/issues/39530).
- [ ] No new documentation or tests were required for this minor change.

## Who can review?

@speech models: @eustlb


Comments:
Hi @eustlb, this PR fixes the typo in the method name mentioned in #39530. Kindly review when you get a chance 😊


Thanks for finding this inconvenient typo... agree with @qubvel. @rev2607 can you add the suggested change so that we ensure we support both?
Once merged, I'll take care of updating the hub model cards.

Thanks for the feedback @qubvel and @eustlb! I've pushed the requested changes to fix the typo and add the temporary wrapper. Let me know what you think. 

@rev2607 can you please update `voxtral.md` file in the repo as well?

Thanks, @qubvel. I've updated voxtral.md as requested.

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

run-slow: voxtral

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

models: ['models/voxtral']
quantizations: [] ...

Checking slow tests (likely compute related)
Edit: merging #39605 quickly to update to runners values

run-slow: voxtral

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

models: ['models/voxtral']
quantizations: [] ...

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

run-slow: voxtral
Typo in `apply_transcrition_request` method name
Author: xenova
Pull request: no

https://github.com/huggingface/transformers/blob/34133d0a790787739bfc9a42603985de3728ede4/src/transformers/models/voxtral/processing_voxtral.py#L287

should most likely be `apply_transcription_request` :)
cc @eustlb 

I would open a PR, but this will also require some updates to the various model cards (which use this method name).

Comments:
Rename huggingface_cli to hf
Author: LysandreJik
Pull request: yes

Adapt the docs to `huggingface_hub` PR https://github.com/huggingface/huggingface_hub/pull/3229

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39630). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix ModernBERT Decoder model
Author: qubvel
Pull request: yes
Labels: name: bug

# What does this PR do?

as in title


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

run-slow: modernbert_decoder

run-slow: modernbert_decoder

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

models: ['models/modernbert_decoder']
quantizations: [] ...

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

# What does this PR do?
Fix #39558

The bug fixe now shows:
```python
Number of returned hidden states: 17
hidden state  0 values (slice): tensor([0.0045, 0.0166, 0.0210])
hidden state  1 values (slice): tensor([-0.0010,  0.0339,  0.0018])
hidden state  2 values (slice): tensor([ 0.2473, -0.5012,  1.5765])
hidden state  3 values (slice): tensor([ 0.2444, -0.5238,  1.5824])
hidden state  4 values (slice): tensor([ 0.2463, -0.5339,  1.5775])
hidden state  5 values (slice): tensor([ 0.2797, -0.5208,  1.6037])
hidden state  6 values (slice): tensor([ 0.2424, -0.4786,  1.6114])
hidden state  7 values (slice): tensor([ 0.2291, -0.4361,  1.5910])
hidden state  8 values (slice): tensor([ 0.2474, -0.3626,  1.5842])
hidden state  9 values (slice): tensor([ 0.2487, -0.3277,  1.4880])
hidden state 10 values (slice): tensor([ 0.1552, -0.2746,  1.4607])
hidden state 11 values (slice): tensor([ 0.1235, -0.2442,  1.3794])
hidden state 12 values (slice): tensor([ 0.1107, -0.2346,  1.3300])
hidden state 13 values (slice): tensor([ 0.0789, -0.2590,  1.3076])
hidden state 14 values (slice): tensor([ 0.3292, -0.3711,  1.1052])
hidden state 15 values (slice): tensor([ 0.4628, -0.6839,  1.1164])
hidden state 16 values (slice): tensor([ 0.2918, -0.4089,  1.8382])
```

This will not work for gemma, but the effort for gemma is to record the hidden states before the forward, a hack but can be done if this break anyone's workflow:
```python 
        def make_capture_wrapper(module, orig_forward, key, index):
            @wraps(orig_forward)
            def wrapped_forward(*args, **kwargs):
                if "hidden_states" in collected_outputs:
                    collected_outputs[key] += args[0]
                output = orig_forward(*args, **kwargs)
                if not isinstance(output, tuple):
                    collected_outputs[key] += (output,)
                elif output[index] is not None:
                    collected_outputs[key] += (output[index],)
                return output

            return wrapped_forward
```
something like that 😉 


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39636). 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: arcee, aria, bitnet, cohere, cohere2, csm, deepseek_v2, deepseek_v3, diffllama, dots1, emu3, ernie4_5, ernie4_5_moe, gemma, gemma2, gemma3
fix `kyutai` tests
Author: ydshieh
Pull request: yes

# What does this PR do?

> HF_HOME=/mnt/cache HF_HUB_READ_TOKEN=hf_XXX RUN_SLOW=1 python3 -m pytest -v --flake-finder --flake-runs=10   tests/models/kyutai_speech_to_text/test_modeling_kyutai_speech_to_text.py::KyutaiSpeechToTextForConditionalGenerationIntegrationTests::test_generation_batched

It might be from a numerical stability issue, only 3 elements are different.

```
(Pdb) EXPECTED_TOKENS[2, 157:164]
tensor([3232,    3,    0,  269,    3,    3,    0])
(Pdb) out.cpu()[2, 157:164]
tensor([3232,    3,    3,    0,  269,    3,    0])
(Pdb)
```

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39416). 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: kyutai_speech_to_text

got 

> FAILED tests/models/kyutai_speech_to_text/test_modeling_kyutai_speech_to_text.py::KyutaiSpeechToTextForConditionalGenerationIntegrationTests::test_generation_batched - AttributeError: 'MimiModel' object has no attribute '__name__'. Did you mean: '__ne__'?


after merged the latest main. Rashan is on it. 

I am going to merge
update expected outputs for whisper after #38778
Author: ydshieh
Pull request: yes

# What does this PR do?

The differences are actually minor (mostly at the end of the outputs)


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

@gante 🙏 

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

run-slow: whisper

simply updated the values again (the diff is still minor, might be from the several PRs during my time off)
Inference API Returning 404
Author: FoundationINCCorporateTeam
Pull request: no
Labels: name: bug

### System Info

So I am using the hugging face inference API and the model wont work on the inference API but works in the hugging face model playground: huggingface_hub.errors.HfHubHTTPError: 404 Client Error: Not Found for url: https://router.huggingface.co/hf-inference/models/HuggingFaceTB/SmolLM3-3B  What should I do?

### Who can help?

_No response_

### Information

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

### Tasks

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

### Reproduction

To reproduce use the hugging face API on: HuggingFaceTB/SmolLM3-3B

### Expected behavior

The expected behavior is to get a response to the request. When you get a parameter wrong when sending a request it gives a correct error message for that param but when you get everything correct it sends 404

Comments:
This is the HF Hub rather than the Transformers library, so I'm closing the issue, but it might might be a good question for the support space! Try posting there https://huggingface.co/spaces/transformers-community/support
Grammatical error in the "Loading model's" page
Author: marcndo
Pull request: no

There seems to be a grammatical error in the sentence on the "Loading model's" page. The sentence currently reads:

"Call from_pretrained() to download and load a models weights and configuration stored on the Hugging Face Hub."

This should be corrected to:

"Call from_pretrained() to download and load a model's weights and configuration stored on the Hugging Face Hub."

This correction ensures the sentence is grammatically correct and the possessive form of "model" is used properly. 

Comments:
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.

Closing since #39019 has been merged
fix dead NVIDIA link 
Author: lidanserj
Pull request: yes

Hey team! Found and fixed dead link in src/transformers/models/mamba/modeling_mamba.py

https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/model/gpt_model.py - old
https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/legacy/model/gpt_model.py - new

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

run-slow: mamba

@lidanserj some models inherit from mamba via modular - you might need to change those too or run `make fix-copies` locally to get the tests to pass!

@Rocketknight1  should I wait for your suggestions, or can I get started?

@lidanserj no suggestions - but you do need to run `make fix-copies` or something like that to get the CI to pass. Once it's green, you can ping me and I'll merge this!

<img width="751" height="178" alt="image" src="https://github.com/user-attachments/assets/440af76c-d98f-41d4-bbd5-b42f2eb4ec93" />
Add missing flag for CacheLayer
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

The flag is absolutely critical to work correctly, as the mask creation functions rely on it.
This fixes all the `generate_beyond_sliding_window` tests

cc @manueldeprada @ydshieh for viz

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39678). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add Deepseek-VL
Author: ArthurZucker
Pull request: no
Labels: name: New model

### Model description

Deepseek-VL: 
- [paper](https://arxiv.org/abs/2403.05525) 
- [code](https://github.com/deepseek-ai/DeepSeek-VL/) 
- [weights](https://huggingface.co/collections/deepseek-ai/deepseek-vl-65f295948133d9cf92b706d3)

### Open source status

- [ ] The model implementation is available
- [ ] The model weights are available

### Provide useful links for the implementation

_No response_

Comments:
Fix auto_docstring crashing when dependencies are missing
Author: yonigozlan
Pull request: yes

As the title says, simply use a try except for now until I come up with a better solution

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39564). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add unit test: text-classification pipeline handles empty string
Author: ckakgun
Pull request: yes

## What does this PR do?

This  pull request adds a unit test to the `text-classification` pipeline to verify that it can handle an empty string input without raising an error, and returns an empty list. This improves test coverage for an edge case.

## Motivation

Sometimes a user fills empty input into a pipeline by mistake.  This test ensures that the pipelines deal with the issue of having an empty string.



Comments:
hi @ckakgun is this something the pipeline is failing at right now, or does the test just verify behaviour that already works?

Hi @Rocketknight1! thanks for the reply.
This test verifies a behavior that already works. It aims to improve test coverage for an edge case (empty input) to ensure stability.

Hmmn - I'm not sure the test is needed. I don't know if we need defined behaviour in the case when the pipeline is passed an empty string. since it's not clear to me what the user's expectations should be there! It also seems like something we might break/change in future, and I don't want the test to make any guarantees about what happens in case they become invalid later.

Still, thank you for the PR! Feel free to keep contributing in future.
Does Gemma 3 need positions ids to be 1-indexed explicitly?
Author: krypticmouse
Pull request: no

Hi Team

At some point `Gemma3ForConditionalGeneration` used to impose a 1-indexing of `position_ids`, [see here](https://github.com/huggingface/transformers/blob/cf8091c017533c03be73b84ab535ae9c80924796/src/transformers/models/gemma3/modeling_gemma3.py#L1430). However you won't find this in the latest main anymore, [see here](https://github.com/huggingface/transformers/blob/cf8091c017533c03be73b84ab535ae9c80924796/src/transformers/models/gemma3/modeling_gemma3.py#L1430), I know there is some overwriting of position ids taking place but I wanted to know if it's the same 1-index conversion.

Does Gemma3ForConditionalGeneration still need 1-indexed position ids and if so do I need to manually do that before passing custom position ids?

Comments:
I don't think you should ever need to manually create 1-indexed position IDs for Gemma! If a model uses offset position IDs, it should handle that internally. The values you pass should always be 0 indexed.

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.
Use auto_docstring for perception_lm fast image processor
Author: yonigozlan
Pull request: yes

Nit, as the title says

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

run-slow: perception_lm

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

# What does this PR do?

This PR supersedes https://github.com/huggingface/transformers/pull/35377 for convenience, because I could not push on the other PR for some final cleanups (org where the fork was made is protected or something)


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39665). 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, xlstm
Add ep
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Add support for expert parallel!

Comments:
Does not work for mixtral, tricky because of the sequentiality of the weights. 
I would need to tap into fusing them on the fly.

I'll add something that allows for this, but also a plan that allows for one the fly merging the modulelist to the format for megablocks

Will getting deepseek working too be pretty straightforward?

Yes and no! for both I used nn.Modulelist() (deepseek I had no choice and Mixtral I was junior) and so it's a bit more annoying, but yes because next pr will make sur we have a bit of a better interface! 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39501). 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: llama4