noamaanMulla-03/transformers-issues huggingface dataset:
Remove SageMakerTrainer
Author: cyyever
Pull request: yes
Labels: name: for_v5?

# What does this PR do?

It is replaced by Trainer.

Comments:
@ydshieh sagemaker is still supported, although not in its own Trainer. Unless we feel that the test code is outdated, `tests/sagemaker/scripts/pytorch/run_glue_model_parallelism.py` can' be deleted (it is invoked by other scripts of `tests/sagemaker/scripts`, deleting it and all its invokers means eventually we have to delete the whole folder..).

But I have deleted `tensorflow` related stuff...

Thanks for pointing out. Let's keep it then 👍 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41267). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
MoE + vllm = 😻 
Author: ArthurZucker
Pull request: yes
Labels: name: Mixture of Experts

# What does this PR do?
Starting with vllm, but also towards better training

TODO:
- DBRX, GPTSAN, ERNIE4.5, Jamba (ça été fait par ia je crois), Minmax pareil,  NllbMoe, PhiMoe (AI based), switch et vitpose)








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

run-slow: aria, bamba, dbrx, deepseek_v2, deepseek_v3, dots1, ernie4_5_moe, falcon_h1, flex_olmo, glm4_moe, glm4v_moe, gpt_oss


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

models: ['models/aria', 'models/bamba', 'models/dbrx', 'models/deepseek_v2', 'models/deepseek_v3', 'models/dots1', 'models/ernie4_5_moe', 'models/falcon_h1', 'models/flex_olmo', 'models/glm4_moe', 'models/glm4v_moe', 'models/gpt_oss']
quantizations: [] ...

run-slow: aria, bamba, dbrx, deepseek_v2, deepseek_v3, dots1, ernie4_5_moe, falcon_h1, flex_olmo, glm4_moe, glm4v_moe, gpt_oss, granitemoe

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

models: ['models/aria', 'models/bamba', 'models/dbrx', 'models/deepseek_v2', 'models/deepseek_v3', 'models/dots1', 'models/ernie4_5_moe', 'models/falcon_h1', 'models/flex_olmo', 'models/glm4_moe', 'models/glm4v_moe', 'models/gpt_oss', 'models/granitemoe']
quantizations: [] ...

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

run-slow: aria, bamba, dbrx, deepseek_v2, deepseek_v3, dots1, ernie4_5_moe, falcon_h1, flex_olmo, glm4_moe, glm4v_moe, gpt_oss
Allow private Space id for Trackio
Author: qgallouedec
Pull request: yes

requires https://github.com/gradio-app/trackio/pull/236



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_40948). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🚨 [v5] remove deprecated `generate` classes (constraints and beam scorers)
Author: gante
Pull request: yes

# What does this PR do?

The decoding methods using these classes were recently moved to the hub, and these classes were deprecated. They were scheduled to be removed in minor versions that won't exist, so they get tagged as v5 removals :)

(cc @manueldeprada )

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

# What does this PR do?

This PR fixes the async client for transformers chat. There were some error due to the latest version of `huggingface-hub` since we migrated to httpx and i'm not sure why the previous code actually worked ... 

### Traceback 
```
Traceback (most recent call last): File "/admin/home/marc/miniconda3/envs/test/bin/transformers", line 8, in <module> sys.exit(main()) File "/admin/home/marc/transformers/src/transformers/commands/transformers_cli.py", line 48, in main service.run() File "/admin/home/marc/transformers/src/transformers/commands/chat.py", line 665, in run asyncio.run(self._inner_run()) File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/admin/home/marc/transformers/src/transformers/commands/chat.py", line 747, in _inner_run model_output = await interface.stream_output(stream) File "/admin/home/marc/transformers/src/transformers/commands/chat.py", line 134, in stream_output async for token in await stream: File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/site-packages/huggingface_hub/inference/_generated/_async_client.py", line 956, in chat_completion data = await self._inner_post(request_parameters, stream=stream) File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/site-packages/huggingface_hub/inference/_generated/_async_client.py", line 282, in _inner_post response = await self.exit_stack.enter_async_context( File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/contextlib.py", line 619, in enter_async_context result = await _cm_type.__aenter__(cm) File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/contextlib.py", line 199, in __aenter__ return await anext(self.gen) File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/site-packages/httpx/_client.py", line 1583, in stream response = await self.send( File "/admin/home/marc/miniconda3/envs/test/lib/python3.10/site-packages/httpx/_client.py", line 1616, in send raise RuntimeError("Cannot send a request, as the client has been closed.") RuntimeError: Cannot send a request, as the client has been closed.
```

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

# What does this PR do?

This PR fixes the remaining files, a follow-up of #41227 . 

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

run-slow: beit, bridgetower, chameleon, cohere2_vision, conditional_detr, convnext, deepseek_vl, deformable_detr, depth_pro, detr, dinov3_vit, donut, efficientloftr, efficientnet, eomt, flava

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

# What does this PR do?

Some code can directly use `max/min` to avoid sorting.

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

run-slow: gpt_neox_japanese, ovis2

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

# What does this PR do?

As the title says..

Comments:
You might need to resolve `beam_constraints.py` before we can merge though

@Rocketknight1 Done!

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

run-slow: emu3, eomt, idefics, layoutlmv3, mask2former, maskformer, mllama, moshi, musicgen_melody, nllb_moe, omdet_turbo, owlv2, owlvit, pixtral, rag, sam

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

Merging!
Fix unnecessary single-item container checks
Author: cyyever
Pull request: yes

# What does this PR do?

Simplify container tests.

Comments:
@cyyever some of these were used for type checks, you might have to use `x is str` or `isinstance(x, str)` instead to make the other code quality checks pass

@Rocketknight1 fixed

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

run-slow: altclip, chinese_clip, clip, clipseg, dpt, flava, groupvit, imagegpt, kosmos2_5, llama, metaclip_2, perceiver, phi3, phi4_multimodal, qwen3_omni_moe, tapas

Merging!

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41279). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
feat: use `aws-highcpu-32-priv` for amd docker img build
Author: McPatate
Pull request: yes

change the runner group to something more powerful, amd docker image build is very greedy in resources

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41285). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add processor and intergration test for qwen3vl
Author: JJJYmmm
Pull request: yes

# What does this PR do?

- support aux loss in qwen3vlmoe
- update qwen3vl processor test since the Qwen3-VL-235B-A22B is released!
- fix multi-video inference
- add intergration test for 30a3 (skip for now)

# Who can review?
- text models: @ArthurZucker @Cyrilvallez
- multimodal models: @zucchini-nlp

Comments:
run-slow: qwen3_vl, qwen3_vl_moe



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

models: ['models/qwen3_vl', 'models/qwen3_vl_moe']
quantizations: [] ...

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

run-slow: qwen3_vl, qwen3_vl_moe

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

models: ['models/qwen3_vl', 'models/qwen3_vl_moe']
quantizations: [] ...
Fix binding of video frames to video placeholder in `InternVL` model
Author: daskol
Pull request: yes
Labels: name: run-slow

This PR fixes broken frame patch indexing in `InternVLProcessor`. If batch is non-trivial (more than one sample) and contains videos and video placeholder in text then the processor returns `pixel_values` of wrong shape. Specifically, it returns `(total_num_frames - 1, ...)` instead of `(total_num_frames, ...)`. The simple code snippet to reproduces follows.

```python
proc = AutoProcessor.from_pretrained('OpenGVLab/InternVL3_5-1B-HF')
texts = [
    '<video>\nAre there any cyan objects that enter the scene?\nno',
    '<video>\nAre there any red spheres that enter the scene?\nno',
]
frames = np.ones((4, 448, 448, 3), np.float32)
inputs = proc(text=texts,
              videos=[frames, frames], return_tensors='pt',
              videos_kwargs={'size': (448, 448)})
print(inputs.pixel_values.shape)  # (7, 3, 448, 448)
assert inputs.pixel_values.shape[0] == 2 * frames.shape[0]  # FAIL: 7 != 8
```

The original lines are authored by @yonigozlan. Could you take a look?

FYI @Rocketknight1 @zucchini-nlp


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

@daskol  Looks like some InternVL processor tests are failing, you can run them locally using:
`RUN_SLOW=1 python -m pytest tests/models/internvl/test_processing_internvl.py` ;)

@yonigozlan Thanks for the oneliner to run tests. All jobs are green now.

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

run-slow: internvl

Thank you for your time.
[docs] remove references to recently deleted classes in non-`en` docs (onnx, feature processors)
Author: gante
Pull request: yes

# What does this PR do?

See title. These are causing our doc builder to crash.

_______________________

how to locally test the doc builder:
1. clone and install the doc builder
2. run `doc-builder build transformers docs/source/ja/ --language ja --clean` (replace `ja` by the target language of your choice) 

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

Should we try to avoid the doc build workflow run failing because of a failure from the build for other language?

i.e. always upload the built `en` doc (if it builds successfully).

@ydshieh yeah that would be nice (since it's the most relevant language, and we always check its CI at merge time)

OK, will try to see if I can make that work
Fix pylint warnings
Author: cyyever
Pull request: yes

# What does this PR do?

More fixes

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

Please be very careful with your PRs @cyyever. This one broke gpt-oss dequantization due to the removed param
Remove some previous team members from allow list of triggering Github Actions
Author: ydshieh
Pull request: yes

# What does this PR do?

Better security practice.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41263). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Trainer._algin_special_token can't figure out tokenizezr_has_new_eos correctly when model.generation_config.eos_token_id is a list
Author: WayenVan
Pull request: no
Labels: name: bug

### System Info

Refering the code, when algin the special tokens:

```
tokenizer_has_new_eos = tokenizer.eos_token_ids != self.model.generation_config.eos_token_id
```
here if we have a list in model's generation_config, then this value is always false thus duplicate eos_token_id will be introduced in the eos_token_id in target generation_config

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

NOne

### Expected behavior

if the eos_token_id is in model's generation_config, tokenizer_has_new_eos should be True

Comments:
🌐 [i18n-KO] Updated ko/perf_train_special.md
Author: D15M4S
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Updated ko/perf_train_special.md" 으로 부탁드립니다 -->
# What does this PR do?

Updated the perf_train_special.md file in the documentation with a Korean translation.
Thank you in advance for your review.

Part of #20179 
Update of #34590

## 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
<!-- @harheem, @nsbg, @Youngdong2, @xhaktm00, @ssunbear, @ChoHyoungSeo, @judy-choi -->
<!-- @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?
- [ ] 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).
- [ ] Did you write any new necessary tests?

## Who can review? (Final)

<!-- 2. KREW 팀원들의 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
<!-- @stevhliu May you please review this PR? -->

Comments:
Patch MistralCommonTokenizer
Author: juliendenize
Pull request: yes

# What does this PR do?

This PR patches the `MistralCommonTokenizer`:
1. [BUG FIX] spm now is correctly supported as previous usage would result in an error for `_piece_to_id` and `_is_control_token`.
2. [BUG FIX] previous implementation of `_piece_to_id` was incorrect for Tekkenizer.

a) the special tokens were not supported
b) the normal tokens were not shifted by adding the number of special tokens

4. [MAYBE BUG FIX] Changed `get_vocab` to a function that should better mimic what happens in `Transformers`: now the mapping is based on the real ids but some ids are missing due to conversion loss of some tokens in Tekken.
5. [FEATURE] `add_generation_prompt` has been added. This is to match signature of Transformers. In practice this value is ignored except if:

a) `continue_final_message` and `add_generation_prompt` are `True` an error is raised.
b) if `add_generation_prompt` is `True` and the last message is `assistant` then an error is raised as the user should have passed `continue_final_message`.

6. ~[FEATURE] Now the tokenizer is set to fast because:~

a) ~it is true~(Edit: not so sure about that after discussion)
b) it removes annoying message when initializing the tokenizer.

Edit 2: this has been reverted as it doesn't bring value and is misleading.

7. [OPTIMIZATION] now image tensors are converted without slowness warnings from torch.
8. [DOCS] updated some docs to remove unused args.

Also added minimal tests to ensure SPM also works in the future.

## 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.
- [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?

@patrickvonplaten @ArthurZucker @itazap 

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

run-slow: auto

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41439). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix an import error with PreTrainModel
Author: remi-or
Pull request: yes

This tiny tiny PR fixes an error introduced in #41445 which led to an import error.
For instance, `tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_flash_attn_2_fp32_ln` without this fix fails with 
```
NameError: name 'PreTrainedModel' is not defined
```
but after this fix passes

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41571). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[Qwen3VLMoe] Fixed: Expected self.dtype to be equal to src.dtype - routing_weights casting
Author: danielquintas8
Pull request: yes

## What does this PR do?
Fixed: Expected self.dtype to be equal to src.dtype - routing_weights casting

## Related issue
Fixes [#41418](https://github.com/huggingface/transformers/issues/41418)

Comments:
+1

cc @ArthurZucker for Moe since this might affect more models (?)

I think you didn't run the code which generates the modeling files and that's why you're seeing the difference. 

cc @zucchini-nlp 

> Thanks, can you check this mistake was not propagated to other models please!

We found the same casting happening in a few more models (ernie4_5_moe, qwen2_moe, qwen3_moe, qwen3_next, qwen3_omni_moe) and updated them accordingly

The `hunyuan_v1_moe` implementation of `route_tokens_to_experts` has different arguments compared to the other models, so this falls outside the scope of this issue. -> I will inspect it further in a future issue

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

run-slow: ernie4_5_moe, qwen2_moe, qwen3_moe, qwen3_next, qwen3_omni_moe, qwen3_vl_moe

@ArthurZucker can you merge this so that we can properly train these models?

Hey @ArthurZucker, all checks are green and the PR’s been referenced a couple times.
Just wanted to check if there’s anything else needed before merge. Thanks!
[kernels] rm mra kernels
Author: MekkCyber
Pull request: yes

# What does this PR do?

Removes the mra kernels, and uses kernels from the hub : https://huggingface.co/kernels-community/mra instead

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

run-slow: mra

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

run-slow: mra

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

models: ['models/mra']
quantizations: [] ...
Fixed : Bad error message for AutoTokenizer loading Voxtral #41553
Author: i3hz
Pull request: yes

# What does this PR do?



Fixes # 41553
Added a small check in both src/transformers/models/llama/tokenization_llama_fast.py and src/transformers/models/llama/tokenization_llama.py.



## 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.
- [ ] 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?
@ArthurZucker 
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.





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

run-slow: llama, mra

That's my bad I forgot to run the make commands I'll make the changes and create another one , but the kernel files are missing , is that normal?