noamaanMulla-03/transformers-issues huggingface dataset:
regression from tokenizers v5 to fix fast reference for pipeline
Author: itazap
Pull request: yes

ends with "Fast" == `tokenizers` backend !

fixes https://github.com/huggingface/transformers/issues/42540

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42628). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Remove slow tokenizer break pipeline loading.
Author: jiqing-feng
Pull request: no
Labels: name: bug

### System Info

latest main branch transformers

### Who can help?

@itazap 

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

pipeline("document-question-answering", model="impira/layoutlm-document-qa")
```

output:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jiqing/transformers/src/transformers/pipelines/__init__.py", line 1085, in pipeline
    return pipeline_class(model=model, task=task, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jiqing/transformers/src/transformers/pipelines/document_question_answering.py", line 150, in __init__
    raise ValueError(
ValueError: `DocumentQuestionAnsweringPipeline` requires a fast tokenizer, but a slow tokenizer (`RobertaTokenizer`) is provided.
```

### Expected behavior

Regression PR https://github.com/huggingface/transformers/pull/40936

cc @zucchini-nlp 

Comments:
cc @itazap for tokenizers :)
test ci training for text model only
Author: 3outeille
Pull request: yes

- Only 1 failing test (flagging https://github.com/huggingface/transformers/issues/42629) . The test will be skipped for now

<img width="1160" height="893" alt="image" src="https://github.com/user-attachments/assets/b1d50b10-28ac-4f0e-b825-b749cff14fb0" />
<img width="1338" height="544" alt="image" src="https://github.com/user-attachments/assets/b522402f-ccf6-4be7-8248-4c085867a0a3" />
<img width="2134" height="1754" alt="image" src="https://github.com/user-attachments/assets/c97fda1d-bcd8-434d-874f-38aeb1dbd60e" />



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

run-slow: recurrent_gemma

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

models: ["models/recurrent_gemma"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19935720812)

✅ No failing test specific to this PR 🎉 !


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

run-slow: blt, recurrent_gemma
Ultra security for `pr-repo-consistency-bot.yml`
Author: ydshieh
Pull request: yes

# What does this PR do?

A follow-up work of #42646

No more `high` CodeQL report 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42652). 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: beit

Repo. Consistency fix runs successfully without any file modified.
Fix a typo in GGML integration of Qwen2 MoE
Author: a4lg
Pull request: yes

# What does this PR do?

It fixes a typo in the GGML integration code to enable reading Qwen2 MoE config from a GGUF file correctly.

It is intended to be backported to v4.

Related (Qwen3 MoE): #39976

<!--
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.
-->

## 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?

## 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.

@SunMarc @MekkCyber @CyrilVallez

<!-- 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 @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42650). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix saving multiple tokenizers for custom processors
Author: yonigozlan
Pull request: yes

Fixes this issue https://github.com/huggingface/transformers/issues/41816
Instead of harcoding a set of tokenizer attribute that shouldn't be saved as part of `preprocessor_config`, this remove all attributes that contain "tokenizer" from `preprocessor_config`, which allows for more flexibility when creating a custom processor with multiple tokenizers.

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

> Nice! BTW, is this is only for tokenizers and supporting several image_processors/etc is not yet fully implemented?

Yes this is just for tokenizers! I'm working on another PR for image_processors and others, but I think it's best to isolate the two PRs as it might cause some issues
[kernels] fix typing for Kernel mapping
Author: MekkCyber
Pull request: yes

# What does this PR do?

Fix the type of the kernel mapping

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42623). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix interactions between require_read_token and staticmethod
Author: Rocketknight1
Pull request: yes

As @Sai-Suraj-27 pointed out in #42476, there's something weird going on with static methods in some tests. The cause seems to be `require_read_token` having a faulty check for `staticmethod` which obliterates args in some cases. Trying this to see if it helps!

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

Explanation for reviewers because this one is quite tricky:

The `require_read_token` decorator decorates a test or function. However, in some cases, the function is a method with a `staticmethod` decorator. The problem arises when we apply `@require_read_token` **after** `@staticmethod`. In this case, the decorator returns a non-static function, and so we get lots of argument confusion because a `self` argument is inserted where we don't want it.

The old code fixed this with the hack `if "staticmethod" in inspect.getsource(test_case).strip():`, but this breaks when the test case contains that string **anywhere**. The new decorator code correctly checks whether the method we're grabbing is static, and if so, returns a similarly-static output.

cc @ydshieh since this mostly affects tests!

Thank you. I added such so hacky due to my limited knowledge of python, sorry.

With this PR, it seems works with or without running with the ` HF_HUB_READ_TOKEN`, so ✅ .

You are so good in python 

and thanks @Sai-Suraj-27 for identifying this, you are so good at this!

I had to do some reading on this one, the interactions between staticmethods and wrappers were confusing for me as well at first :sweat_smile:
enable sdpa enable gqa logic for Ascend NPU
Author: FightingZhen
Pull request: yes

# What does this PR do?

As discussion [(link)](https://github.com/huggingface/transformers/pull/41143#issuecomment-3346569299) in #41143 , we set `enable_gqa=False` by force when running on Ascend NPU. 

After that, we made a series of experiments to make sure `torch.nn.functional.scaled_dot_product_attention` api work fine on Ascend NPU when setting `enable_gqa` to `True` or `False`, so this limitation can be removed now :)

Note: Experiments based on `torch==2.5.1` and `torch_npu==2.5.1`

Fixes # (issue)
Not related.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#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:
@vasqu ready for review, some failed CI maybe not related with my modification, cc @frozenleaves 

Also, dont worry about the CI, it's unrelated to your PR

Will merge after rerunning CI to pass flaky tests, thx a lot 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_41601). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[bugfix] fix flash-attention2 unavailable error for Ascend NPU
Author: FightingZhen
Pull request: yes
Labels: name: for patch

# What does this PR do?

#40002 cause Flash-Attention2 unavailable on Ascend NPU, **the core reason is package `flash-attn` unavailable on Ascend NPU, even can not be installed**, current implementation will cause **ImportError** on Ascend NPU.

This PR is committed for fixing this problem, remove redundant `apply_rotary_emb` function usage at the same time.

Fixes # (issue)
Not related.

## 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.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


Comments:
PR is ready for review @ArthurZucker @SunMarc @Rocketknight1 @ivarflakstad , cc @Byter-s @vasqu

> Some initial comments, I'm not sure if we can hugely simplify this. That depends on if the _pad/_unpad functions really are not working as expected

@vasqu Thank you for your suggestions, I have tests `pad_input` and `unpad_input` funcs from your implementation, which is OK for Ascend NPU in terms of accuracy and performance, I will follow using your funcs. But the logical branch still can not be merged, detail reason can be found on above comments. Please help me have a check again, thanks :)

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

run-slow: qwen2_5_omni
Some optimizations for offloading
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. This will make the CI much faster.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42665). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[docs] Attention backends + continuous batching
Author: stevhliu
Pull request: yes

Refactors the optimization docs, starting with the attention backend and continuous batching docs (more updates to come in subsequent PRs!).

- reorg the `toctree` to create a clearer inference optimization section for inference (adds the `AttentionInterface`, continuous batching, and kernels guides)
- rename the "LLMs" section into a more generic "Generate API" section especially since we have VLMs now
- add `ContinuousMixin` and `ContinuousBatchingManager` to the API reference
- polish the Attention Interface doc (table describing the available backends, using kernels, etc.) - maybe you can review this section @Cyrilvallez 🙏
- polish the Continuous batching doc (break up the `ContinuousBatchingManager` example to better show the different options for using it, adds clearer PagedAttention and sliding window attention sections, high-level description of how the mixin, manager, and scheduler work together, move the monitoring section to the `transformers serve` docs) - maybe you can review this section @McPatate 🙏

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42329). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Lasr model
Author: eustlb
Pull request: yes
Labels: name: New model

name: Audio


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

Always assume it already exists

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

run-slow: auto, dac, fastspeech2_conformer, lasr, parakeet
inaccurate eval loss computation
Author: wwt17
Pull request: no

https://github.com/huggingface/transformers/blob/1f0b490a2c42eb129dccc69031ccb537058689c4/examples/pytorch/language-modeling/run_clm_no_trainer.py#L657 The last batch may be smaller, since `drop_last` default to `False` for `DataLoader` construction. Thus,  computing the mean over the losses is inaccurate.
Same issue for the train loss:
https://github.com/huggingface/transformers/blob/1f0b490a2c42eb129dccc69031ccb537058689c4/examples/pytorch/language-modeling/run_clm_no_trainer.py#L673

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.
DINOv3ViTLayer_FP16 error
Author: AnnaTrainingG
Pull request: no
Labels: name: bug

### System Info

When using the DINOv3ViTLayer in fp16 mode, the training process gets killed and throws an error.
`
exitcode : -8 (pid: 2536) 1967
error_file: <N/A> 1968
traceback : Signal 8 (SIGFPE) received by PID xxxx`


Comments:
@AnnaTrainingG Hi! I'd like to work on this issue. Could you please assign it to me?

I'm planning to investigate:
- Testing with fp32 instead of fp16 to isolate the precision issue
- Adding gradient clipping to prevent overflow
- Checking for NaN/Inf in the training loop



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.
Avoid CUDA stream sync
Author: cyyever
Pull request: yes

# What does this PR do?

Remove more synchronizing CUDA operations reported.

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

run-slow: qwen2_5_omni, qwen2_5_vl

Cool idea! How are you searching for CUDA sync points in the code?

@Rocketknight1 I use `torch.cuda.set_sync_debug_mode("warn")`.

Cool method, in that case! Let me know what else you find with it, and when this PR is ready for review.

@Rocketknight1 I have other fixes but it's better to split them into smaller ones. This PR is one of them and is complete, no more to add here. 
PS: the CI failures should be unrelated.

Yup - try leaving it for a bit or rebasing/rerunning, ping me once it's green and I'll merge!

Merging now the CI is green

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_40060). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
support for a new model_type called blueberry
Author: dustinwloring1988
Pull request: yes

This PR adds support for a new `model_type` called **`blueberry`** in the Transformers library. It registers the model type, updates the configuration mapping, and ensures that `AutoConfig` and related utilities correctly recognize and load `blueberry` models. 

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

run-slow: auto

Hi @dustinwloring1988, are there any pretrained models with this architecture?

@Rocketknight1 yes I have 2 small ones a base and a chat finetune.

Can you link them? We generally recommend starting with a [custom model](https://huggingface.co/docs/transformers/main/en/custom_models), and only migrating the models into Transformers itself after they have a lot of users, because the team at Hugging Face takes responsibility for maintaining them once they're in the main library!
Add DeepSeek V3.2 model support with Lightning Indexer sparse attention
Author: shuyingl
Pull request: yes

## Summary

This PR adds support for **DeepSeek-V3.2-Exp**, which extends DeepSeek V3 with DeepSeek Sparse Attention (DSA) powered by a Lightning Indexer.

### Key Features

- **Lightning Indexer**: Enables O(L*k) sparse attention complexity (vs O(L²) dense), where k=2048 tokens are selected per query
- **Hadamard Transform**: Applied to Q/K in the indexer for activation rotation, with pure PyTorch fallback when `fast-hadamard-transform` is not installed
- **Non-interleaved RoPE in Indexer**: Critical difference from MLA which uses interleaved RoPE (as noted in the official repo's bug fix)
- **Training Support**: Full support for training with configurable sparse attention toggle and detachable indexer input for the two-stage training approach described in the technical report

### New Configuration Parameters

| Parameter | Default | Description |
|-----------|---------|-------------|
| `index_n_heads` | 64 | Number of indexer heads |
| `index_head_dim` | 128 | Indexer head dimension |
| `index_topk` | 2048 | Tokens selected for sparse attention |
| `use_sparse_attention` | True | Toggle sparse vs dense attention |
| `detach_indexer_input` | False | For Stage 2 training optimization |

### Training Strategy (from Technical Report)

The implementation supports the two-stage training approach:

1. **Stage 1 (Dense Warm-up)**: Train only the indexer with dense attention to align with main attention distribution
2. **Stage 2 (Sparse Training)**: Train full model with sparse attention, indexer input detached for separate optimization

### Files Changed

- New model directory: `src/transformers/models/deepseek_v32/`
- Updated auto mappings for config, model, and task-specific classes

### References

- Official Repository: https://github.com/deepseek-ai/DeepSeek-V3.2-Exp
- Technical Report: DeepSeek_V3_2.pdf in the repo
- HuggingFace Model: https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp

## Test plan

- [x] Config import test
- [x] Model import test
- [ ] Forward pass test with small config
- [ ] Numerical comparison with reference implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

run-slow: auto

Closing - created against wrong repo. Will create PR on fork instead.
update and add Expectations for mistral3/internvl tests
Author: Abdennacer-Badaoui
Pull request: yes

This PR adds and update ROCm-specific expectations for msitral3/internvl tests and updates several some cuda expectations.

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

run-slow: mistral3

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

models: ["models/mistral3"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19926571750)

✅ No failing test specific to this PR 🎉 !


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

run-slow: internvl, mistral3
[Quantization] Fix FP8 experts replacing
Author: MekkCyber
Pull request: yes

# What does this PR do?

In the 3D case for MoEs, `gate_up_proj` and `down_proj` are not modules, just parameters, so the experts weren't replaced as expected

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

I have verified that this resolves the FP8Linear issue in #42028 .