noamaanMulla-03/transformers-issues huggingface dataset:
WSD Scheduler to auto infer training steps
Author: wheynelau
Pull request: no
Labels: name: Feature request

### Feature request

WSD Scheduler should calculate stable steps in `trainer.py`. And if num_warmup_steps is provided in kwargs, schedule_func should respect the kwargs. 

My guess is that the intention is it to decay till min and stay there till the end of training, but `min_lr_ratio` is set to the default of 0, wouldn't the learning rate be always 0? Would like to have some insights on this if possible.

```
TypeError: get_wsd_schedule() missing 1 required positional argument: 'num_stable_steps'
```

Additionally, trying to pass in `num_warmup_steps` in `lr_scheduler_kwargs` will result in duplicate keys:
```
     return schedule_func(optimizer, num_warmup_steps=num_warmup_steps, **scheduler_specific_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: transformers.optimization.get_wsd_schedule() got multiple values for keyword argument 'num_warmup_steps'
```



### Motivation

I want to run WSD scheduler for my training, but I do not want to have to calculate the stable steps.

### Your contribution

I can contribute to this, but I would like to better understand the edge cases or possible scenarios I might have missed out from the maintainers. However, here is my current workaround:

```
def get_wsd_schedule(
    + num_training_steps: int = 0,
):

...
    assert num_stable_steps or num_training_steps, "One of either stable steps or training steps must be provided"
    if not num_stable_steps:
        num_stable_steps = num_training_steps - num_warmup_steps - num_decay_steps
```

```
    if name == SchedulerType.WARMUP_STABLE_DECAY:
        return schedule_func(optimizer, num_warmup_steps=num_warmup_steps,num_training_steps=num_training_steps, **scheduler_specific_kwargs)
```

Comments:
cc @muellerzr @sunmarc for Trainer
deepspeed zero3 NVMe offload is  not working
Author: eljandoubi
Pull request: no
Labels: name: bug

### System Info

transformers==4.46.0
accelerate==1.0.1
sentencepiece==0.2.0
deepspeed==0.15.3

<img width="601" alt="pin" src="https://github.com/user-attachments/assets/cd3f2734-30a6-4509-91ff-e1e4cb9149a4">


### Who can help?

@muellerz @SunMarc @ArthurZucker @amyeroberts @qubvel

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

accelerate configr:
compute_environment: LOCAL_MACHINE                                                                                                                                           
debug: false
deepspeed_config:
  deepspeed_multinode_launcher: standard
  gradient_accumulation_steps: auto
  gradient_clipping: 1.0
  offload_optimizer_device: nvme
  offload_param_device: nvme
  zero3_init_flag: true
  zero3_save_16bit_model: false
  zero_stage: 3
distributed_type: DEEPSPEED
downcast_bf16: 'no'
machine_rank: 0
main_process_ip: 0.0.0.0
main_process_port: 0
main_training_function: main
mixed_precision: bf16
num_machines: 3
num_processes: 24
rdzv_backend: c10d
same_network: true
tpu_env: []
tpu_use_cluster: false
tpu_use_sudo: false
use_cpu: false

================================================

I launch the code using 

```
accelerate launch --config_file config.yml code.py
```

```
from transformers import AutoModelForVision2Seq, BitsAndBytesConfig

model_kwgs = {
     "pretrained_model_name_or_path": "local_folder/contains/paligemma-3b-pt-896",
     "trust_remote_code":True,
     }

model = AutoModelForVision2Seq.from_pretrained(**model_kwgs)
```

### Expected behavior

Have a NVMe offloaded model.

Comments:
Hey! is there a reason why you are using `trust_remote_code = True`? This would use the online code, not the `transformers` native one!

@ArthurZucker I set `trust_remote_code = True` to bypass the warnings, but it had no effect on the error.

No you need to set it to `False` instead normally
[`peft`] Given that `self.active_adapter` is deprecated, avoid using it
Author: tomaarsen
Pull request: yes

# What does this PR do?

`PeftAdapterMixin.active_adapter` has been deprecated since #26407 added multi-adapter support, but it's still being used in `PeftAdapterMixin.get_adapter_state_dict`. This results in a FutureWarning every time I save a checkpoint after training with `model.add_adapter(...)`.

This PR updates the latter to use the correct `PeftAdapterMixin.active_adapters()[0]` method instead, which is identical in behaviour, except minus the warning.

The deprecated `active_adapter`: https://github.com/huggingface/transformers/blob/54739a320e38bc86cd250303a35e68d5d3f14a83/src/transformers/integrations/peft.py#L433-L438

Additionally, the comment 
```
The model will use `self.active_adapter()`
```
in `enable_adapters` seemed to be a bit misleading - that method wasn't being used. For clarity, I removed it.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?

@ArthurZucker @BenjaminBossan

- Tom Aarsen


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34804). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Need to reduce the Latency in Musicgen-Small model while concurrent request comes in.
Author: Pr0fe5s0r
Pull request: no

Hey guys, I am working in a MusicGen Project where we have like 2xL4 GPU with 24GB VRAM each. So, currently we are using the same exact code from this huggingface spaces. 

Code: [musicgen-streaming](https://huggingface.co/spaces/sanchit-gandhi/musicgen-streaming)
Model: [facebook/musicgen-small](https://huggingface.co/facebook/musicgen-small)
`transformers==4.45.2`

I have like 4 docker containers and each container has its own model running.

**Problem** 
When i try to do inference in any one of the container the latency is low. like 2.3 + - sec. But when i do a concurrent request to different containers the latency spikes to 3.4 sec on all the containers. Even i have isolated the models i get this result. It is the same exact code but instead of Gradio i am using a FastAPI code to serve the chunks.

**Needed**
Need to decrease the latency and need to do 5 concurrent request least

Thanks

Comments:
I suspect this isn't a Transformers bug, unfortunately! It's hard to imagine a bug that would interact with containers in this way - the issue is much more likely to be caused by how you're assigning/gathering work from containers / GPUs. 

Closing for now, but feel free to reopen if you think it really is a Transformers bug - we might need a simple reproducer or something like that to productively work on the issue, though!

@Rocketknight1 hey thank you for the reply. So, I have used nvidia-smi and top tools to measure the loads. they are isolated. to reproduce the same issues https://huggingface.co/spaces/sanchit-gandhi/musicgen-streaming use this gradio app. try to generate the request in concurrent manner. there will be a latency in exponential manner.

I guess this is because of CUDA kernel. What you think?
Fix : BitNet tests
Author: MekkCyber
Pull request: yes

# What does this PR do?
Fixes BitNet tests for the CI

## Who can review ?
@SunMarc 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34895). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[AWQ, CI] Bump AWQ version used in docker image
Author: BenjaminBossan
Pull request: yes

# What does this PR do?

The old AWQ version is failing with the latest (unreleased) transformers, giving the error:

> ImportError: cannot import name 'shard_checkpoint' from
'transformers.modeling_utils'

This has been resolved in awq v0.2.7:

https://github.com/casper-hansen/AutoAWQ/pull/644

Fixes part of the failing quantization CI:

- https://github.com/huggingface/transformers/actions/runs/12002230961/job/33454061676
- https://github.com/huggingface/transformers/actions/runs/12002230961/job/33454065681


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] ~~Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.~~ Discussed internally on Slack
- [ ] 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:
Merging this as this is a small change related to quantization tests. 

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

# What does this PR do?

This test assert `model.out_indices, (-2, -1)` and it was written on 2023/12.

However, we have

> out_indices = list(out_indices) if out_indices is not None else None

in `src/transformers/utils/backbone_utils.py` which is written on 2024/05

It's just time to update the test so we don't see it fails forever.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34877). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Upgrade torch version to 2.5 in dockerfile for quantization CI
Author: MekkCyber
Pull request: yes

# What does this PR do?
Upgrade the torch version to 2.5.1 in the dockerfile for the quantization CI
Job for docker image with torch 2.5.1 : https://github.com/huggingface/transformers/actions/runs/12013872016
## Who can review ?
@SunMarc 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34924). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Auto compile when static cache
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Add automatic compile for `static` cache. 
This can be tested with:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
import time
device = "cuda"
model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B", torch_dtype=torch.float16).to(device)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B")

sequence = "Hey what's the plan"

inputs = tokenizer.encode(sequence, return_tensors='pt').to(device)
model.generation_config.temperature = 1.0
model.generation_config.top_p = 1.0

t0 = time.time()
out = model.generate(inputs, do_sample=False, max_new_tokens=500)
out = tokenizer.batch_decode(out, skip_special_tokens=True)[0]
dt = time.time() - t0
print(f'dt: {dt}', out)

t0 = time.time()
out = model.generate(inputs, do_sample=False, max_new_tokens=500, cache_implementation="static")
out = tokenizer.batch_decode(out, skip_special_tokens=True)[0]
dt = time.time() - t0
print(f'dt: {dt}', out)

t0 = time.time()
out = model.generate(inputs, do_sample=False, max_new_tokens=500, cache_implementation="static")
out = tokenizer.batch_decode(out, skip_special_tokens=True)[0]
dt = time.time() - t0
print(f'dt: {dt}', out)
```
which give 15sec for dynamic, 30 for the first generate, then 4seconds for the next one


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

# What does this PR do?
This PR fixes a failling test in `test_ggml.py` related to the function `test_falcon7b_q2_k`. The error that was occuring is 
```
The following `model_kwargs` are not used by the model: ['token_type_ids'] (note: typos in the generate arguments will also show up in this list)
```
## Who can review ?
@SunMarc 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34871). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
fix: Adjust slow tokenizer for return_overflowing_tokens
Author: tibor-reiss
Pull request: yes

Fixes #28900 

ToDo:
- add tests
- update docs
- check regression

- [ ] 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?

@ArthurZucker @amyeroberts 

Comments:
Fix import structure for Fast Image processors
Author: yonigozlan
Pull request: yes

# What does this PR do?

Small fix to include torchvision dependency in import structure for DETR, RT-DETR, Deformable DETR Fast image processors

Not sure why I didn't see it before, or why it didn't break anything, but better safe than sorry :) 

<!--
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.
-->

## Who can review?

@ArthurZucker 

<!-- 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 @MekkCyber

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_34859). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
VideoLLaVA: add default values
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

As a final step of updating models to work on non-legacy path, this PR adds default values in video llava model. Since the hub repo owner has not been active for several months now, I think all we can do is to hardcode the defaults. Especially when there is only one ckpt with this particular architecture, we should be good to go

Anyone is still free to tweak the params by passing new values in the init

PS. Some slow tests might be failing, related to https://huggingface.slack.com/archives/C01NE71C4F7/p1732216183109549 . All slow tests should be run and fixed after https://github.com/huggingface/transformers/pull/34502 finalizing work on VLM-side

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34916). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): dlopen: cannot load any more object with static TLS
Author: liuzhao104
Pull request: no
Labels: name: Usage

name: Installation

name: bug

### System Info

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
dlopen: cannot load any more object with static TLS

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

why

### Expected behavior

why

Comments:
Hello! This doesn't seem linked to `transformers` unfortunately, it seems to be linked with your environment

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.
How to output token by token use transformers?
Author: xuanzhangyang
Pull request: no
Labels: name: Discussion

name: bug

### System Info

...

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

...

### Expected behavior

How to output token by token use transformers?

Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

Thanks!

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.
Skipping aqlm non working inference tests till fix merged
Author: MekkCyber
Pull request: yes

# What does this PR do?

In the inference part of AQLM they use the type `torch.Any` which was deprecated in torch 2.5. This PR simply skips inference tests with AQLM models till the fix https://github.com/Vahe1994/AQLM/pull/139 is merged to fix the CI.

## Who can review ?
@SunMarc 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34865). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
llama3.1 tokennizer from transformers has Different behavior from origin openai/tiktoken
Author: WhatGhost
Pull request: no
Labels: name: bug

### System Info

transformers == 4.46.0
tiktoken==0.8.0

### Who can help?

_No response_

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

@ArthurZucker @itazap hi, i use transformers to run a llama3.1 model。
but I found that the ids after tokennizer.encode is difference from the tiktoken lb from openai.tiktoken(https://github.com/openai/tiktoken)

The code is shown below
```python
        import tiktoken
        from transformers import AutoTokenizer

        tokenizer = AutoTokenizer.from_pretrained(args.model_path, fast=True)
        prompt = "请你基于以下「评估标准」"
        token_ids = tokenizer.encode(prompt)  #[15225, 57668, 125510, 88852, 13177, 64479, 112494, 110778, 10646]
        encoding = tiktoken.get_encoding("cl100k_base")
        titoken_ids = encoding.encode(prompt) #[15225, 57668, 75146, 35304, 88852, 13177, 64479, 17885, 108, 31944, 12870, 228, 10646]
```

i wondered if there is any difference betwen openai/tiktoken and transformers. 
and if the answer is yes,how can i modify the code to convert openai/titoken to transformers 's llama3.1's tokennizer 

Can anyone help me? Thanks!

### Expected behavior

expected if there is any difference betwen betwen openai/tiktoken and transformers's llama3.1 tokennizer. and how can convert each

Comments:
`cl100k_base` is used for OPENAI series models: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb?short_path=19ce768#L26. It has different tokenizer with llama series. That's why you can't get the same token ids I think.

Indeed, we plan to support converting directly from any given encoding, you would be able to do : `tokenizer = AutoTokenizer.from_pretrained("cl100k_base", fast=True)` but in the mean time you have to use the `TikTokenConverter`

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.

@techkang @ArthurZucker Thanks for your relpy. It works and i solved the problem. It's not a bug.It's my misunderstanding of tiktoken. I will close this issue. Thanks again!