noamaanMulla-03/transformers-issues huggingface dataset:
Fixed grammar mistakes
Author: FrogWarlord
Pull request: yes

fixed a couple grammar mistakes


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?

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.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->


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

Added spaces between words, fixed a typo and other errors

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?

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.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->


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

# What does this PR do?

This PR fixes trainer compatibility with py3.9. To be added in a patch for the latest release. Asked by optimum folks cc @IlyasMoutawwakil 

Comments:
For this one, let's merge on main and cherry pick it on v4 branch as this is just typing ! 

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

Can you close this issue https://github.com/huggingface/transformers/issues/41339 after merge?

Hi, this one was my bad! We've been updating for Py3.10 because Py3.9 is EOL next week. Do we really want to revert to support it?

Don't worry @Rocketknight1, it was for a patch that was released last week
this PR added a few untested notebooks that need to be fixed/verified by AMD
Author: Mahdi-CV
Pull request: no
Labels: name: bug

### System Info

The notebooks added by this PR loads but you get errors when you run them. https://github.com/huggingface/transformers/pull/41676/

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

just load the notebooks added by this link and run the cells https://github.com/huggingface/transformers/pull/41676/

### Expected behavior

it will throw different errors for different notebooks. Only the set of notebooks added by @fan-amd in the previous PR work with with AMD Cloud

Comments:
Hi @Mahdi-CV, I'd like to help fix this issue. Could you please provide more details:

1. Which specific notebooks from PR #41676 are failing? (e.g., quicktour.ipynb, task_summary.ipynb, etc.)
2. What are the specific error messages you're seeing for each notebook?
3. Are you testing these on AMD Cloud, and if so, what's the environment setup?

This information will help me create a proper fix. Thanks!

This has been resolved!
transformers serve quantization docs + some api fixes for bitsandbytes
Author: SunMarc
Pull request: yes

# What does this PR do?

This PR adds some docs for transformers serve x quantization and fixes the quantization api for bitsandbytes. 
Following PR will add more support for other methods and I will add a section in each quantization method to show what is the preferred setup (compile ? dtype ?) when using serve ! 

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

let's merge this first and i'll do follow up pr
Bye bye env vars, keep everything as configs
Author: SunMarc
Pull request: yes

# What does this PR do?

Supersedes https://github.com/huggingface/transformers/pull/37259

As @BenjaminBossan found, (https://github.com/huggingface/accelerate/pull/3252), the TrainingArguments will set environmental variables automatically when using Accelerate because before it wouldn't work otherwise. Nowadays the only env variable required for things to run smoothly is the ones for model init (fsdp cpu eff ram).

This PR does a few things:
- We completely remove the need for environmental variables, creating the proper configs (dynamo relies on https://github.com/huggingface/accelerate/pull/3251)
- I've refactored how mixed_precision gets set, to simplify the training arguments and combine 7 args into 2.
- Removes old references/updates the logic in Trainer to reflect the choices

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

@SunMarc I'm wondering if this would be a good candidate to be included in the v5 release? Not sure if there is enough time left :sweat: 

I changed quite a lot of things regarding args in trainer. Is there any specific things you want in v5 ? 

You mean in another PR? In that case, I'm fine with closing this one.

My main concern is that we should avoid using environment parameters as a way to propagate arguments as much as possible, as this is a hard to debug side effect. And if there is no choice, `Trainer` should try to clean up the envs that it set once it's finished. If those concerns are addressed, it's perfect for me.

SG, I will try to fix that asap before the release

can be closed as we merged a similar pr
make apollo test case pass
Author: yao-matrix
Pull request: yes

as in galore here https://github.com/huggingface/transformers/blob/main/tests/trainer/test_trainer.py#L2443, same change to make apollo test case `test_apollo_lr_display_without_scheduler` pass.

@ydshieh , pls help review, thx very much.

Comments:
cc @SunMarc 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41805). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[`Flash Attention`] Disable packed sequences with pos ids only during torch compile
Author: vasqu
Pull request: yes

Draft, only as a reference as what could be done. It would allow for full graph compile when using no attention mask.

Supported compile:
- Bsz 1
  - No mask
    - Before: No full graph, recompilations
    - After: Full graph
  - Attn mask
    - Before: No full graph, recompilations
    - After: No full graph, recompilations
  - Pos ids, no mask
    - Before: No full graph, recompilations
    - After: Not supported, silent wrong computations (if packed)
  - Fa kwargs, no mask
    - Before: Full graph
    - After: Full graph
- Bsz > 1
  - No mask
    - Before: Full graph
    - After: Full graph
  - Attn mask
    - Before: Same as bsz 1
    - After: Same as bsz 1

Tl;dr: core changes are
- No attn mask: Full graph support vs recompilations and no full graph (bsz == 1)
- Position ids but no attn mask: Not supported for compile vs recompilations and no full graph


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

# What does this PR do?

Parakeet encoder modified the sequence length, making that the input attention_mask cannot be directly used to know which embeddings positions correspond to padding. 

Here we do it differently than the actual external approach like we have on mimi that consists to retreive the correct mask:
```python
attention_mask = mimi_model.get_audio_codes_mask(inputs.attention_mask)
```
and that recomputes as mask that is already known in the forward and that can simply be returned along with the outputs.

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

# What does this PR do?

Translated the `main_classes/backbones.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)

May you please review this PR?
@jungnerd, @chelsseeey, @skwh54, @amo33, @maximizemaxwell, @D15M4S
@harheem
@4N3MONE 
@yijun-lee 

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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)
<!-- @stevhliu May you please review this PR? -->

Comments:
글로서리에서는 `backbone`을 `기반`으로 번역하도록 정의되어 있지만, 문서 제목과 TOC까지 모두 변경하기에는 용어의 의미적 범위에 고민이 있었습니다. 따라서 TOC와 문서 제목은 `백본`을 유지하되 본문에서는 `기반`으로 번역하고, 도입부에 `백본(이하 기반)` 설명을 추가하는 방향으로 글로서리 일관성을 고민했습니다. 의견주시면 반영하겠습니다.

> 글로서리에서는 `backbone`을 `기반`으로 번역하도록 정의되어 있지만, 문서 제목과 TOC까지 모두 변경하기에는 용어의 의미적 범위에 고민이 있었습니다. 따라서 TOC와 문서 제목은 `백본`을 유지하되 본문에서는 `기반`으로 번역하고, 도입부에 `백본(이하 기반)` 설명을 추가하는 방향으로 글로서리 일관성을 고민했습니다. 의견주시면 반영하겠습니다.

TTA 용어 사전에서는 `기간`, 글로서리에서는 `기반`으로, 대부분의 기술블로그에서는 '백본'으로 정의되어 번역되고 있었습니다.

하나의 단어에 서로 다른 번역어가 혼재하면 가독성이 많이 떨어질 수 있겠다는 생각이 들었습니다.
의미 전달이 가장 명확하다고 생각한 단어를 하나 선택하신 뒤 통일하여 사용하는 방안을 제안드립니다!
(개인적으로 `백본`이 의미전달이 명확하다는 생각이 들었습니다. 다른 분들도 의견 부탁드려요!)
unpin torch/torchcodec for CircleCI
Author: ydshieh
Pull request: yes

# What does this PR do?

We can run CircleCI with torch 2.9 + torchcodec 0.8 now, after a minor change in `src/transformers/video_utils.py`, which is discussed on slack

https://huggingface.slack.com/archives/C3PDTEV8E/p1761255740979019?thread_ts=1760709571.854159&cid=C3PDTEV8E

>  please use the device=kwargs.get("device", "cpu"), workaround for now
We didn't officially support device=None (the Optional type annotation was a mistake). So your workaround is the correct fix.
We may eventually support device=None (https://github.com/meta-pytorch/torchcodec/issues/993) but it won't always default to CPU like it used to

and zucchini-nlp is OK with that:

https://huggingface.slack.com/archives/D06HT56C0HF/p1761123374935529

> let's just make cpu default device untill fixed then
[10:56](https://huggingface.slack.com/archives/D06HT56C0HF/p1761123382729509)
with a TODO comment



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41839). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Feat/lightglue image processor fast
Author: AlphaOrOmega
Pull request: yes

# What does this PR do?
This PR implements the LightGlue fast image processor.
Since the LightGlue image processor is closely tied to the SuperGlue image processor logic, I based my implementation on the existing `SuperGlueImageProcessorFast` class.
However, there is some redundancy between the two implementations, as they share many of the same operations. A cleaner approach might be to have `LightGlueImageProcessorFast` inherit from `SuperGlueImageProcessorFast` instead, please let me know what you think.

Additionally, I made a small update to the contributing.md file to reflect the recent change in the transformers_cli command.
Please let me know if you would prefer that I split this minor change into a separate PR.


# Test Performed
RUN_SLOW=1 python -m pytest tests/models/lightglue/test_image_processing_lightglue.py

I used a profiler during the run to analyse the runtime speed : 
+ with standard image processor 
<img width="1579" height="177" alt="image" src="https://github.com/user-attachments/assets/1f6195d7-96be-46e1-a861-644e94272f53" />
+ with fast image processor 
<img width="1588" height="175" alt="image" src="https://github.com/user-attachments/assets/bce88888-bf6d-41d7-968c-a2c75d360002" />

Based on this simple test, I evaluate the speed improvement by 3 time on my hardware.


N.B. : Please note that the LightGlue image processor tests inherit from the SuperGlue image processor tests, which explains the traces appearing in the SuperGlue test logs.





## 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?
- [ 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.
           link : https://github.com/huggingface/transformers/issues/36978#issue-2947632853

- [ 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?
Thank you, @yonigozlan, for providing feedback on the implementation I chose.
@stevhliu, feel free to review the CONTRIBUTING.md file update and let me know if any further changes are needed.



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

run-slow: auto, lightglue

Hello @yonigozlan,

Does it looks good to you as well ?

Thanks

Hello @AlphaOrOmega ! So sorry I missed this, but we've actually already added the fast image processor for lightglue using modular. Closing this for now, but thank you for working on this
Resume training by trained samples to avoid elastic job loss or over-reading of data.
Author: zhengchenyu
Pull request: yes

# What does this PR do?

Resume training by trained samples. Then we can avoid reading more or less data due to changes in the number of workers.

Fixes: #40245 

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?

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:
This PR depends on https://github.com/huggingface/accelerate/pull/3757.

cc @sunmarc

The experiment used Qwen3 SFT and DeepSpeed ​​for training. After apply #41159, #41144, https://github.com/huggingface/accelerate/pull/3757., and this pr. The following experimental results were obtained. The `base` training is performed on a single machine with 8 GPUs. And the `switch` training switches between single-machine 8 GPUs and dual-machine 8 GPUs every 100 steps.

<img width="1165" height="484" alt="截屏2025-10-24 16 12 13" src="https://github.com/user-attachments/assets/f69f4798-cfcb-4aea-b132-1c82bd23ce67" />

This result proves that there is nothing wrong with this PR.

cc: @SunMarc @Rocketknight1
further reducing flakiness in `utils/check_bad_commit.py` (#41658) 
Author: ydshieh
Pull request: yes

# What does this PR do?

In #41690, we run each test (on each git bisect commit) 4 times to avoid the false positive being reported to specific team member.

However, when we check if a test passes on the commit of the current CI run (in the last job of checking bad commit) that failed in the same current run in the usual job for that model, we only needs 1 pass among 4 runs to conclude it's flaky.

Prior to this PR, it requires the 4 runs all passing to say "it pass on the check time" and conclude it's flaky which is incorrect, and this leads the false positive being still reported (even with less chance).

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41815). 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: flex_olmo
Fix Qwen2Audio flash attention mask format for generation
Author: Abdennacer-Badaoui
Pull request: yes

## What does this PR fix?

This PR fixes the `test_eager_matches_fa2_generate` test failure for Qwen2Audio by using the `create_bidirectional_mask` utility function to properly handle attention masks across different attention implementations.

The Qwen2Audio model was manually creating a 4D attention mask with `-inf` values for the audio encoder, regardless of the attention implementation being used. This caused issues with Flash Attention 2/3, which requires a 2D boolean mask (shape `(batch_size, seq_len)`) with `1` for valid tokens and `0` for padding.

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

@remi-or ready for review 🙂

run-slow: qwen2_audio

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

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

Can you push an empty commit? Cant merge with red CI

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

run-slow: qwen2_audio

Thx a lot :hugs:
Fix const parsing for dict inputs in chat schemas
Author: Rocketknight1
Pull request: yes

Found one more bug in chat schemas and updated the tests to cover it! `const` nodes were not being handled correctly when the parent node had structured content.

This PR also moves `test_chat_schema_utils.py` to `test_chat_parsing_utils.py` to match the name of the actual file `utils/chat_parsing_utils.py`.

Tests may not be running in the CI yet but I ran them all locally and they're passing!

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