noamaanMulla-03/transformers-issues huggingface dataset:
AutoTokenizer / Process does not support Magistral model
Author: benglewis
Pull request: no
Labels: name: bug

### System Info

Transformers version: 4.57.1
Python: 3.13
Linux and macOS (seems irrelevant)

### Who can help?

It looks like the same issue is also breaking the `AutoTokenizer` for Magistral:

> Traceback (most recent call last):
>   File "./debug_mistral.py", line 23, in <module>
>     tokenizer = AutoTokenizer.from_pretrained("mistralai/Magistral-Small-2509")
>   File "./.pixi/envs/dev/lib/python3.13/site-packages/transformers/models/auto/tokenization_auto.py", line 1156, in from_pretrained
>     tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
>                                                ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
>   File "./.pixi/envs/dev/lib/python3.13/site-packages/transformers/models/auto/auto_factory.py", line 815, in __getitem__
>     raise KeyError(key)
> KeyError: <class 'transformers.models.mistral3.configuration_mistral3.Mistral3Config'>

### Information

- [ ] The official example scripts
- [ ] 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

```python
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("mistralai/Magistral-Small-2509")
```

### Expected behavior

It should work and not crash.

Comments:
This appears similar to #36968 and I believe that I can fix it similarly

#42198 should fixes your issue no? Magistral is also `mistral3`. Note that there hasn't been a patch or release so you need to be on main. 

Note that you will need `mistral-common` package as well. Other tokenizers don't work for now

@vasqu Ohh, yeah, you are right, it seems to work with the latest code from `main`. My apologies 🙏 

Is there any chance that this fix can be backported to a `transformers` 2.x release? I ask since I see that `main` is for `transformers` 3.x already

Ehm, we are on version v4 and go to the next major v5 soon. I think we planned backporting certain PRs for v4 as patch release cc @ArthurZucker @Cyrilvallez 

This one will be patch for v4 this week!
[loading] Re-add and improve disk offloading support
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

This PR re-add support for weight offloading to disk using the `device_map`, which was temporarily dropped in https://github.com/huggingface/transformers/pull/41580 to simplify the PR (because weights need to be resaved correctly after performing custom Ops during dynamic loading).

It further improve the offloading mechanism as everything is now offloaded in `safetensors` format, vs `numpy` format originally when using `accelerate`. This is much easier and efficient.

Slow tests are exactly similar to before the big weight loading refactor (10 failing over all models)

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

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: deepseek_vl_hybrid, glm4_moe
Fix tied weight for Bart (for BC)
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. Bart used to check which weight was present instead of simply using the default one, as some main checkpoint have the wrong one saved. See [here](https://github.com/huggingface/transformers/pull/41580/files#diff-5b256a6fcfe7956b744dc1e902f150a79e2692b822a6dbac2c6612f8690846b6L917-L928) before we refactored the tied weight

cc @vasqu as you noticed the issue first!

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

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: bart, bigbird_pegasus
Protect `torch.distributed` imports
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. We need to protect them correctly in `core_model_loading.py` for older torch versions


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42361). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix unhelpful error message for Voxtral tokenizer
Author: engmohamedsalah
Pull request: yes

## Summary

Fixes #41553

When loading certain LLaMA-style tokenizers (like Voxtral) without the required external package (`mistral-common`) or without a `tokenizer.model` file present, the tokenizer attempts to call:

```python
sentencepiece.Load(None)
```

This results in an unhelpful error:

```
TypeError: not a string
```

This PR adds a defensive check in `LlamaTokenizer.get_spm_processor()`: if `vocab_file` is None or invalid, a clear and actionable `ValueError` is raised instead.

## Changes

**Modified files:**
- `src/transformers/models/llama/tokenization_llama.py`: Added validation check before `tokenizer.Load()`
- `tests/models/llama/test_tokenization_llama.py`: Added test for the new error handling

## Behavior Before
- LlamaTokenizer calls `sentencepiece.Load(None)`
- User sees only: `TypeError: not a string`
- No guidance on how to fix the issue

## Behavior After
- If `vocab_file` is None or invalid, raises a clear `ValueError`:
```
ValueError: Cannot load the tokenizer: vocab_file is 'None'. This model appears to require special tokenization support. Please install the required package with: pip install mistral-common
```

## Why This Helps
Many model repositories depend on external packages or separate tokenizer assets. This improvement makes debugging straightforward and helps users understand exactly what they need to install.

## Testing
- Added `test_missing_vocab_file_error_message()` to verify proper error handling
- Test confirms that a helpful `ValueError` is raised with actionable guidance when `vocab_file=None`
- Manually tested the fix with the scenario described in the issue

## Checklist
- [x] Fix addresses the issue described in #41553
- [x] Added test for the new error handling
- [x] Test passes locally
- [x] Code follows repository style guidelines

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: llama

Isn't that issue fixed/closed already?

@Rocketknight1 
You are correct. we can close this PR
benchmarker_V2: sdpa_backend handling and level 2 config issue
Author: Abdennacer-Badaoui
Pull request: no
Labels: name: bug

### System Info

Hi @McPatate, @remi-or,

I noticed a few things in `BenchmarkConfig`:

1. In `check_validity`, for `continuous_batching` you check `sdpa_backend is not None` and then set it to `"math"`, but earlier it’s already set to `"flash_attention"` if None. The warning says it should be None, but it’s set to `"math"`.

2. Level 3/4 in `get_config_by_level` generates all configs but ignores `"paged|sdpa"`, which will be included in level 2.

Thanks!


Comments:
I opened a PR that contains the fixings 

https://github.com/huggingface/transformers/pull/42339

Bugs Fixed

  Bug 1 - sdpa_backend inconsistency (line 105):
  - The warning message says "must be None" but code was setting it to "math"
  - Fixed by changing to None to match the warning
  - This allows PyTorch to auto-select the appropriate backend

  Bug 2 - Invalid attn_implementation (line 243):
  - Using "paged|sdpa" directly bypassed validation logic
  - Fixed by changing to "sdpa"
  - The "paged|" prefix is automatically added by init_continuous_batching()

Thank you for this @engmohamedsalah !
fix tekken pattern matching
Author: ArthurZucker
Pull request: yes
Labels: name: for patch

# What does this PR do?
Gotta add a test!

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

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto
Make benchmarking lighter: clean-up result files and remove non-needed arguments
Author: remi-or
Pull request: yes

This PR simplifies the benchmarking suite by:
- removing the timestamps for each token generation from the result file: we now only keep the time to first token and the (mean) inter-token latency
- removes the SDPA backend argument which is both un-used in practice and introduces a lot of edge cases
- starts the refactoring of `time_generate_batch` and fixes some logic in it (it was not recording the right throughput / results)
- adds a bit more context to loading bars and removes some messages

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42357). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Support .to(device) or Device Aware Handling for Segmentation Labels in EOMTImageProcessor #42205
Author: Chenhao-Guan
Pull request: yes

What does this PR do?
Fixes a RuntimeError: Expected all tensors to be on the same device... when training EomtForUniversalSegmentation.

The EomtImageProcessor returns labels (mask_labels, class_labels) as a list[torch.Tensor] because the number of masks per image varies. The standard BatchFeature.to(device) call in a training loop does not move tensors inside these lists, leaving them on the CPU.

This PR adds a robust check at the beginning of the EomtForUniversalSegmentation.forward() method. It automatically moves any provided mask_labels or class_labels to the same device as the pixel_values, ensuring all inputs are on the correct device before loss computation.

This fixes the device mismatch bug internally without requiring any changes from the user.

Fixes #42205

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. (Fixes #42205)

[x] Did you make sure to update the documentation with your changes? (N/A - Bugfix)

[x] Did you write any new necessary tests? (Verified with issue's code)

Who can review?
@NielsRogge @molbap @merveenoyan

Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: eomt, mask2former, maskformer, oneformer

additional mask2former, maskformer, oneformer added,following the suggestion of @NielsRogge. However,mask2former, maskformer, oneformer were not tested on the actual model.

Thanks a lot! Will assign @yonigozlan for review

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42228). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add image processor fast vitpose
Author: yonigozlan
Pull request: yes

# What does this PR do?

Depends on https://github.com/huggingface/transformers/pull/42020

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

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, vitpose
Fix documentation reference to pytorch max memory allocated
Author: JuanFKurucz
Pull request: yes

# What does this PR do?

The old link is returning 404, new one loads https://docs.pytorch.org/docs/stable/generated/torch.cuda.memory.max_memory_allocated.html even tho they changed the path to `torch.cuda.memory.max_memory_allocated` importing from `torch.cuda.max_memory_allocated` still works and does not show any deprecation warning.

## 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.

<!-- 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
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->

Documentation: @stevhliu

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

# What does this PR do?

Fixes the reference to the dataset `yelp_review_full` that seems to have changed from no org to `Yelp`

## 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.

<!-- 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
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->

Documentation: @stevhliu

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42349). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix reference to imagenet 1k dataset
Author: JuanFKurucz
Pull request: yes

# What does this PR do?

Fixes the reference to the dataset `imagenet-1k` that seems to have changed from no org to `ILSVRC`

## 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.

<!-- 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
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->

Documentation: @stevhliu

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42348). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Remove test inheritance for EfficientLoftr, rename KeypointMatchingOutput to model specific name
Author: yonigozlan
Pull request: yes

# What does this PR do?

Remove inheritance in efficient loftr tests (following https://github.com/huggingface/transformers/pull/42327). Also fix source of the issue, KeypointMatchingOutput is different for each keypoint matching model, so rename it to model-specific names.

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

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: efficientloftr, lightglue, superglue
Tiny doc fix
Author: molbap
Pull request: yes

# What does this PR do?

Checked out the contributing guide, found 2 dead links

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

it's that it does not work from https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md is all and it tends to be my first entrypoint :laughing: and most other links there do work,  haven't checked all though

Ah I see, though it will stop working from docs after this PR because it has to be without the `.md` suffix for it 🥲  Not sure what's the correct way to make it work in both places


https://moon-ci-docs.huggingface.co/docs/transformers/pr_42296/en/contributing#do-you-want-to-implement-a-new-model 

no idea either, cc @stevhliu here please :pray: 

Hmm, I think we can either:

- remove the symlink between the `CONTRIBUTING.md` on the repo and the docs
- modify the doc-builder to accept the `.md` extension (this is probably the best since it requires less maintenance)

wdyt?

Yes why not go for the doc-builder change!
Replace Optional and Union typing with | in some source files
Author: cyyever
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

This PR uses Python 3.10 `|` for Union and Optional types.

Comments:
@Rocketknight1 It's green now.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42294). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Bump hfh prerelease v1.0.0.rc7
Author: Wauplin
Pull request: yes

Might be the last pre-release to test? :tada:

I don't expect anything to break but better safe than sorry :hugs: 

(cc @hanouticelina)

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