noamaanMulla-03/transformers-issues huggingface dataset:
Fix: object detection pipeline batching issue #31356
Author: ankitgpt18
Pull request: yes
Labels: name: Code agent slop

What does this PR do?

Hey! I noticed that the 
ObjectDetectionPipeline.py
 had a small bug where it would only return the first result when you passed in a batch of images.

I've updated the 
postprocess
.py method to loop through all the results in the batch, so now it correctly returns a list of predictions for every image you send it.

Fixes #31356

Who can review?
@Rocketknight1 (Pipelines)

Comments:
Will review this tomorrow!

Hi @ankitgpt18, I'm seeing some conflicting discussion at #31356 - can you give me some example code that shows the bug, so I can verify this PR fixes it? It's unclear if the bug is still present.

> Hi @ankitgpt18, I'm seeing some conflicting discussion at #31356 - can you give me some example code that shows the bug, so I can verify this PR fixes it? It's unclear if the bug is still present.

Hi @Rocketknight1! Thanks for reviewing. 

I've attached a reproduction script that demonstrates the bug. 

**Before the fix:** The pipeline would only return results for the first image in the batch.
**After the fix:** The pipeline correctly returns results for all images in the batch.

The issue was in line 162 of [object_detection.py] where it was doing `raw_annotation = raw_annotations[0]` instead of looping through all annotations.

[reproduce_batching_bug.py](https://github.com/user-attachments/files/24604588/reproduce_batching_bug.py)


View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43161&sha=8210d4

The script your code agent wrote is invalid - it can only trigger the bug by passing misshapen inputs directly to the postprocess method. I tested the pipeline myself and it works fine with batched inputs, because when you actually run the pipeline, batched inputs are split and passed individually to `postprocess()`. There is no bug and this PR is a waste of time.
Adding DeepSeek's Engram module
Author: Chenhao-Guan
Pull request: no
Labels: name: Feature request

### Feature request

  DeepSeek introduces **Engram** - a conditional memory module with O(1) N-gram lookup [https://github.com/deepseek-ai/Engram/tree/main](url)


### Motivation


  This seems like a valuable general component that could benefit other models (similar to RoPE integration).

### Your contribution

  **Questions:**
  1. Is transformers interested?
  2. Where should it live?
  3. Any design preferences?

  Happy to contribute if this fits the roadmap!

Comments:
We only accept new models if any model(s) are released alongside it. Afaik, I only see a demo code but no official checkpoints (yet) so we would have to pass on this for now.

It's similar to mHC of Deepseek where the papers are promising but not models released.
[ci] Fixing some failing tests for important models
Author: Abdennacer-Badaoui
Pull request: yes

This PR addresses several failing tests in the CI. 

------
 ###  Fixed tests : 

- tests/models/gpt2/test_modeling_gpt2.py::GPT2ModelLanguageGenerationTest::test_batch_generation
- tests/models/gpt2/test_modeling_gpt2.py::GPT2ModelLanguageGenerationTest::test_batch_generation_2heads 
- tests/models/detr/test_modeling_detr.py::DetrModelIntegrationTests::test_inference_no_head 
- tests/models/llama/test_tokenization_llama.py::LlamaTokenizationTest::test_added_tokens_serialization 
- tests/models/llama/test_tokenization_llama.py:LlamaTokenizationTest:test_chat_template_return_assistant_tokens_mask
- tests/models/llama/test_tokenization_llama.py::LlamaTokenizationTest::test_chat_template_return_assistant_tokens_mask_truncated 
- tests/models/llama/test_tokenization_llama.py::LlamaTokenizationTest::test_padding_side_in_kwargs 
- tests/models/llama/test_tokenization_llama.py::LlamaTokenizationTest::test_truncation_side_in_kwargs 
- tests/models/llava/test_modeling_llava.py::LlavaForConditionalGenerationIntegrationTest::test_tokenizer_integration
- tests/models/qwen2_5_omni/test_modeling_qwen2_5_omni.py::Qwen2_5OmniModelIntegrationTest::test_small_model_integration_test_batch 



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43231). 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: detr, gpt2, llava, qwen2_5_omni

Removed the `@require_read_token` decorator, as a smoother process is coming in https://github.com/huggingface/transformers/pull/43233

run-slow: detr, gpt2, llava

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

models: ["models/detr", "models/gpt2", "models/llava"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !
[`Docs`] Minimax M2 add release date
Author: vasqu
Pull request: yes

New make automatically added the correct line but there was no original release date

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

`Text2TextPipeline` has been deprecated for a while, as well as its sub-pipelines `TranslationPipeline` and `SummarizationPipeline`. It was a big maintenance headache, and users should probably use modern chat models for tasks like translation and summarization. This PR finally deletes it all for `v5`!

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

Tests are passing (one unrelated one failing, I'll make a PR for that). Even though they're no longer SOTA, there is probably still some usage of Summarization/Translation pipelines though, especially the Marian models. Those models will still be usable, but there won't be a clean pipeline for it! We might want to write something about the change in the v5 release notes - I can do that if you're okay with the change cc @lysandrejik @arthurzucker ?

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

run-slow: fsmt, marian

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43256&sha=d5e814
Crash Fix for GLM-Image: TopPLogitsWarper numerical stability on MPS
Author: inferencers
Pull request: yes

# What does this PR do?
Using -inf as a filter value in masked_fill causes NaN on MPS devices.

Changing default filter_value to a large negative float -1e9 instead is a commonly used safe alternative for softmax and numerically stable across all devices (CPU, CUDA, MPS).

Fixes # (issue)
Runtime crash when generating image with GLM-Image on MPS.

## 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?


## 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 @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:
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43286&sha=c986a9
Fix failing `fast_vlm` tests
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?

Fixes these failing [FastVlmForConditionalGenerationIntegrationTest](https://github.com/huggingface/transformers/actions/runs/20706072009/job/59437072515#step:14:4472)

<img width="1396" height="279" alt="image" src="https://github.com/user-attachments/assets/72879321-0225-4d15-a880-890c21bb8caa" />


## 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?
@Rocketknight1 @vasqu

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

run-slow: fast_vlm

run-slow: fast_vlm

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

models: ["models/fast_vlm"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43275). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[CB] Refactor: extract common scheduling logic into Scheduler base class
Author: dstekanov
Pull request: yes

# What does this PR do?

This PR refactors the FIFOScheduler and PrefillFirstScheduler classes to extract common scheduling logic into the base Scheduler class (fixed TODO: further common-ize the two classes)

#### Local verification
Verified basic continuous batching utilities locally on CPU (macOS) by running existing tests:

```bash
pytest -q tests/generation/test_continuous_batching.py -k group_layers
pytest -q tests/generation/test_continuous_batching.py -k attention_mask
```

## Before submitting
- [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? 
- [ ] Did you write any new necessary tests?

## Who can review?

@remi-or @ArthurZucker @McPatate

Comments:
This is great, and the change was long overdue tbh. But we just merged a PR that moved quite a bit of code in the schedulers, so I think you need to rebase + resolve conflicts with care. Sorry for the untimeliness of this all!

> LGTM, thanks for the contribution! If you can make the changes I commented about it would be awesome. Once that's done I will test, approve and merge 🙂

Thanks! I’ve applied the requested changes

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

@bot /style

Style fix is beginning .... [View the workflow run here](https://github.com/huggingface/transformers/actions/runs/21001145284).

It seems the style bot is broken, could you run `make style` please? 

> It seems the style bot is broken, could you run `make style` please?

Just pushed a small style fix, seems I introduced it in my latest commit

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43237&sha=757e42
Fix pipeline tests
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. Fix tests after https://github.com/huggingface/transformers/pull/43195

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

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43293&sha=018144
[Qwen-VL] min/max pixels gone forever
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

As per title, deletes min/max pixels from class attributes, but still allows passing them with kwargs at `__init__` and during `__call__`. 

And fixes https://github.com/huggingface/transformers/pull/43228#issuecomment-3745649304. Caused by us setting `self.min_pixels` to config value and giving it highest priority than `size` in `_further_process_kwargs`, even when `size` is a user-defined argument.


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43279). 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: glm_image, qwen2_vl, video_llama_3
fix subfolder issue
Author: ArthurZucker
Pull request: yes

# What does this PR do?


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

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43300&sha=cc5663
Missing imports for DetrLoss and DetrHungarianMatcher
Author: sammlapp
Pull request: no

Previously, I was able to import these classes as 
```
from transformers.models.detr.modeling_detr import DetrLoss, DetrObjectDetectionOutput, DetrHungarianMatcher
```

In v4.57.3, the import fails and I also cannot find DetrLoss or DetrHungarianMatcher anywhere in the codebase. Have they been removed/replaced with an alternative? What is the up-to-date import?

Thank you for assistance / information

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.

Re opening
Simplify `_get_resolved_checkpoint_files` and do not try safetensors bot conversion with a subfolder
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. Also takes the opportunity to refactor `_get_resolved_checkpoint_files` a bit, as it's currently a big mess
Also, `use_safetensors` should be set to None in `from_pretrained`, so that we check `.bin` files automatically if there are no `safetensors` file. Otherwise, it requires passing an explicit `use_safetensors=False` from the user which is weird - also related to [this issue](https://github.com/huggingface/transformers/pull/43178#discussion_r2691060130)

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

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43301&sha=00a83b
Ensure training forward respects autocast precision
Author: karthik-0306
Pull request: yes
Labels: name: Code agent slop

This PR ensures that the model forward pass during training runs under the same
autocast precision as evaluation.

Previously, the forward pass in `compute_loss` was executed outside the autocast
context, which could lead to inconsistent dtypes between training and evaluation
when using mixed precision (e.g. bf16).

The fix wraps the forward call in `compute_loss` with the existing autocast context
manager, preserving expected behavior without affecting default fp32 training.

A regression test is included and conditionally skipped when bf16-capable hardware
is not available.


Comments:
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43302&sha=785d07
Fix MusicGen generation config
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Some audio models have their own `generate()` which doesn't call `prepare_generation_config`. We need to call `prepare_generation_config` to update values to prev defaults

Also, I added a small deprecation warning preparing us and users to passing either generation config of `kwargs`, only one. We will anyway have to support it for a long time, it is a common pattern among users

Comments:
run-slow: musicgen_melody

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

models: ["models/musicgen_melody"]
quantizations: []

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

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

✅ No failing test specific to this PR 🎉 !


CI is going crazy with the flakiness :cry: 

CI is sooo flaky

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

run-slow: musicgen_melody, whisper
Fix eager experts for DeepSeekV2
Author: Rocketknight1
Pull request: yes

The eager expert computation for DeepSeekV2 inherited from Qwen2MoE, but they pass expert weights differently. Qwen2MoE selects experts before `forward()`, it passes `top_k_weights` with shape  `(num_tokens, num_top_k)`. DeepSeekV2 does not, so `top_k_weights` has shape `(num_tokens, num_experts)`. The result is that DeepSeekV2 selected incorrect experts when `_experts_implementation == "eager"` and the output was garbage.

This PR overrides the `forward()` method for DeepSeek so we select the right experts!

cc @IlyasMoutawwakil, fixes #43224

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

thanks @Rocketknight1 i was surprised as well when writing batched_mm and grouped_mm that top_k_weights can have two possible shapes while the eager path seemed very standardized across MoEs. so i added support for both shapes without touching the eager path (assuming that it works fine somehow 😅).

Yeah, I'm not sure how this ever worked! I wonder how long this bug has existed for

not for long, i see it was introduced in https://github.com/huggingface/transformers/pull/42456 

cc @ydshieh more flaky tests here, I think possibly Hub issues again?

run-slow: deepseek_v2

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

models: ["models/deepseek_v2"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


@IlyasMoutawwakil tests are green! Can you approve it so I can merge?

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

run-slow: deepseek_v2

run-slow: deepseek_v2

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

models: ["models/deepseek_v2"]
quantizations: []

@vasqu confirmed in local testing that your fix also recovers the correct output!

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

✅ No failing test specific to this PR 🎉 !
[doc] glm-asr is an audio model
Author: eustlb
Pull request: yes

# What does this PR do?

Nit on doc


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43309). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Replace regex with re
Author: Rocketknight1
Pull request: yes

As the title says, this replaces `import regex as re` with `import re`. Most of this has already been done, but this cleans out the last of it. It also fixes one case where we were using possessive quantifiers that only work in 3.11, enabling us to remove regex there too.

Aside from general cleanup, the main reason to do this is that `regex` segfaults in Py3.14's free-threading mode, and it'd be nice if we were able to support that!

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43310). 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: bertweet, blenderbot_small, clvp, ctrl, deepseek_vl, deepseek_vl_hybrid, depth_pro, fastspeech2_conformer, got_ocr2, gpt_oss, mllama, pixtral, recurrent_gemma, sam3, sam3_video, switch_transformers

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43310&sha=2cf127