noamaanMulla-03/transformers-issues huggingface dataset:
`tokenizer` is still being used in `Trainer` instead of `processing_class`
Author: arjunaskykok
Pull request: no

In the [`Fine-tuning a model with the Trainer API` page](https://huggingface.co/learn/llm-course/chapter3/3?fw=pt), either in the documentation or the notebook, we are told to use the `tokenizer` parameter when initializing the `Trainer` class.

![Image](https://github.com/user-attachments/assets/3b2870e9-210b-404f-a2b8-d3091fcac7ad)

But the `tokenizer` parameter has been deprecated. We should use the `processing_class` parameter.

@stevhliu

Comments:
Good catch, would you like to open a PR to update the docs and course to use the `processing_class` parameter instead?

Okay, I'll do it.

PRs:

https://github.com/huggingface/course/pull/895
https://github.com/huggingface/notebooks/pull/574
chore: update SigLIP2 model card
Author: saswatmeher
Pull request: yes

# What does this PR do?
Update the model card for SigLIP2 to handle #36979 

Fixes #36979 


## 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.
- [ ] 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.

Documentation: @stevhliu


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

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

Addressed. Thank you for your suggestions! :)
fix performance issue in convert_ids_to_tokens
Author: martin-harmonic
Pull request: yes


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

cc @itazap for tokenizers - it's simple enough and shouldn't have side effects, so feel free to merge if you're happy with it too

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

Looks good to me! thanks! 😊
Fix error message in `hub.py`
Author: srai9
Pull request: yes

# What does this PR do?
This PR fixes a broken link in an error message in `hub.py`. A space is missing between the link and the following text.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@stevhliu @Rocketknight1


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37796). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Not able to trace GPT2DoubleHeadsModel
Author: levindabhi
Pull request: no
Labels: name: bug

### System Info

Hi, I'm trying to create trace of GPT2DoubleHeadsModel model but I'm facing issue. Here is my code

```
from transformers.utils import fx
from transformers import *

gpt2_config = GPT2Config()
model = GPT2DoubleHeadsModel(gpt2_config)
input_names = model.dummy_inputs.keys()
trace = fx.symbolic_trace(model, input_names)
```

I'm getting below error

File "~/venv/lib/python3.12/site-packages/torch/fx/proxy.py", line 327, in iter
    raise TraceError('Proxy object cannot be iterated. This can be '
torch.fx.proxy.TraceError: Proxy object cannot be iterated. This can be attempted when the Proxy is used in a loop or as a *args or **kwargs function argument. See the torch.fx docs on pytorch.org for a more detailed explanation of what types of control flow can be traced, and check out the Proxy docstring for help troubleshooting Proxy iteration errors

Any help, Thanks!

### Who can help?

@ArthurZucker @michaelbenayoun 

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

```
from transformers.utils import fx
from transformers import *

gpt2_config = GPT2Config()
model = GPT2DoubleHeadsModel(gpt2_config)
input_names = model.dummy_inputs.keys()
trace = fx.symbolic_trace(model, input_names)
```

### Expected behavior

Expecting it to work without error

Comments:
Hi @levindabhi, I don't know if we're strongly supporting `torch.fx` right now - we're refocusing on making sure everything works with `torch.compile` instead!

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.
BERT is broken on `v4.49.0-Gemma-3`
Author: koute
Pull request: no
Labels: name: bug

### System Info

I'm using pytorch 2.6.0 on Linux.

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

Consider the following code:

```py
import transformers

model = transformers.AutoModelForMaskedLM.from_pretrained("google-bert/bert-base-cased")
tokenizer = transformers.AutoTokenizer.from_pretrained("google-bert/bert-base-cased")

text = "Hi! My name is Stinky Bob and I'm a [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs["logits"][0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print(predicted_token)
```

On `v4.49.0-Gemma-3` it produces the following output:

```
man
```

On `4.49.0`, `4.48.0`, `4.40.0`, `4.30.0` it produces the following output:

```
friend
```

As far as I can see it breaks on `v4.49.0-Gemma-3` because the checkpoint loading is broken, and it doesn't load the weights for the `model.cls.predictions.transform.LayerNorm` properly (the weights are just default initialized).

### Expected behavior

I expect the BERT weights to be properly loaded and the output consistent with the previous version of transformers.

Comments:
Hey! Can you try to update and install from source, since we did a big refactoring for model load on `main` branch? 

> Hey! Can you try to update and install from source, since we did a big refactoring for model load on `main` branch?

Yep, it's fixed on the newest `main`.

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 use tensorboard with Trainer?
Author: tanujjain
Pull request: no

From the docs, TrainingArguments has a 'logging_dir' parameter that defaults to 'runs/'. Also, Trainer uses a default callback called TensorBoardCallback that should log to a tensorboard by default.

I use:
```
training_args = TrainingArguments(
    output_dir=".",
    group_by_length=True,
    per_device_train_batch_size=8,
    gradient_accumulation_steps=2,
    evaluation_strategy="steps",
    num_train_epochs=1,
    save_steps=1,
    eval_steps=1,
    logging_steps=1,
    learning_rate=3e-4,
    max_steps=1,
) 

trainer = Trainer(
    model=model,
    data_collator=data_collator,
    args=training_args,
    compute_metrics=compute_metrics,
    train_dataset=dataset_train,
    eval_dataset=dataset_test,
    tokenizer=feature_ext,
)
```
So, I rely on default parameters of TrainingArguments and Trainer while hoping to find a `runs/` directory that should contain some logs but I don't find any such directory. Could someone please help on how to get tensorboard working?

Comments:
Are you sure it's properly installed? This code should indeed work if `tensoboard` is installed in the environment in which you execute it. You can try to force the `TensorBoard` integration by adding `report_to=["tensorboard"]` in your `TrainingArguments`.

@sgugger My bad, somehow missed tensorboard installation.  Apologies for the inconvenience. Closing the issue.

hi @sgugger  ,
argument report_to = 'tensorboard' did not launch anything .
i am new . am i missing something?
can you please tell me how to use tensorboard loss graph .


I have the same, @git-baahubali  have you fixed it?


> I have the same, [@git-baahubali](https://github.com/git-baahubali) have you fixed it?

Nope
Why does "is_causal = query.shape[2] > 1 and causal_mask is None"?
Author: ChengLyu
Pull request: no

Trying to understand this [line](https://github.com/huggingface/transformers/blob/main/src/transformers/integrations/sdpa_attention.py#L47):

Why does "is_causal = query.shape[2] > 1 and causal_mask is None"?  Does it mean that `is_causal` `true` if there is no causal mask? I tend to think the opposite?

Thank you for the help.

Comments:
This is a bit of a weird one and directly relates to how torch has implemented the sdpa module. In essence, the `is_causal=True` kwarg would ignore/disallow the provided attention mask and directly use causal masking internally instead. However, this is often unwanted as we have padding for example which technically produces a non causal mask (you might interpret it as a delayed causal mask if using left padding for example). The conditions relate to 
- `q` is only having a `seq_len` of 1 which would translate to a full attention mask (not causal) in any case --> `is_causal=False`
- we do not flag it as causal will be interpreted as full mask / using the provided mask --> `is_causal=False`
- no mask provided and we flag it as causal will be interpreted as the usual causal mask with no padding (which assumes that all sequences in the batch have the same length) --> `is_causal=True`
- mask provided and we flag it as causal wil be interpreted as using the provided mask --> `is_causal=False`

In most cases, a mask is provided due to padding --> `is_causal=False` but using a custom mask (eg delayed causal mask) circumventing torch shenanigans.

Tldr; We need to force our masks to ensure correct padding etc when the `is_causal` flag would not allow us to do so. When no mask is provided, we assume no padding and allow torch to use their internal causal mask (without padding).

Thank you @vasqu for the clarification.

What if caller passes in `is_causal=True` and provides a mask? In this case, does the `is_causal` take the dominance so torch uses its internal mask and ignores the provided one?

Not sure tbh and not on a pc atm but you could check it yourself by creating a random mask + inputs (with reasonable shapes). My hunch says that it would throw an error. See also the official docs @ https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html where they have an assert statement when using the flag (forcing no attention mask to be passed).

Even then, I'd suggest using the flag whenever you can to allow torch to use more efficient backends such as flash attention. <-- this is undocumented and it's obscure imo that to this day that the details on which backend gets chosen when is not really easy to check (unless reading the c++ code directly).

I can check later when I have proper time 👀 

Just experiment with providing `is_causal=True` and providing a custom mask, did get the runtime error:
`RuntimeError: _scaled_dot_product_attention: Explicit attn_mask should not be set when is_causal=True`.

Thank you @vasqu for the discussion!
GOT-OCR2 docs indicate model can produce markdown, but it only produces LaTeX.
Author: piercelamb
Pull request: no

Stated [here](https://huggingface.co/docs/transformers/en/model_doc/got_ocr2#formatted-text-inference)

Returning formatted text is toggled via the `format` boolean:
```python
inputs = processor(image, return_tensors="pt", format=True).to(device)
```
It only returns LaTeX. Can the model somehow return markdown or are the docs mistaken?

Comments:
cc @yonigozlan 

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.
[VLMs] fix flash-attention tests
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

FA2 with layer norm upcasted was failing for all VLMs before. The issue lies in VLM config structure which is composite, and modifying base config doesn't update sub-configs (which are also deepcopied in model with `XXX._from_config`)

The solution is to apply recursively config update on model's children, whenever a PretrainedModel is found. Though I am not sure if we need any recursive calls when `prepare_model_for_quantization`, it doesn't seem to update config 

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

run-slow: janus

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

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

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

Hi  @zucchini-nlp this PR introduced a regression in PEFT. Before the PR, the model card would look like this:

```markdown
---
library_name: peft
base_model: facebook/opt-125m
---

# Model Card for Model ID
[...]
```

Afterwards, the `base_model` meta info is missing:

```markdown
---
library_name: peft
---

# Model Card for Model ID
[...]
```

Here is a reproducer:

```python
# testfile.py
from transformers import AutoModelForCausalLM
from peft import LoraConfig, get_peft_model

model_id = "facebook/opt-125m"

def test_save_peft_modelcard(tmp_path):
    model = AutoModelForCausalLM.from_pretrained(model_id)
    config = LoraConfig()
    model = get_peft_model(model, config)
    model.save_pretrained(tmp_path, safe_serialization=False)

    with open(f"{tmp_path}/README.md") as f:
        model_card = f.read()
    assert "base_model: facebook/opt-125m" in model_card
```
New Model: Ava
Author: Kuduxaaa
Pull request: yes

# 🚀 Add AvaModel: A Scalable & Efficient LLM Architecture

## Overview
This PR introduces **AvaModel**, a new transformer-based language model architecture designed for high performance across different scales (100M to 100B parameters).   

## Architecture Highlights
```python
AvaForCausalLM(
  (model): AvaModel(
    (embed_tokens): Embedding(32000, 1280)
    (layers): ModuleList(
      (0-11): 12 x AvaDecoderLayer(
        (self_attn): AvaAttention(
          (q_proj): Linear(in_features=1280, out_features=1280, bias=False)
          (k_proj): Linear(in_features=1280, out_features=640, bias=False)
          (v_proj): Linear(in_features=1280, out_features=640, bias=False)
          (o_proj): Linear(in_features=1280, out_features=1280, bias=False)
          (dropout): Dropout(p=0.0, inplace=False)
        )
        (mlp): AvaMLP(
          (gate_proj): Linear(in_features=1280, out_features=5120, bias=False)
          (up_proj): Linear(in_features=1280, out_features=5120, bias=False)
          (down_proj): Linear(in_features=5120, out_features=1280, bias=False)
          (act_fn): SiLU()
        )
        (input_layernorm): AvaRMSNorm()
        (post_attention_layernorm): AvaRMSNorm()
      )
    )
    (norm): AvaRMSNorm()
    (rotary_emb): AvaRotaryEmbedding()
  )
  (lm_head): Linear(in_features=1280, out_features=32000, bias=False)
)
```

More info: [Kuduxaaa/ava-llm](https://github.com/Kuduxaaa/ava-llm)


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

Hi @kuduxaaa, we generally don't add architectures to `transformers` until a significant pre-trained model exists using that architecture! The architecture looks good and we appreciate the educational goal, but we probably won't be able to merge this PR. I'm sorry!

Thanks for the clarification! Totally understandable. I appreciate the feedback and the kind words about the architecture. Once a pre-trained model is ready and properly evaluated, I’ll revisit this with a new PR 🥳🧠
AutoModel from_pretrained does not recursively download relative imports
Author: yair-schiff
Pull request: no
Labels: name: bug

## **Background**
I have the following setup:

My directory looks like:
```
|--modeling.py
|--backbone.py
|--modules.py
```

In `modeling.py` I have an import statement to `backbone`:
```
from .backbone import ...
```

and likewise in `backbone.py` I have an import statement to `modules`:
```
from .modules import ...
```

My auto_map references `modeling.py`:
```
config.auto_map = {"AutoModel": "modeling.[some_class_in_this_file]"}
```

Now, I push a model to the hub and I also upload all 3 files to the repo.

## **Issue**
However, when I try to use `AutoModel.from_pretrained` on my repo, I get a `FileNotFoundError` because for some reason `modules.py` was not cloned/pulled to the HF_HOME dir:
```
FileNotFoundError: [Errno 2] No such file or directory: '<HF_HOME>/transformers_modules/<repo>/modules.py'
```

I understand that the necessary relative imports are obtained recursively as [here](https://github.com/huggingface/transformers/blob/81aa9b2e07b359cd3555c118010fd9f26c601e54/src/transformers/dynamic_module_utils.py#L108-L138).

How come the relevant files aren't also pulled/cloned recursively?


### Expected behavior

Recursive dependencies should be cloned/pulled when `AutoModel.from_pretrained` is called

Comments:
Self-assigning, will investigate this one

Finally got around to this one, sorry for the delay! Can you share your code, or if there's anything proprietary in there, can you try to make a minimal reproducer that shows the behaviour and upload it? It'll help a lot in speeding up the debugging process!

@Rocketknight1 thank you for following up. I was working on a minimal reproducible repo to share but I am realizing that perhaps my initial error was that I did not do the following (assuming I have `MyModelConfig` and `MyModel` classes defined in `modeling.py`):
```
MyModelConfig.register_for_auto_class()
MyModel.register_for_auto_class("AutoModel")
```

Are these steps essential? I do have the following defined in my config:
```

auto_map = {
    'AutoConfig': 'modeling.MyModelConfig', 
    'AutoModel': 'modeling.MyModel'
}
```

Generally yes, but I realize this isn't well-documented. We might want to make a note to more clearly document the process for writing/uploading custom code models (cc @stevhliu, but I realize the code is quite arcane - let me know if you want me to draft something!)

Yeah if you don't mind drafting something, that'd be super @Rocketknight1 ! The relevant section for documenting it would be [here](https://huggingface.co/docs/transformers/main/en/custom_models#upload) 😄 

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.