noamaanMulla-03/transformers-issues huggingface dataset:
redirect logging output to `stdout` instead of `stderr`
Author: techkang
Pull request: no
Labels: name: Feature request

### Feature request

Redirect logging output to `stdout` instead of `stderr`. Specifically, add argument `stream=sys.stdout` at: https://github.com/huggingface/transformers/blob/893ad04fad145904ccb71e4e858e4134c32226b6/src/transformers/utils/logging.py#L88.

### Motivation

It is a common practice to redirect logging output to `stdout` in deep learning frameworks.
For example: Detectron2: https://github.com/facebookresearch/detectron2/blob/8d85329aed8506ea3672e3e208971345973ea761/detectron2/utils/logger.py#L84
fairseq: https://github.com/facebookresearch/fairseq/blob/ecbf110e1eb43861214b05fa001eff584954f65a/fairseq_cli/train.py#L22
Deepspeed: https://github.com/microsoft/DeepSpeed/blob/2b41d6212c160a3645691b77b210ba7dd957c23f/deepspeed/utils/logging.py#L69.

Here is my analysis. Traditionally, `stdout` is used for output of the program and `stderr` is used for warning/debugging. That's why the default stream of `logging` is `stderr`. However, the output of deep learning frameworks consists of losses, eval results and checkpoints. It's a common practice to use `logger.info()` to display this information. Therefore, it would be more appropriate to redirect these outputs to `stdout` since they are part of the program's normal output.

### Your contribution

I can submit a PR if this request is confirmed.

Comments:
@ArthurZucker @Rocketknight1 

Hmn, I'm uncertain here - our code that logs losses and eval results etc. mostly exists in the `Trainer` class. It makes sense for that to be logged to `stdout`, but most other logging events in `Transformers` are intended as warnings/errors and should definitely go to `stderr`.

cc @muellerzr @SunMarc for `Trainer` logging!

@Rocketknight1 In an ideal training process, there should be little or even zero warnings/errors. A perfect solution would be to redirect `warning/error` messages to `stderr` and `info/debug` messages to `stdout`. But if we only want to use one stream for simplicity, I think `stdout` would be a better choice.

Any other official workaround to print write logs to stdout?
[bark] fix loading of generation config
Author: gante
Pull request: yes

# What does this PR do?

Supercedes #36570 

`BarkModel.can_generate()` is `False`, but it needs to be `True`. Explanation in the diff.

____________________________________________
Reproducer of the issue:
```py
from transformers import pipeline

pipe = pipeline("text-to-speech", "suno/bark")
pipe("hello")
```

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_36587). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[XGLM] tag tests as slow
Author: gante
Pull request: yes

# What does this PR do?

These two new tests load a non-small model -> test should be slow

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_36592). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Lora_B weight becomes 0 when using AuotModel
Author: makcedward
Pull request: no
Labels: name: bug

### System Info

transformers version: 4.49.0
peft version: 0.14.0

### Who can help?

_No response_

### Information

When using `AutoModel` to load the base model and passing it to`PeftModel`, the LoRA weights become 0. It is not a problem when using `AutoModelForCausalLM`.

### Tasks

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

### Reproduction

```
from transformers import AutoModel, AutoModelForCausalLM
from peft import PeftModel

base_model_id = "meta-llama/Llama-3.2-1B"
adapter_id = "makcedward/Llama-3.2-1B-Instruct-LoRA-Adapter"

auto_model = PeftModel.from_pretrained(
    AutoModel.from_pretrained(
        base_model_id,
    ),
    adapter_id
)
auto_casual_model = PeftModel.from_pretrained(
    AutoModelForCausalLM.from_pretrained(
        base_model_id,
    ),
    adapter_id
)

print("Auto Model")
print(auto_model.base_model.model.layers[0].self_attn.q_proj.lora_A.default.weight)
# tensor([[-0.0168,  0.0056, -0.0009,  ...,  0.0149, -0.0161, -0.0064],

print(auto_model.base_model.model.layers[0].self_attn.q_proj.lora_B.default.weight)
# tensor([[0., 0., 0.,  ..., 0., 0., 0.],

print("AutoModelForCausalLM")
print(auto_casual_model.base_model.model.model.layers[0].self_attn.q_proj.lora_A.default.weight)
# tensor([[ 1.5867e-02,  2.7307e-02, -1.8503e-02,  ..., -1.2035e-02,

print(auto_casual_model.base_model.model.model.layers[0].self_attn.q_proj.lora_B.default.weight)
# tensor([[-7.1123e-04, -4.3834e-03, -1.7415e-03,  ...,  4.3514e-03,

```

### Expected behavior

Able to load LoRA weights by using AutoModel

Comments:
Moved to PEFT repo
fix: argument
Author: ariG23498
Pull request: yes

Arguments is different in the docs.

https://github.com/huggingface/transformers/blob/752ef3fd4e70869626ec70657a770a85c0ad9219/utils/modular_model_converter.py#L1729


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_36558). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[docs] add the missing import for Image and bug fix
Author: faaany
Pull request: yes

## What does this PR do?
Add the missing import for Image and add comment for other hardware devices. 

There is also a bug in the code itself, which needs further debug. I will undraft, once I fixed the issue. 

@stevhliu


Comments:
Hi @stevhliu , I fixed the bug in the example code. Otherwise, I will get the following error: 

```bash
Traceback (most recent call last):
  File "/home/sdp/fanli/transformers/playground.py", line 55, in <module>
    inputs = processor(prompt, images=videos).to(model.device, model.dtype)
TypeError: LlavaProcessor.__call__() got multiple values for argument 'images'
```

And also the `sample_frames` has a bug. `video_1` contains 7 frames rather than 6. So I fixed both issues. 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34776). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
should use eigvalsh instead of eigvals for fast&stable covariance matrix diagonalization
Author: bohrium
Pull request: no
Labels: name: Performance

https://github.com/huggingface/transformers/blob/c2820c94916e34baf4486accae74760972183a2f/src/transformers/modeling_utils.py#L2473

covariance matrices are always symmetric.  so use `torch.linalg.eigvalsh`.  This caused major speedup  (>100x in preprocessing and >2x in overall finetuning) in project I'm working on today.

Comments:
cc @abuelnasr0 @gante - this line comes from #34037. 

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.

cc @bohrium no reply from the original author - would you be willing to make this PR? I think your reasoning is valid, and the performance improvement would be nice!

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.

@Rocketknight1  --- made a PR

https://github.com/huggingface/transformers/pull/35516
ModuleNotFoundError: No module named 'evaluate'
Author: ucas010
Pull request: no

### System Info

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.25.1
- Platform: Linux-3.10.0-1160.81.1.el7.x86_64-x86_64-with-glibc2.17
- Python version: 3.9.15
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.13.1+cu116 (True)
- 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?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@ArthurZucker and @younesbelkada@sgugger

### Information

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

### Tasks

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

### Reproduction

https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling
```
python run_mlm.py \
    --model_name_or_path roberta-base \
    --train_file path_to_train_file \
    --validation_file path_to_validation_file \
    --per_device_train_batch_size 8 \
    --per_device_eval_batch_size 8 \
    --do_train \
    --do_eval \
    --output_dir /tmp/test-mlm
line 35, in <module>
    import evaluate
ModuleNotFoundError: No module named 'evaluate'
myhugBert.sh:行4: --train_file: 未找到命令
myhugBert.sh:行11: --output_dir: 未找到命令
```



### Expected behavior

overcome the bug

Comments:
You need to `pip install evaluate`, as the error message tells you. This is also in the [requirements](https://github.com/huggingface/transformers/blob/main/examples/pytorch/language-modeling/requirements.txt) for this example.

First run the pip install-r requirements.txt command then still if you won't find out the module then install individual module pip install evaluate @ucas010 

Closing this issue as it seems resolved. Feel free to reopen if needed.
Github action for auto-assigning reviewers
Author: Rocketknight1
Pull request: yes

This draft PR adds a Github action to assign reviewers. It takes a similar approach to the CODEOWNERS file, but it tries to choose one or two most relevant reviewers rather than just pinging absolutely everyone.

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

Should be ready, pinging @ydshieh and @ArthurZucker for review! (In future, these pings will be automatic :sweat_smile: )

The `pull_request_target` will checkout to the base branch of the pull request (which is usually the `main`).

That is why it is secure by default (and not blocked by the `need approval` configuration).

So here we need to find the actual PR commit, checkout to it, but keep the job/steps secure when doing this.

[Ref](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target)

It's kind involved. If you prefer, I can work on this workflow part next week.

Guess I can take over this PR unless @Rocketknight1 has any other thought. Will do it this week.

I'm sorry, I just got distracted by other stuff! The PR should be ready, though - if you want to merge it or take over, go ahead @ydshieh 

@Rocketknight1 @ArthurZucker 

I took a look, and @Rocketknight1 is using `pull_request_target` event, without checkout to the PR head branch, so the action is running against the `main` branch.

Furthermore,  the script `.github/scripts/assign_reviewers.py`, it gets the touched files without checkout to the PR head branch neither: it uses `PyGithub` and avoids the checkout.

Therefore, my previous concern regarding security is not presenting. Great job @Rocketknight1 !

I will review this PR in a more detailed manner later.

cc @ydshieh I'm seeing typing failures that I think your PR already fixed - do you know why the CI is still running the old verison?

maybe you haven't rebase / merge the latest main branch ..?

It's rebased!

A second rebase fixed it - maybe I just needed to clear a cache @ydshieh! Sorry to bother you.

Should be ready for final review now though, and licence is added @ArthurZucker !

The auto-assign action picks 2-3 reviewers based on file changes. How exactly does it rank them? Should we refine the logic to avoid unnecessary pings (e.g., skipping PR authors automatically)?

@machinelearningprodigy They're ranked by how many lines of code touch files that are "owned" by that person, where ownership is defined in the `codeowners_for_review_action` file.
Update recommended reviewers
Author: Rocketknight1
Pull request: yes

It's been a couple of months and the mourning period has concluded, so we can stop pinging Yoach and Sanchit now :sweat_smile: 

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

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

Duplicate of #36394!
Update chat_extras.md  with content correction
Author: krishkkk
Pull request: yes

# What does this PR do?
Fixed a typo in the content, that may confuse the readers.


## 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?





Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).
Update "who to tag" / "who can review"
Author: gante
Pull request: yes

# What does this PR do?

Updates tag suggestions: yoach and sanchit are no longer part of the team, and they were getting tagged.


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_36394). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Open Object Detection Leaderboard: Model Requests not working
Author: daniel-bogdoll
Pull request: no
Labels: name: bug

### System Info

When I want to request an evaluation for a model on the [Hugging Face Open Object Detection Leaderboard](https://huggingface.co/spaces/hf-vision/object_detection_leaderboard), I get an `Error submitting request!`

I have tried:

- [PekingU/rtdetr_r50vd](https://huggingface.co/PekingU/rtdetr_r50vd)
- [PekingU/rtdetr_r50vd_coco_o365](https://huggingface.co/PekingU/rtdetr_r50vd_coco_o365)
- [jozhang97/deta-swin-large-o365](https://huggingface.co/jozhang97/deta-swin-large-o365)
- [IDEA-Research/dab-detr-resnet-50](https://huggingface.co/IDEA-Research/dab-detr-resnet-50)

For models that are already evaluated, I get something like `Results of the model 'hustvl/yolos-base' are now ready and available.`, which is as expected.

### Who can help?

@rafaelpadilla 
@amyeroberts 

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

Enter Model name (user_name/model_name) at https://huggingface.co/spaces/hf-vision/object_detection_leaderboard --> Request a model here

### Expected behavior

Should start an evaluation run

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.

cc @clefourrier 

Hi! You should open a discussion directly on the space, so that the maintainers of said leaderboard see your request.
Fix check for XPU. PyTorch >= 2.6 no longer needs ipex.
Author: tripzero
Pull request: yes

Update is_torch_xpu_available. Only check for ipex module if torch version is less than 2.6. Ipex is no longer necessary as of torch 2.6.

@Rocketknight1


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).
Allow parameters of the ViTPooler to be configurable, with the default values set to the current hardcoded values
Author: sebbaur
Pull request: no
Labels: name: Feature request

name: Vision

### Feature request


I would like to add `pooled_output_size: int | None` and `pooler_act: str` fields in ViTConfig such that the following https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L665-L666 can be configured if needed.

The two fields would have default values `None` (which results in using the value of `hidden_size`, like is currently done, and `tanh`. This would result in no change to the default behaviour, while allowing some flexibility.



### Motivation

This is part of the open-sourcing of the HeAR model (https://arxiv.org/abs/2403.02522) in PyTorch format. The encoder uses the ViT architecture, and the pooler has no activation (identify function instead of tanh) and the pooling dimension is smaller than the hidden dimension.

### Your contribution

I will submit a PR 

Comments:
hi @sebbaur, we generally don't modify existing models in this way! Although it seems straightforward, lots of models are small modifications of existing models, and the changes can quickly overwhelm the modeling code if we incorporate them all. Instead, you could try:

1) Adding HeAR as a custom code model: https://huggingface.co/docs/transformers/en/custom_models
2) Adding HeAR as a [modular model](https://huggingface.co/docs/transformers/en/modular_transformers) that inherits from ViT but overrides the config and code where required.

Hello @Rocketknight1, I am a bit confused why? This change is a no-op by default, and just makes two hardcoded hyperparameters configurable (the activation of the final layer and its number of output channels)

It doesn't seem to warrant a new model? HeAR is just a trained ViT


Hi @Rocketknight1, do you still feel this warrants a new model ? The PR is ready if you want to take a look

Hi @sebbaur, I thought about it a bit more and it's probably fine, so I'm sorry for troubling you! We generally have a philosophy of avoiding changes like that to existing models, but since the PR is ready and seems compact enough we can probably get away with it this time 😅 

Apologies -- I should have waited for feedback before doing this

Just for my understanding -- what would have been the recommended way of doing this change? Creating a new class inheriting from ViT and overwriting what needs to be changed? 

Yeah, but in this case the change is probably small enough that that would be a lot of extra work. Don't worry about it!
[bugfix] Update modeling_llama.py so it skips keys correctly
Author: HDCharles
Pull request: yes

the llama model was using past_key_value and past_key_values interchangeably which caused issues because only one of those was actually skipped in _skip_keys_device_placement when both needed to be.

This PR changes it so only past_key_values is used.

without this fix, llama + torch.compile was having issues as in the surfaced issue below. Note, though this was surfaced due to a TorchAO recipe though the bug was unrelated to torchao

i think https://github.com/huggingface/transformers/pull/35763 might have caused this bug but not sure

Fixes

https://github.com/pytorch/ao/issues/1705

- text models: @ArthurZucker (not sure if this is the right person)
- @hmellor @Rocketknight1 (last 2 hf people to touch this code)
- @SunMarc (previously worked on torchao hf stuff)



Comments:
cc @SunMarc can you take a look?

are these test failures actually blocking? it seems like other models just have the same issue.

This [PR](https://github.com/huggingface/transformers/pull/35873) that was merged today actually fixes the issue that you are having (Cache is not a `nn.Module` anymore, so it will be skipped automatically). 

Still, it would be indeed be better to only keep one of them. @ArthurZucker why do we have `past_key_value` and `past_key_values` ?
Accidentally allocating 2x memory in new caching_allocator_warmup
Author: c0g
Pull request: no

It seems like https://github.com/huggingface/transformers/commit/1603018e7aa517623192cc9ff164bbec513b66e4 is allocated 2x the memory required? I now can't allocate a 7b for inference. 

https://github.com/huggingface/transformers/blame/51083d1bac7905aa8316b75f7897bdd4e5302044/src/transformers/modeling_utils.py#L5849

Comments:
Hi @c0g, this line has been updated! Can you retest with the latest version from `main` and confirm if the issue is resolved?

yep thanks
Deprecate transformers.agents
Author: aymeric-roucher
Pull request: yes

# What does this PR do?

Deprecates `transformers.agents` in favor of [smolagents](https://github.com/huggingface/smolagents) for extended functionality, and a similar API.

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

@aymeric-roucher This seems like a great idea! One snag though is that `smolagents` requires Python >= 3.10 but Transformers requires Python >= 3.9. So deprecating this doesn't give those that need Python == 3.9 a path to migrate. 

Thoughts?