noamaanMulla-03/transformers-issues huggingface dataset:
Add clear error message for missing SentencePiece model in `get_spm_processor` (fix #41553)
Author: AvinashDwivedi
Pull request: yes

Fix: clearer error when SentencePiece model file is missing for Llama tokenizer

Fix:
Improved error handling in get_spm_processor to provide a clear, actionable message when the required SentencePiece model file is missing.

Before:
The tokenizer raised an unhelpful low-level
```python
TypeError: not a string
```
from the SentencePiece library when vocab_file was None.

After:
It now raises a concise, human-readable error:
```python
ValueError: Missing SentencePiece model file: 'None'. 
This tokenizer requires a .model file provided by the 'mistral-common' package. 
Install it with: pip install mistral-common
```

Fixes: #41553
<img width="2000" height="1346" alt="Screenshot 2025-10-14 191309" src="https://github.com/user-attachments/assets/cb23a855-40d9-4d1b-8997-1138936c3eb9" />

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

run-slow: llama

@ArthurZucker would you please help me why I'm seeing checks are failing although the changes are very small. I'm new to opensource So, please help me sir!

I think it's strange to reference `mistral-common` in the `Llama` tokenizer, but up to you @arthurzucker @itazap!

Copy pasting a bit but let's coordinate https://github.com/huggingface/transformers/issues/41553#issuecomment-3406606156

@ArthurZucker @Rocketknight1 as I can see this issue is still not solved can you guys give me some idea how you want it? I'll make it exactly same as you want it.
Double router compute?
Author: molbap
Pull request: yes

# What does this PR do?

Not sure what the intended fix is (force f32 or not) but currently the first is ignored

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41653). 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
Fix confusing cls assignment
Author: cyyever
Pull request: yes

# What does this PR do?

Don't overwrite `cls` incidentally in `__new__`.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41642). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[kernels] refactor function kernel calling
Author: MekkCyber
Pull request: yes

# What does this PR do?

This should simplify lazy kernel loading in Transformers.  
We simply define a mapping between each kernel name and the repository it should be pulled from, then load it using the `lazy_load_kernel` function. This function adds the kernel to a global cache shared across all models.  
If the kernel isn’t available, we check whether it’s installed as a module for backward compatibility; otherwise, we return `None`.


Comments:
run-slow: falcon_mamba, mamba

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

models: ['models/falcon_mamba', 'models/mamba']
quantizations: [] ...

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41577). 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: falcon_mamba, mamba
Incorrect access of dataset field fixed
Author: vignesh1507
Pull request: yes

In `test_tokenizer`:

`for text in dataset[i]["premise"].values():
    test_string(slow, fast, text)

# hypothesis, all languages
for text in dataset[i]["hypothesis"]["translation"]:
    test_string(slow, fast, text)`

The "premise" field in the XNLI dataset is a string, not a dictionary**. Calling .values() on a string will raise an error. Similarly, "hypothesis" is also a string (not a dictionary), so "hypothesis"]["translation" will fail.

Comments:
cc @ydshieh do you know if this script is still in use?

@Rocketknight1 

Can't find any usage in the codebase. The recent changes in the history are more about type hints. Let's remove it.
purge HF_HUB_ENABLE_HF_TRANSFER; promote Xet
Author: Vaibhavs10
Pull request: yes


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

# What does this PR do?

This PR should all simple trainer tests and some deepspeed tests. 
The only remaining tests to fix are deepspeed z2 grad acc tests but this is strange why it is failing ... cc @IlyasMoutawwakil maybe you have an idea as you worked on it for `HPU` 

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

hey @ydshieh is there a simple way to run trainer tests like the other tests ? 

Merging as the failing processor test is known and unrelated!

> hey @ydshieh is there a simple way to run trainer tests like the other tests ?

Do you mean

run-slow: trainer

? I think it would work
[`Masks`] Fix mask handling in eager for vision models
Author: vasqu
Pull request: yes
Labels: name: Vision

As per title, some vision models use masks, let's sync with bert this time and reduce errors that could be introduced

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

run-slow: audio_spectrogram_transformer, deit, dinov2, dinov2_with_registers, dinov3_vit, dpt, ijepa, videomae, vit, vit_mae, vit_msn, vitpose_backbone, vivit, yolos

il faut run-slow svp, Monsieur, au moins une parti 🙏 

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

run-slow: audio_spectrogram_transformer, deit, dinov2, dinov2_with_registers, dinov3_vit, dpt, ijepa, videomae, vit, vit_mae, vit_msn, vitpose_backbone, vivit, yolos

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

models: ['models/audio_spectrogram_transformer', 'models/deit', 'models/dinov2', 'models/dinov2_with_registers', 'models/dinov3_vit', 'models/dpt', 'models/ijepa', 'models/videomae', 'models/vit', 'models/vit_mae', 'models/vit_msn', 'models/vitpose_backbone', 'models/vivit', 'models/yolos']
quantizations: [] ...

Checked against main and the failing tests are the same, videomae in general seems to be broken tho (integration tests)
Add in-out modalities as class attribute per model
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Branches out from https://github.com/huggingface/transformers/pull/40884#discussion_r2400964015 to make review and merge faster

Adds a class attr for each model to indicate the supported input and output modalities. Out modalities will be `None` in case the model is not generative and "text" in most other cases. We have only a few models that can generate audio and image in the output. Note that for encoder decoder models that whisper the input modalities will contain both encoder ("audio") and decoder ("text") modalities

This will be used firstly for the pipeline and we can extend usage later to better testing suite and in preparing inputs better in generation with multimodal LLMs (e.g. if we move multimodal encoding to `GenrationMixin._prepare_multimodal_encodings`). No test added at this point, because there is nothing to test

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

> E.g. can we look at the signature of forward and, based on arguments present / type hints, determine modalities?

yeah, also thought of it. It is doable for most models but there are some tricky ones as well, For example we don't have a consistent naming habit for video modality or we have no way to say what is being output by a model that has an overwritten `generate()`. We can have have a default to `input_modalities` as well similar to `output_modalities`, but then manually overwrite all models where the pattern does not match

> We can have have a default to input_modalities as well similar to output_modalities, but then manually overwrite all models where the pattern does not match

imo this would be an improvement :) also an incentive to nudge contributors towards standard names and definitions!

But check with @ArthurZucker before committing code!

(See [tenet](https://huggingface.co/spaces/transformers-community/Transformers-tenets) number 4: standardization for model definitions, abstractions for infra. I would place this under infra)

I think this is a decent approach. waiting on this PR as it helps quite a lot - rather than depending on heuristics or some sort of registry we want to get the input-output modalities supported by the model via config. I hope we can adopt this as a standard soon @ArthurZucker 

@bot /style

Style fix is beginning .... [View the workflow run here](https://github.com/huggingface/transformers/actions/runs/18404040452).

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

run-slow: aimv2, align, altclip, aria, audio_spectrogram_transformer, autoformer, aya_vision, bark, beit, bit, blip, blip_2, blt, bridgetower, chameleon, chinese_clip
Fix dtype casting with quantization
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

We should always trust the dtype of the params in the meta model, except when the parameter is going to be quantized!
Got broken in https://github.com/huggingface/transformers/pull/41548, where we stopped looking at the `keep_in_fp_32_regex`, to instead trust the model dtypes directly!

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

# What does this PR do?

Serving is broken with continuous batching to due recent PRs. This PR fixes it 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41624). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Small changes to benchmarking script
Author: remi-or
Pull request: yes

This PR:
- adds throughput to the final pretty print at the end of the benchmark runs
- adds the information of the output shape to the decoded text of the output (usefull to double check if throughput is right)
- changes the behavior of the `run_benchmarks.py` script so that it will only run 3 configs unless instructed to do otherwise

This way, anyone can run a "quick"
```
python benchmark_v2/run_benchmarks.py --model-id "meta-llama/Meta-Llama-3-8B" -b 32 -s 128 -n 256
```
after changing the `generate` code or some model specific code to check perf did not take a big hit. 
Thanks @SunMarc for the suggestion!

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41662). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Erroneous flash attention version check
Author: franzscherr
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.57.0.dev0
- Platform: Linux-6.11.0-29-generic-x86_64-with-glibc2.35
- Python version: 3.11.13
- Huggingface_hub version: 1.0.0.rc5
- Safetensors version: 0.6.2
- Accelerate version: not installed
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.8.0+cu128 (CUDA)
- Using distributed or parallel set-up in script?: no
- Using GPU in script?: yes
- GPU type: NVIDIA RTX PRO 6000 Blackwell Workstation Edition

### Who can help?

@Cyrilvallez 

### Information

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

### Tasks

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

### Reproduction

1. create image
```Dockerfile
FROM pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel

RUN apt-get update && apt-get install -y wget git
RUN wget -nv https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.3/flash_attn-2.8.3+cu12torch2.8cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
RUN pip install flash_attn*
RUN pip install sgl-kernel
RUN git clone https://github.com/huggingface/transformers
RUN pip install -e transformers
```
2.
```python
from transformers.utils import import_utils
import_utils.is_flash_attn_2_available()
```

will report `False`.

### Expected behavior

It should report `True`.

The issue likely is because `import_utils._is_package_available` gets the package version from index `0` of `importlib.metadata.packages_distributions()["flash_attn"]`.
The distribution_name resolves to `sgl-kernel` instead of `flash_attention` in this case.

What about giving precedence to distributions that match the package name?

Comments:
@franzscherr this seems like an easy fix could you assign this issue to me 

Arf, sorry @yashisthebatman, I started working on this before I saw your comment... It will be fixed by https://github.com/huggingface/transformers/pull/41661, thanks a lot for the report @franzscherr!

@Cyrilvallez no problem mate!!
Improve package version check
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/41651. In very niche cases, a package may have several distributions, leading to potential issues in our current check (if the wrong one is first). This PR fixes it by checking if a distribution of the same name exists

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41661). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
improve `utils/check_bad_commit.py`
Author: ydshieh
Pull request: yes

# What does this PR do?

This script (used to find which commits fail certain failing tests on our CI) fails recently, due to the fact that the warning `sys:1: DeprecationWarning: builtin type swigvarlink has no __module__ attribute` was written to `stderr` and we use `stderr` to check if there is error.

This is not a good approach, we should instead check `result.returncode`. Also a few improvements added along this here

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

> Do we want this to be a permanent solution or is it a workaround for now? Let's see how it fares

Kind of, it is improved along the time: it's use `git bisect` (with subprocess) which calls a  script (created on the fly) (a nested subprocess), so a bit complicated to handle the scenario. 

Later, I will need to handle the flaky tests too to make the results more reliable.
Add missing dates to docs
Author: yonigozlan
Pull request: yes

Not sure how these slipped through, this should have broken repo-consistency. I'll investigate.

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

Yes the script to generate `release_date` looks for arxiv or huggingface papers and use their release date. But we have plenty of model cards without arxiv or hf papers links, so I'll work on a better solution, or just remove the release date part if no links are found

Hi @yonigozlan, I was the author of this add_dates script. Firstly, thanks for improving the script in your previous commits, although I have not yet seen the changes. Let me try to explain the context behind this script briefly.

There was an ongoing issue to improve the model cards by @stevhliu and in the new standard of the docs, paper abstract was supposed to be removed in favor of a hf paper link and/or blogpost link. The rough dates were added so that the models could be organized in terms of recency (this helps in exploring the changes in a particular model series or modality over time). The reason why it uses the date from hf paper or otherwise stays "release_date" is to enforce the addition of the paper on hf papers (acts as a reminder). There was also a global variable for storing a list of papers that are on arxiv but not yet on hf papers. Moreover, if the model was released on a blog post, it is crucial that the contributors attach the blogpost link in the card and manually add the release date from the blog post.

For instance, cwm paper has the wrong link (fb link), it should be the hf paper link https://huggingface.co/papers/2510.02387 and the abstract must also be removed. For lfm2_moe, they released it with a blog post instead of a paper, so the [link](https://www.liquid.ai/blog/liquid-foundation-models-v2-our-second-series-of-generative-ai-models) to the blog post must be added and the contributor must manually add the date (10th july 2025) as 2025-7-10.

When this script was merged to main (~august), I had ensured that almost all the model till then have the correct release dates and sufficient links to backtrack the source of those models. 

That makes sense @MHRDYN7 ! We can try to be more strict then and have a the check-repo-consistency check fail when we are missing release dates for some models (with a message that encourage them to add a link to hf papers)
Erroring when KernelConfig is passed without use_kernels = True
Author: MekkCyber
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_41657). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `chat_extras.md` to Korean
Author: Judy-Choi
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `chat_extras.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [x] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 KREW 팀원들에게 리뷰를 요청하는 아래 주석을 노출해주세요!-->
May you please review this PR?
<!-- @jungnerd, @luckyvickyricky, @chelsseeey, @skwh54, @amo33, @maximizemaxwell, @D15M4S -->
@harheem, @nsbg, @Youngdong2, @xhaktm00, @ssunbear, @ChoHyoungSeo
<!-- @4N3MONE, @Kim-Ju-won, @ahnjj, @FacerAin, @ssum21, @TaskerJang, @HyunZ118 -->
<!-- @yijun-lee, @songi104, @chhaewxn, @AhnJoonSung, @jihyun-0611, @seopp, @pyapyapya -->

## 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#start-contributing-pull-requests),
      Pull Request section?
- [x] 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? (Final)

<!-- 2. KREW 팀원들의 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
LGTM! 번역 고생하셨습니다!!
전반적으로 자연스러운 번역이였어요ㅎㅎ

@stevhliu
May you please review this PR?
Thanks!

Thanks! The doc-builder is currently having some issues with building translated docs. Currently working on a fix and I'll merge for you once the issue is resolved!

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39863). 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/18568130304)
🌐 [i18n-KO] Translated `image_processor.md` to Korean
Author: ahnjj
Pull request: yes

# What does this PR do?

Translated the `image_processor.md` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [ ] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? -->
<!-- @jun048098, @yijun-lee, @mreraser, @shinhyunji36, @heuristicwave -->
<!-- @win2dvp21, @enchantee00, @fabxoe, @1kmmk1, @junejae -->
<!-- @SeungAhSon, @Jwaminju, @thsamajiki, @4N3MONE, @jungnerd -->
<!-- @mjk0618, @cjfghk5697, @ahnjj, @JinukHong, @nuatmochoi -->
<!-- @010kim, @chhaewxn, @boyunJang, @jeongiin, @harheem -->
@chhaewxn, @ahnjj, @jun048098, @fabxoe

## 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#start-contributing-pull-requests),
      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).
- [ ] Did you write any new necessary tests?

## Who can review? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR? 

Comments:
LGTM!

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

> Thanks, just need to resolve the merge conflict!

@stevhliu Thanks for the review! I know it's been so late, but I would appreciate it if you could recheck it to be merged :)

No problem, would you mind resolving the failing CI tests and then I can merge for you?