noamaanMulla-03/transformers-issues huggingface dataset:
Fix failing `PhiIntegrationTests`
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
Fixes these failing [PhiIntegrationTests](https://github.com/huggingface/transformers/actions/runs/20706072009/job/59437072132#step:14:2409).

<img width="1333" height="195" alt="image" src="https://github.com/user-attachments/assets/16c2ba7d-539a-4147-b0c0-2d26da311df2" />

## 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?
@vasqu 

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

run-slow: phi, phi3

run-slow: phi, phi3

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

models: ["models/phi", "models/phi3"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


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

# What does this PR do?

This makes the process more smooth: we only need to make sure the bot has access to the gated repositories.

Comments:
run-slow: whisper, llama

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

models: ["models/llama", "models/whisper"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


run-slow: whisper, llama

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

run-slow: apertus, aya_vision, bert, blt, chameleon, cohere2, cohere2_vision, csm, cwm, deepseek_v2, deepseek_v3, diffllama, doge, gemma, gemma2, gemma3

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

models: ["models/llama", "models/whisper"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !
Fix failing `Owlv2ModelIntegrationTest` & `OwlViTModelIntegrationTest`
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?

Fixes failing [Owlv2ModelIntegrationTest](https://github.com/huggingface/transformers/actions/runs/20706072009/job/59437072091#step:14:4172) & [OwlViTModelIntegrationTest](https://github.com/huggingface/transformers/actions/runs/20706072009/job/59437072113#step:14:4015)

<img width="1351" height="165" alt="image" src="https://github.com/user-attachments/assets/c7ee7f9b-1259-4523-8424-213c7596bd4b" />




## 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?
@vasqu

Comments:
run-slow: owlv2, owlvit

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

models: ["models/owlv2", "models/owlvit"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


> LGTM, base owlvit might need bigger tols again? Seeing it failing with slightly higher diffs there

Yes, Updated the PR. Thanks for the review!

run-slow: owlvit

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

models: ["models/owlvit"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


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

run-slow: owlv2, owlvit

run-slow: owlv2, owlvit

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

models: ["models/owlv2", "models/owlvit"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !


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

# What does this PR do?

This PR fixes an issue with `config` and `quantization_config`. Since we don't propagate the `quantization_config` into subconfig, we don't cast the tensors to the correct dtype when using flash attn. However, I prefer not to propagate this information for now. Instead, we just set _is_quantized flag. In the past, we were using `_pre_quantization_dtype`. 

Fixes https://github.com/huggingface/transformers/pull/43001

Regression caused by https://github.com/huggingface/transformers/pull/42882/files

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43145). 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=43145&sha=3cc7ed

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

run-slow: diffllama, falcon, falcon_mamba, gpt_neo, gptj, kyutai_speech_to_text, mimi, moshi, nemotron
Fix Qwen2VLVideoProcessor ignoring runtime min_pixels/max_pixels kwargs
Author: Anri-Lombard
Pull request: yes

## Summary
- Add `_further_process_kwargs` method to `Qwen2VLVideoProcessor` to handle runtime `min_pixels`/`max_pixels` kwargs
- Add test to verify runtime kwargs work correctly

## What does this PR do?

Fixes #43183

The video processor was missing the `_further_process_kwargs` method that the image processor has (see `image_processing_qwen2_vl_fast.py:87-108`). This caused `videos_kwargs{min_pixels, max_pixels}` to be silently ignored when passed at call time, resulting in ~15x more visual tokens than expected.

## Test plan
- [x] Added `test_video_processor_runtime_min_max_pixels` test
- [x] All existing video processor tests pass

Comments:
Hi @Anri-Lombard thanks for this PR! Can you confirm that running your test without the fix failed in the same way described in the original issue? I am sure the test passes with your fix, I just want to make sure we know we're replicating the original problem. 

Hi @brandonpelfrey, thanks for pointing that out 🙏

Yes, I confirmed the test replicates the original problem.

**Without the fix** (with `_further_process_kwargs` removed):
- The test fails with: `AssertionError: 256 not less than 256`
- Both default and constrained calls produce identical `video_grid_thw` values
- The runtime `min_pixels`/`max_pixels` kwargs are silently ignored

**With the fix:**
- The test passes
- Default processing with `max_pixels=224*224` produces 256 patches
- Constrained processing with `max_pixels=56*56` produces fewer patches as expected

I've also strengthened the test to verify that the grid size actually changes when custom pixel constraints are passed, rather than just checking for key existence.

Thanks @Anri-Lombard . Unfortunately, I'm not a maintainer 😃 but this looks like it will resolve the originally reported problem. 

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

run-slow: qwen2_vl, video_llama_3

I think this is a duplicate of #43228!

I guess since this one was first that would be the duplicate 😅

lol, fair point, your one was first! That one is more advanced in the review process now though
Fix ObjectDetectionPipeline batch processing bug
Author: ayushm98
Pull request: yes

# What does this PR do?

Fixes #31356 

This PR fixes a bug in the `ObjectDetectionPipeline` where only the first image was processed when using the `batch_size` parameter.

## Problem

When using `batch_size > 1`, the pipeline would batch multiple images together in the forward pass, but the `postprocess` method only processed the first element (`raw_annotations[0]`) instead of iterating through all annotations.

## Solution

Modified the `postprocess` method in `object_detection.py` to:
1. Loop through all `raw_annotations` returned by `post_process_object_detection`
2. Process each annotation individually  
3. Handle both single image and batch cases correctly (returns single list for one image, list of lists for multiple)

## Testing

- Added regression test `test_batch_size_parameter` that verifies all images are processed when using `batch_size` parameter
- Existing tests continue to pass (single image and multi-image without batch_size)

## Who can review?

cc @yonigozlan 

Comments:
Hi @yonigozlan! Thanks for taking a look.

The issue is specifically in the `postprocess` method of `ObjectDetectionPipeline`. While you're correct that the Pipeline base class handles batching, the problem occurs when `post_process_object_detection` returns results for multiple images (when batch_size > 1), but the current code only processes the first result with `raw_annotation = raw_annotations[0]`.

Here's a code sample to reproduce:

```python
from transformers import AutoModelForObjectDetection, AutoImageProcessor, ObjectDetectionPipeline

model_id = "hf-internal-testing/tiny-detr-mobilenetsv3"
model = AutoModelForObjectDetection.from_pretrained(model_id)
image_processor = AutoImageProcessor.from_pretrained(model_id)
object_detector = ObjectDetectionPipeline(model=model, image_processor=image_processor)

# Test with 4 images and batch_size=2
images = [
    "http://images.cocodataset.org/val2017/000000039769.jpg",
] * 4

outputs = object_detector(images, threshold=0.0, batch_size=2)
print(f"Number of outputs: {len(outputs)}")  # Should be 4, but may not handle all correctly
```

The fix ensures that when `post_process_object_detection` returns multiple results (one per image in the batch), we iterate through all of them instead of just taking the first one. The test case in the PR (test_batch_size_parameter) validates this behavior.

Let me know if you need any clarification!

I get the expected value (4) with the given code to reproduce the issue. Looks like this might be an LLM PR, closing for now
Fix `test_reverse_loading_mapping` common test
Author: yonigozlan
Pull request: yes

The test currently search for the target pattern in the keys of the tied_weights dict, but target pattern can break regex search (if they contain a group search/replace like `\1`, so this fix searches for the source pattern in the values of the tied_weights dict,

Needed for https://github.com/huggingface/transformers/pull/41549

Cc @Cyrilvallez 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43239). 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=43239&sha=7d30ab
Remove unused imports
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.
-->

<!-- Remove if not applicable -->
This PR removes unused imports.

Comments:
cc @Rocketknight1 

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

run-slow: conditional_detr, dbrx, deformable_detr, detr, edgetam, edgetam_video, grounding_dino, janus, jetmoe, pop2piano, timesformer, yolos

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43078). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
docs: fix grammatical error in README.md
Author: davidfertube
Pull request: yes

## Description

This PR fixes a minor grammatical error in the README.md file.

## Changes

- Fixed possessive form: `models lifetime` → `model's lifetime`

## Location

The error was in the 'Why should I use Transformers?' section, under point #3:
- **Before**: 'Choose the right framework for every part of a models lifetime'
- **After**: 'Choose the right framework for every part of a model's lifetime'

## Motivation

Grammatical correctness improves documentation quality and readability.

## Testing

No code changes - documentation only. Verified the fix is grammatically correct.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43236). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix typo: seperately → separately in lw_detr converter
Author: skyvanguard
Pull request: yes

## What does this PR do?

Fixes a typo in the LW-DETR model conversion script.

**Change:** `seperately` → `separately` in a comment

**File:** `src/transformers/models/lw_detr/convert_lw_detr_to_hf.py` (line 158)

## Before submitting

- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

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

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

run-slow: lw_detr

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43235). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix unsafe torch.load() in _load_rng_state allowing arbitrary code execution
Author: ColeMurray
Pull request: yes

Add weights_only=True to torch.load() call in Trainer._load_rng_state() to prevent arbitrary code execution when loading malicious checkpoint files.

The existing safe_globals() context manager provides no protection for PyTorch < 2.6 as it returns contextlib.nullcontext(). This makes the torch.load() call at line 3059 vulnerable to pickle deserialization attacks, unlike all other torch.load() calls in the same file which correctly use weights_only=True.

Impact: Users loading untrusted checkpoints on PyTorch 2.2-2.5 are vulnerable to arbitrary code execution via malicious rng_state.pth files.


Comments:
Sorry about the CI @ColeMurray, it is unrelated to your PR working on fixing it

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43140&sha=5bf9b6

Thx for sticking through, merging now!

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

Just wanted to check the history, seems like #37162 reintroduced removing that kwarg but we shouldn't allow it - i.e. `check_torch_load_is_safe()` was missing to throw an error in those cases

Can we safely do this instead, we really shouldn't allow torch<2.6 here cc @SunMarc @winglian  

Perfect, merging then thx for checking in
Deprecate dtype per sub config
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/42968, https://github.com/huggingface/transformers/issues/42641

As discussed, this PR deprecated different dtypes per backbone and falls back to the main dtype if a user is requesting different dtypes. 

There is no clean way to support different dtypes when the backbone can have a task head. We either cast hidden states to task dtype in all model files, or we need a workaround to infer task head and force dtype on it when loading. So the better solution is to deprecate dict dtypes, apparently it is not used much

Comments:
run-slow: llava, llava_next, llava_next_video, llava_onevision

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

models: ["models/llava", "models/llava_next", "models/llava_next_video", "models/llava_onevision"]
quantizations: []

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

✅ No failing test specific to this PR 🎉 !
[GLM-Image] AR Model Support for GLM-Image
Author: zRzRzRzRzRzRzR
Pull request: yes
Labels: name: New model

This PR is to adapt the implementation of the AR model for GLM-Image. For Full Pipeline, check [diffusers](https://github.com/huggingface/diffusers/pull/12921) repos


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

@zucchini-nlp is there a `tiny` variant available for this model? 👀 

Nope, I didn't create any tiny model, feel free to create one for testing

In transformers, we use those only in pipeline tests and this model doesn't fir any existing pipe

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

run-slow: auto, glm4_moe_lite, glm4v, glm4v_moe, glm_image

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43100&sha=d4350b
[cleanup] Remove AutoModelForVision2Seq + attention mask device
Author: Wauplin
Pull request: yes

- Removed `device` argument from `get_extended_attention_mask`. Device is inferred from `attention_mask`.
- `AutoModelForVision2Seq` is removed in favor of `AutoModelForImageTextToText`

Both were marked as deprecated and removed in v5. I've noticed them while working on some Hub cleanup. Feel free to ignore if not relevant or taken care of elsewhere.

---

Note: I've noticed a few other places with deprecated args. I'll take care of them in separate PR to avoid too many changes per PR.

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

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=42427&sha=a35749

Superseded by https://github.com/huggingface/transformers/pull/43195!
[CB] Soft-reset offloading
Author: remi-or
Pull request: yes

# Summary
This PR adds a basic form of offloading to the continuous batching API. Currently, when we cannot schedule any request because the KV cache is full, we throw an error, which is less than optimal. This PR fixes this by adding a mechanism where instead of throwing an error, we de-schedule the oldest request by adding it back to the list of waiting request, but keeping the generated tokens by adding them to the initial prompt. Then, no new request can be scheduled until one is completed, which helps avoid infinite loops on scheduled-offloaded requests.

## Performance 

| Arguments                                          | Throughput on main | Throughput with PR | Delta   |
|----------------------------------------------------|--------------------|--------------------|---------|
| --samples 10                                       | 532.98             | 530.45             | -2.53   |
| --samples 20 --num-blocks 16                       | ERROR              | 100.14             | N/A     |
| --samples 50                                       | 1478.16            | 1477.42            | -0.74   |
| --samples 100                                      | 2254.38            | 2266.81            | +12.43  |
| --samples 100 --attn flash_attention_2             | 2062.56            | 2076.81            | +14.25  |
| --samples 100 --attn sdpa                          | 866.01             | 840.72             | -25.29  |
| --samples 500                                      | 5299.24            | 5281.98            | -17.26  |
| --samples 500 --add-prefix --compile               | 6774.53            | 6743.21            | -31.32  |
| --samples 50 --num-return-sequences 8 --do-sample  | 5319.79            | 5362.52            | +42.73  |
| --samples 100 --num-return-sequences 4 --do-sample | 4680.87            | 4674.91            | -5.96   |

Throughput are in tok/s. The script run is `examples/pytorch/continuous_batching.py`

## Tests
Tests pass, including the tests added for this PR.

## Sanity check
Looks good.


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

We enable this per default because the alternative is crashing. When we add proper `OffloadPolicy` and the parameters around that, I will add a `NoOffload` policy which crashes, for the folks who like that.

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43150&sha=1e48c7
Fix benchmark script
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

Fix after https://github.com/huggingface/transformers/pull/43153.
F821 Undefined name `device_type` which crashes `make style` etc

cc @remi-or for viz!

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