noamaanMulla-03/transformers-issues huggingface dataset:
Minor error condition bug fix
Author: htahboub
Pull request: yes

This error condition appears to be incorrect. Based on the error message, this should be triggered if both `input_ids` and `inputs_embeds` are provided. However, it is currently triggered if neither is provided.

@simonJJJ, @amyeroberts, @qubvel 

Comments:
Hi @htahboub, I don't think the proposed change is correct. The current logic condition is XOR i.e. it will fail if both or neither are specified, which is what we want to check for. 

If you think the error message can be improved or clarified feel free to propose an update! 

Hey! 🤗 Thanks for your contribution to the `transformers` library!

Before merging this pull request, slow tests CI should be triggered. To enable this:
- Add the `run-slow` label to the PR
- When your PR is ready for merge and all reviewers' comments have been addressed, push an empty commit with the command `[run-slow]` followed by a comma separated list of all the models to be tested, i.e. `[run_slow] model_to_test_1, model_to_test_2`
  - If the pull request affects a lot of models, put at most 10 models in the commit message
- A `transformers` maintainer will then approve the workflow to start the tests

(For maintainers) The documentation for slow tests CI on PRs is [here](https://www.notion.so/huggingface2/CI-for-pull-requests-8335bd9217d24d1e8ed1d3a016f39804).

Hey @amyeroberts. Sure, I thought that may be the case, in which case the error message is a little unclear. I have made changes to make that more explicit.

Thanks @amyeroberts, just made the change to the rest of the repo!

Hi @htahboub, there are some tests failing, can you please run `make fix-copies`?

Thanks @qubvel, just ran the command and pushed the changes.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33781). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix attn mask ignore logic in training-time trace
Author: zhenglongjiepheonix
Pull request: yes
Labels: name: run-slow

This pr fixes a scenario where we want to use dynamo trace in training mode, the current attn mask ignore logic creates a problem where data-dependent branch condition `torch.all(attn_mask==1)` will cause graph breaks and disable full-graph tracing, the current solution is to disable mask ignore logic as long as we are in tracing mode no matter we are in training or inference phase.

This will enable compilation for training(forward+backward) like this:
```
model = LlamaForCausalLM(config).cuda()
model = torch.compile(model, fullgraph=True)
loss = model(**inputs)[0]
loss.backward()
```


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

Added a simple gradient match test in training mode @ArthurZucker . According to my local test, the backward latency remains pretty much the same as eager mode when steady(no matter whether cudagraphs are enabled), but we can still benefit from the forward pass in training, and training-time trace does help in my case where I need to do graph analysis under training mode.

Failure is most probably not related to you, but the slow tests is bad / badly designed as it should either not use accelerate, or not use parallelism to make sure we are testing apples to apples. 


Would be nice if you can update the tests 🙏🏻 

Accelerate will kick in if memory is not enough. I think the best solution is just to use the current torch device rather than specifying `device_map='sequential'`, it might cause GPU OOM in this way however. Pytests seem to have problems in avoiding GPU memory fragmentation, see https://discuss.pytorch.org/t/torch-pytest-leads-to-memory-fragmentation-how-to-do-proper-integration-testing-of-a-lot-of-torch-models/201231 , I have run into similar issues where if I run single test alone it passes, and fails because of OOM when I run all the tests all together.

According to the failure information of OOM, the GPU memory allocated but not used is about 7MB, I think it's not significant so fragmentation is not so bad to cause the failure, we simply need GPUs with more memory.

> Failure is most probably not related to you, but the slow tests is bad / badly designed as it should either not use accelerate, or not use parallelism to make sure we are testing apples to apples.

Yes, we should never use accelerate, but in order to make tests pass robustly, we might need GPU runners with more memory, T4 will definitely not be enough because simply loading single model like llama-7b without doing anything would require 13GB
hot fix `self.position_embeddings->self.position_embedding`
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Fixes #33929

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

I think this is still broken. `self.position_embedding` is of type `nn.Embedding`, which means it doesn't have a `.shape` variable.

I think you want to bring back
```
position_embeddings = self.position_embedding.weight.unsqueeze(0)
```

🫠 yep

Opening a new PR
PaliGemma (and probably SigLIP) inference broken in latest transformers version
Author: mranzinger
Pull request: no

> This seems like a breaking change. When I run this model with `transformers==4.44.2`, things work fine. However, when running with `transformers==4.25.1`, it fails with this error:> 
> ```> 
> ...> 
>     num_positions = self.position_embeddings.shape[1]> 
>   File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1687, in __getattr__> 
>     raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")> 
> AttributeError: 'SiglipVisionEmbeddings' object has no attribute 'position_embeddings'. Did you mean: 'position_embedding'?> 
> ``` 

 _Originally posted by @mranzinger in [c6d2848](https://github.com/huggingface/transformers/commit/c6d2848a23aba42404784ba52e421ae7b8c68eda#r147546116)_

Comments:
Yep opening a PR asap cc @xenova ! 

I think this is still broken. `self.position_embedding` is of type `nn.Embedding`, which means it doesn't have a `.shape` variable.

I think you want to bring back
```
position_embeddings = self.position_embedding.weight.unsqueeze(0)
```

Fixed properly this time sorry!

#32600 also introduced a regression by storing position embeds twice


#33965 does look better!
[Doc]: Broken link in Kubernetes doc
Author: saldanhad
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).


## 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
- vision models: @amyeroberts, @qubvel
- speech models: @ylacombe, @eustlb
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33879). 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 `video_text_to_text.md` to Korean
Author: win2dvp21
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `video_text_to_text.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]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)
@harheem, @jeongiin, @1kmmk1, @SeungAhSon, @win2dvp21
<!-- 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 -->

## 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:
🌐 [i18n-KO] Translated `compressed_tensors.md` to Korean
Author: 1kmmk1
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `compressed_tensors.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]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? --> 
@harheem, @jeongiin, @Seungahson, @win2dvp21
<!-- @junejae, @Jwaminju, @010kim, @4N3MONE, @boyunJang --> 
<!-- @jungnerd, @cjfghk5697, @yijun-lee, @mreraser --> 
<!-- @heuristicwave, @nuatmochoi, @chhaewxn, @jun048098, @ahnjj, @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:
🌐 [i18n-KO] Translated `quantization/contribute.md` to Korean
Author: 1kmmk1
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `<your_file>.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]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? --> 
@harheem, @jeongiin, @1kmmk1, @Seungahson, @win2dvp21
<!-- @junejae, @Jwaminju, @010kim, @4N3MONE, @boyunJang --> 
<!-- @jungnerd, @cjfghk5697, @yijun-lee, @mreraser --> 
<!-- @heuristicwave, @nuatmochoi, @chhaewxn, @jun048098, @ahnjj, @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:
Paligemma: fix static cache test
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Fixes the flaky test on paligemma from #33630

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33941). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Failed to import transformers.models.t5.modeling_t5 because of the following error 
Author: Nabeel1232
Pull request: no
Labels: name: bug

### System Info

from transformers import T5ForConditionalGeneration, GenerationConfig
RuntimeError: Failed to import transformers.models.t5.modeling_t5 because of the following error (look up to see its traceback):
Failed to import transformers.genera

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


!pip install transformers
from transformers import T5ForConditionalGeneration, GenerationConfig


### Expected behavior

the command should import T5ForConditionalGeneration, GenerationConfig

Comments:
![image](https://github.com/user-attachments/assets/204bbe16-bba6-416e-b14d-0fcb817cc7a5)

i can import properly 

@Nabeel1232 if you're working in a jupyter notebook, please make sure to restart your runtime after installing a new library.

![image](https://github.com/user-attachments/assets/36f8f714-fe22-497d-9c8c-0b8e030c047f)
![image](https://github.com/user-attachments/assets/540dc11c-c636-480d-aa1f-b6672e595eb0)

Hey sorry couldnt reproduce . Which IDE do you use

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.
🌐 [i18n-KO] Translated `image_text_to_text.md` to Korean
Author: 1kmmk1
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `image_text_to_text.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]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? --> 
@harheem, @jeongiin, @Seungahson, @win2dvp21 
<!-- @junejae, @Jwaminju, @010kim, @4N3MONE, @boyunJang --> 
<!-- @jungnerd, @cjfghk5697, @yijun-lee, @mreraser --> 
<!-- @heuristicwave, @nuatmochoi, @chhaewxn, @jun048098, @ahnjj, @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:
Updating `char_to_token` documentation to note behaviour when `trim_offsets` is True
Author: Craigacp
Pull request: yes

# What does this PR do?

Updates the documentation for `BatchEncoding.char_to_token` to note that the return value can be `None` if `trim_offsets` is true and the char index points to a whitespace character.

Fixes #33237.


## 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. Discussed in #33237.


## Who can review?

@ArthurZucker @itazap 


Comments:
@Craigacp Nice, thank you!! 🚀 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33919). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[`ChatGlm`] Adds support for the ChatGLM model
Author: ArthurZucker
Pull request: yes
Labels: name: WIP

# What does this PR do?
Drafts the support of chat GLM

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

Hi~ o(*￣▽￣*)ブ Could  you tell me what your plans? May I know when the PR can be merged?  I have PRs depended on this feature. 

@younesbelkada and I just came back from holidays, we are hoping end of the week maybe later! 

cc @ArthurZucker could you give a first pass ? 🙏 

I think #33823 should fix this!
cache umt5 bias computation
Author: ArthurZucker
Pull request: yes
Labels: name: WIP

# What does this PR do?
Should fix #26144, by caching the relative bias and only returning the one that is required for the current computation. 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_26150). All of your documentation changes will be reflected on that endpoint.

This is great @ArthurZucker! My new results are:

```
Comparing to facebook/mbart-large-50-many-to-one-mmt: (for pseed, higher is slower)

google/umt5-small:       22.08% (relative speed); 50.19% (relative size) -- speed used to be 975.10%!
google/mt5-small:        12.57% (relative speed); 49.14% (relative size)
t5-small:        32.21% (relative speed); 9.90% (relative size)
```

That's like a 45x improvement?! :o

I know I'm probably _too_ excited but any idea when this can be merged? Or is https://github.com/huggingface/transformers/issues/23145 blocking this?

The linked issue is blocking + for now the output is garbage, working on this 😉 

Ah great, I'll have some patience and keep an eye out to the progress here. 

Bump to keep active

Thanks! Did not have time to improve this yet :( 

> Thanks! Did not have time to improve this yet :(

No worries! I'll just keep bumping this when it becomes marked as stale until you find some time! (Or if you want to just close this that's only fine ofc) 

Closing as I won't have time to tackle this! 🤗
Adding pruning integration to transformer
Author: gaetanlop
Pull request: yes

# What does this PR do?

This PR adds width pruning (attention, embedding, MLP) to transformer models. It adds the following features:

- A PrunerMixin class for handling multiple pruning types (embeddings, neurons, GQA, heads).
- Pruning utilities for nn.Embedding and nn.Parameter to pytorch_utils.

## Fixes # (issue)

This PR generalizes the work done in #33180. 

## Still needs to do

- [ ] Add documentation.
- [ ] Add necessary tests.
- [ ] Add depth pruning.


## Who can review?

cc @ArthurZucker @younesbelkada 

Comments: