noamaanMulla-03/transformers-issues huggingface dataset:
TrainingArguments initializer changes `torch.current_device()`
Author: joaoareis
Pull request: no

### System Info

```
transformers 4.28.1
python 3.9.13
torch 1.12.1
```

### Who can help?

@sgugger 

### 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

Run
```python
import torch
from transformers import TrainingArguments
torch.cuda.set_device(1)
print(torch.cuda.current_device())
training_args = TrainingArguments(output_dir="output/")
print(torch.cuda.current_device(), training_args.device)
```
Observe
```
1
0 cuda:0
```

### Expected behavior

I would expect that the `torch.current_device()` would not change and therefore to observe
```
1
1 cuda:1
```

Comments:
Your expectation is not correct as `TrainingArguments` will take all GPUs available (in this case it will use DataParallel on your model for the training afterward). You need to set the `CUDA_VISIBLE_DEVICES` environment variable to limit the GPUs seen.

Oh, I see. Thanks for the answer!
[AutoModel] fix `torch_dtype=auto` in `from_pretrained`
Author: stas00
Pull request: yes

This PR:

1. fixes the case of `torch_dtype=auto` in `AutoModel.from_pretrained` which got unintentionally stripped in https://github.com/huggingface/transformers/pull/21524 - now `torch_dtype=auto` gets always passed on to the  `from_pretrained` method of the resolved class.
2. adds a test

Fixes: https://github.com/huggingface/transformers/issues/23357

Comments:
_The documentation is not available anymore as the PR was closed or merged._

The only change is that `torch_dtype="auto"` remains in `kwargs` and it wasn't before.

I have just flipped around the `_copy` vs `_orig` as it looked simpler to read that way. There is no functional change in that part of the code.

Probably could just set a flag of `is_torch_dtype_auto = True` instead of copying `kwargs` - I just thought that perhaps down the road other entries might need a special handling. Let me know if you prefer that I recode to use the flag instead. It surely would be cleaner I think.

No no, that works as is.
Build with non Python files
Author: sgugger
Pull request: yes

# What does this PR do?

It appears the non python files (such as CUDA kernesl) have disappeared from the built package once again. Fir some reason there were found before with just `*.extension`, but now need `**/*.extension` (although once found again I can remove the **).

This is all super brittle, so this PR also adds:
- a check that the build package contains the non-Python files before we upload it on testpypi
- a check that the library installed does contain the non-Python files before we upload it on pypi

Will make a patch after this is merged.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix chat prompt in HFAgent
Author: IvanSedykh
Pull request: yes

# What does this PR do?

There was a bug in formatting prompts in the chat mode. Actually, user-provided custom prompts were never used.

## 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.

@sgugger, please review this PR

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Replace appends with list comprehension.
Author: ttsugriy
Pull request: yes

It's more idiomatic and significantly more efficient because 1) it avoids repeated `append` call that Python has to resolve on each iteration 2) can preallocate the size of the final list avoiding resizing

# What does this PR do?

This PR replaces uses list comprehension instead of list appends.


## 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?

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 and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

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: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._
No package metadata found for tqdm while generating exe
Author: MK096
Pull request: no

Hi,
Whenever i try to make executable file i always get an error : No package metadata found for tqdm.
I've tried hidden-import tqdm but it didn't work. In python IDLE it works fine but while running exe it doesn't work.

I am using Win 10 (64-bit)

Code:

              _import eel
              import tqdm # i thought of importing it to see wheter this solves anything..but it didn't help
              from transformers import pipeline
              
              print("Loaded")
              eel.init('Web')
              
              // try...Catch to open index.html_ [UI]
![error](https://user-images.githubusercontent.com/20142735/120370044-8c511200-c32d-11eb-9bd1-b2d63dfb1600.PNG)

Any help will be really appreciated.

Thank You

Comments:
Hello, 
Can you please tell me how you managed to solve this issue ?
[`SAM`] fix sam slow test
Author: younesbelkada
Pull request: yes

# What does this PR do?

This PR fixes the slow tests that were failing due to https://github.com/huggingface/transformers/pull/23295

In fact, in the slow test that we have designed, we forgot to use the correct format for the input bounding boxes

Will address a PR on `notebooks` to address the changes in the example notebook

cc @ydshieh @amyeroberts 

Comments:
Fix for the notebook: https://github.com/huggingface/notebooks/pull/371

_The documentation is not available anymore as the PR was closed or merged._

Indeed the tests were passing before because the processor was force unsqueezeing the boxes here: https://github.com/huggingface/transformers/blob/d765717c76026281f2fb27ddc44fa3636306bb48/src/transformers/models/sam/processing_sam.py#L141 

> you can't have floating integers :) 

Hahah yes, thanks for noticing! Copilot does some bad job sometimes ... will update that as well

Thanks a lot @amyeroberts !

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_23376). All of your documentation changes will be reflected on that endpoint.
Update 3 docker files to use cu118
Author: ydshieh
Pull request: yes

# What does this PR do?

A follow up for #23339.

I will try to build the images and run a small subset of tests to make sure this doesn't break (too many) things before merge.

Comments:
_The documentation is not available anymore as the PR was closed or merged._

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_23406). All of your documentation changes will be reflected on that endpoint.
Top 100
Author: LysandreJik
Pull request: yes

This PR celebrates the upcoming 100k stars for `transformers` by highlighting 100 open-source repositories that use or have integrated `transformers` in their projects.

This list should not be limited to 100 (which we use as a mirror to the 100k stars), so we're looking forward to having libraries that integrate `transformers` open PRs against this document.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
New LlamaTokenizer "fast" version takes 90s to load on 5900x with nvme
Author: Qubitium
Pull request: no

### System Info

Transformer [head]
Cuda 11.8
Pytorch nightly 2.1
Ubuntu 22.04

### Reproduction

Is it normal for the new default "faster" LlamaTokenizer to load so slowly on a fairly new cpu? Imagine the load time on a 2018 Intel xeon. 

Model is a llama 7b converted to HF using latest script within transformer/model/llama head. 

Each cold load takes ~90s. 

```

# this will take 90s to load on 5900x + nvme
# load llama 7b model converted from facebook to hf
tokenizer = AutoTokenizer.from_pretrained(base_model, use_fast=True)
```


### Expected behavior

Load in seconds. 

Comments:
This is to convert the slow tokenizer to the fast format (which the conversion script should do once and for all @ArthurZucker ). You should do `tokenizer.save_pretrained(some_path)` and then copy the fast tokenizer file in the folder where you have your converted LLaMA model to avoid having the slowdown more than once as a workaround @diegomontoya until we fix the conversion script.

Yep the llama conversion script reactor happened before the llama fast tokenizer was around. Will open a PR to save the fast 

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.
add xformers dep, xformers attn for gpt2
Author: ethansmith2000
Pull request: yes

# What does this PR do?

Add xformers as a dependency and implement xformers attention for gpt2. 
I am a bit of a novice to this, but would like to contribute in helping all models in the transformers library to have xformers support.

It is likely the case that this PR is not ready to merge, but I was hoping I could get some feedback on what I would be able to provide

Fixes # (issue)
Reduces VRAM and increases speed

Comments:
cc @younesbelkada I don't know if this redundant with the Better Transformer integration.

Related: https://github.com/huggingface/transformers/pull/22386

I don't think it's an issue to collide - if it is just better in most cases, having it default to users makes sense, in transformers natively (with some refactoring). However, for now, pytorch's sdpa has some limitations:
* no scale argument (some archs do not scale query/key)
* no speedup/memory savings for custom attention mask (flash and mem-efficient not supported)
* no support for mixed fp16/fp32, like in some models where softmax is in fp32 while the rest in fp32
* C++ implementation is good for all hardware, mem-efficient and flash are Nvidia-only

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.
run_text_classification.py: error: the following arguments are required: --model_name_or_path
Author: iamemilyccc
Pull request: no

Hi! I'm running the 'transformers/examples/tensorflow/text-classification/run_text_classification.py' and got the following "Error: the following arguments are required: --model_name_or_path" and "--model_name_or_path=gpt2: command not found" at the same time. Could you please help?

Comments:
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
Add support for Ascend NPU
Author: ji-huazhong
Pull request: no

### Feature request

It would be nice if the Transformers suite could be used directly on the Ascend NPU without modifying the source code.

### Motivation

In China, Ascend NPU is the second choice after Nvidia GPU and has been adpoted by many companies, such as Alibaba, ByteDance, Meituan, etc. Huawei officially released an adapter called [`torch_npu`](https://github.com/Ascend/pytorch/blob/master/README.en.md), to adapt PyTorch on Ascend NPU. `torch_npu` is user friendly to developers, so that we can still enjoy the same PyTorch experience that we accustomed to today.

The native Transformers suite requires minor modifications to run on the Ascend NPU, so it's reasonable to support the Ascend NPU to be a member of Transformers community.

### Your contribution

I can assist in adding support if you want, see this PR (#22644 )

Comments:
@sgugger 

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.
XLNet fails with attn_type "uni"
Author: jppgks
Pull request: no

### System Info

- `transformers` version: 4.26.1
- Platform: Linux-5.10.104-linuxkit-aarch64-with-glibc2.17
- Python version: 3.8.16
- Huggingface_hub version: 0.12.0
- PyTorch version (GPU?): 1.13.0 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

@thomwolf 

### Information

- My own modified scripts

### Tasks

- An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)

### Reproduction

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained("xlnet-base-cased")
tokenizer = AutoTokenizer.from_pretrained("xlnet-base-cased")

# Set attention type
model.transformer.attn_type = "uni"

inputs = tokenizer(["Hello, my dog is cute", "Hello, my dog is cute too"], return_tensors="pt", padding=True)
print(inputs)
outputs = model(**inputs)
```

Error:
```python-traceback
{'input_ids': tensor([[    5,    17, 11368,    19,    94,  2288,    27, 10920,     4,     3],
        [   17, 11368,    19,    94,  2288,    27, 10920,   269,     4,     3]]), 'token_type_ids': tensor([[3, 0, 0, 0, 0, 0, 0, 0, 0, 2],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]]), 'attention_mask': tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}
Traceback (most recent call last):
  File "xlnet.py", line 70, in <module>
    outputs = model(**inputs)
  File "/usr/local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/vscode/.local/lib/python3.8/site-packages/transformers/models/xlnet/modeling_xlnet.py", line 1547, in forward
    transformer_outputs = self.transformer(
  File "/usr/local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/vscode/.local/lib/python3.8/site-packages/transformers/models/xlnet/modeling_xlnet.py", line 1161, in forward
    attn_mask += data_mask[:, :, :, None]
RuntimeError: output with shape [10, 10, 1, 1] doesn't match the broadcast shape [10, 10, 2, 1]
```

### Expected behavior

Successful forward pass with the appropriate attention masks applied.

Comments:
cc @ArthurZucker and @younesbelkada 

This is a fairly old model 😅 It does make sense to drop `uni` (first because it is not working and did not bother anyone) but also let's just redirect to the new [TransformerXL](https://huggingface.co/docs/transformers/model_doc/transfo-xl). Thanks for reporting

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.
Update error message when Accelerate isn't installed
Author: muellerzr
Pull request: yes
Labels: name: trainer

# What does this PR do?

This PR provides a bit more verbose error when `accelerate` isn't found on an install of `transformers`, as the `Trainer` (on PyTorch) requires Accelerate to be installed.

The error message was changed from:
```python
ImportError: Using the Trainer with PyTorch requires accelerate: Run pip install --upgrade accelerate
```
To be:
```python
Using the `Trainer` with `PyTorch` requires `accelerate>=0.19.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`
```

Fixes # (issue)

- https://github.com/huggingface/transformers/issues/23323


## 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#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?

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.

@LysandreJik 

(@sgugger when you are back)


Comments:
_The documentation is not available anymore as the PR was closed or merged._

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_23373). All of your documentation changes will be reflected on that endpoint.
🌐 [i18n-KO] Translated `tasks/zero_shot_object_detection.mdx` to Korean
Author: HanNayeoniee
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.mdx` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `tasks/zero_shot_object_detection.mdx` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179
<!-- 메인 이슈에 기록이 남아요! 가짜연구소 리포를 사용해 연습하실때는 제거해주시면 감사하겠습니다! :smile: -->

## 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. 위 체크가 모두 완료된 뒤에만 가짜연구소 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
Team PseudoLab, may you please review this PR? @0525hhgus, @KIHOON71, @sim-so, @gabrielwithappy, @HanNayeoniee, @wonhyeongseo, @jungnerd

## 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. 가짜연구소 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
@sgugger, @ArthurZucker, @eunseojo May you please review this PR?

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Can you solve the conflicts so we can merge this PR?

> Can you solve the conflicts so we can merge this PR?

toctree file of this branch causes a conflict because it's different from the new version. 
As shown in  [[docs] Doc TOC updates](https://github.com/huggingface/transformers/pull/23049)
Let me fix this after I update korean toctree first!


Closed in favor of #23430
Return early once stop token is found.
Author: ttsugriy
Pull request: yes

# What does this PR do?

Previously even after finding a stop token, other stop tokens were considered, which is unnecessary and slows down processing.

Currently, this unnecessary overhead is negligible since there are usually 2 stop tokens considered and they are fairly short, but in future it may become more expensive.


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Encoder-Decoder: add informative exception when the decoder is not compatible
Author: gante
Pull request: yes

# What does this PR do?

Related to https://github.com/huggingface/transformers/issues/23350

Many decoder models are not compatible with our `EncoderDecoder` structure (mostly because using the encoded hidden states appropriately requires extra code in the decoder model architecture itself). This PR adds an informative message in the presence of incompatible decoder models.

Comments:
_The documentation is not available anymore as the PR was closed or merged._