noamaanMulla-03/transformers-issues huggingface dataset:
Illegal memory access when using 3d rope
Author: BakerBunker
Pull request: no
Labels: name: bug

### System Info

Latest transformers `main` branch

### Who can help?

@zucchini-nlp 

### Information

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

Using models using 3d rope like Qwen2.5-VL or Qwen2.5-Omni, and inference with flash attention 2.
https://github.com/huggingface/transformers/blob/e8e0c76162263840661fc0ca0da3952861754759/src/transformers/modeling_flash_attention_utils.py#L511-L525

Here the code `(torch.diff(position_ids, dim=-1) >= 0).all()` will return `False` when using 3d rope, since the h and w dim are not monotonic.

### Expected behavior

Change `(torch.diff(position_ids, dim=-1) >= 0).all()` to `(torch.diff(position_ids[0] if position_ids.dim() ==3 else position_ids, dim=-1) >= 0).all()`

or add
```python
if position_ids is not None and position_ids.dim() == 3:
        position_ids = position_ids[0]
```
before `is_fa2_with_position_ids`, since `position_ids` is also used here:
https://github.com/huggingface/transformers/blob/e8e0c76162263840661fc0ca0da3952861754759/src/transformers/modeling_flash_attention_utils.py#L550-L560



Comments:
@BakerBunker I remember testing the models with FA2 using the internal test cases, and didn't encounter issues. In case of Qwen-VL models we expect that the `cu_seqlens` are already provided (attention layer passes them to FA2), so it should not be trying to prepare infer them from `position_ids`

Can you share a reproducer?

I am implementing a MoE version of qwen omni model, when inherit the `Qwen3MoEAttention`  as the thinker text model backbone, since here

https://github.com/huggingface/transformers/blob/8178c43112295bf8c4ef04c667efbbbfd34b8bca/src/transformers/models/qwen3_moe/modeling_qwen3_moe.py#L154-L196

the `forward` function doesn't take `position_ids` as a parameter, so the `position_ids` will pass into `attention_interface` in `kwargs`, and will enconter the bug mentioned above.

Ah I see, I think in that case we need to overwrite the modular class and remove `position_ids` before calling the FA2. We will be sure that `position_ids` are 3d and that FA2 has all the information from `cu_seqlens`, thus popping the positions before should be fine

Thank you!
fix flaky `test_generate_compile_model_forward`
Author: ydshieh
Pull request: yes

# What does this PR do?

Found it flaky today in https://app.circleci.com/jobs/github/huggingface/transformers/1816845

(7 failed in a run of 5000 times)

After this PR, all 5000 runs pass

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39276). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add torchcodec in docstrings/tests for `datasets` 4.0
Author: lhoestq
Pull request: yes

continuation of https://github.com/huggingface/transformers/pull/39060 (so this PR also contains the object detection fix so we can run the CI with `datasets` on `main`)

it also adds support for torchcodec.decoders.AudioDecoder as input to audio classification and asr pipelines

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

triggered https://github.com/huggingface/transformers/actions/runs/16009282798

Hi @lhoestq There is slack reporting issues, but I saw many failed tests

> FAILED tests/models/clvp/test_modeling_clvp.py::ClvpModelForConditionalGenerationTest::test_gradient_checkpointing_backward_compatibility - ImportError: To support decoding audio data, please install 'torchcodec'.

I only add 

```
      - name: Install datasets main
        working-directory: /transformers
        run: python3 -m pip install --no-cache-dir git+https://github.com/huggingface/datasets.git@main
```
maybe I should also install something else?

Could you provide a full installation steps 🙏 ? I will rerun the CI again today.

It's best to verify it before merge, as we have several events like switching all jobs to A10, run with torch 2.8 etc. and they already cause quite some chaos.


added the missing torchcodec installations, it should be fine now !

the examples_torch job has

```
        if isinstance(data_args.train_val_split, float) and data_args.train_val_split > 0.0:
            split = dataset["train"].train_test_split(data_args.train_val_split, seed=training_args.seed)
            dataset["train"] = split["train"]
            dataset["validation"] = split["test"]
    
        # Get dataset categories and prepare mappings for label_name <-> label_id
>       categories = dataset["train"].features["objects"]["category"].feature.names
E       TypeError: 'Sequence' object is not subscriptable
```

so maybe from `datasets` ??

Also a tiny change to fix

https://app.circleci.com/pipelines/github/huggingface/transformers/136595/workflows/5580c370-0b69-49f5-a3e9-7c96485eab15/jobs/1810677

is also necessary. (update the 1 src/transformers/models/hubert/modeling_hubert.py or src/transformers/models/hubert/modular_hubert.py)

I fixed the TypeError and the modeling_hubert :)

> can we revert doc changes? snippets for the few I tried are broken anyway, let's change to torchcodec when it is not blocking for windows users

sure !

> why the stereo → mono conversion in the pipeline? AFAIK it is directly handled by the models no?

oh I didn't know that, let me change it :)

I was converting to mono because the {"array": ..., "sampling_rate": ...} input format was already mono so I assumed the models were also mono.

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

run-slow: audio_spectrogram_transformer, clvp, data2vec, hubert, moonshine, qwen2_5_omni, qwen2_audio, sew, sew_d, speech_encoder_decoder, speech_to_text
Add trust_remote_code in LightGlueConfig
Author: sbucaille
Pull request: yes
Labels: name: Vision

# What does this PR do?

Add trust_remote_code parameter to LightGlue config so that LightGlue can be used with other not implemented keypoint detectors than SuperPoint.

With `from_pretrained`, `trust_remote_code` is not provided to the config, so I had to include it into the config itself as an attribute.

Discussed on Slack.

## Who can review?

@qubvel 


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

run-slow: lightglue

we have the following test fails:

```
   1 failed because `AssertionError: {'tru[1887 chars]t', 'trust_remote_code': False, 'output_attent[1572 chars]alse} != {'tru[1887 chars]t', 'output_attentions'` -> False}, 'hidden_size'[1544 chars]alse}
  31 failed because `TypeError` -> transformers.models.superpoint.configuration_superpoint.SuperPointConfig() got multiple values for keyword argument 'trust_remote_code'
Number of failed tests: 32
```

Yep, should be fixed

run-slow: lightglue

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

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

Out of curiosity, I know the 2 failed torchscript tests are not really related to the changes and were introduced after LightGlue's PR, but I can't really figure out where the problem comes from, have you had similar problems on other models ?

That's most probably related to the recent `@can_return_tuple` change in 
 - https://github.com/huggingface/transformers/pull/39120
 
 known issue, we are working on the fix

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39253). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Improve ELECTRA documentation with explanations and helpful links
Author: PrakyathMC
Pull request: yes

## What does this PR do?

Improves the ELECTRA model documentation following the standardized format outlined in #36979.

## Changes Made
- ✅ Added explanatory comments to Pipeline and AutoModel code examples
- ✅ Added "Quick Links" section with popular ELECTRA models on HuggingFace Hub  
- ✅ Included additional resources (paper links, model collection)
- ✅ Improved accessibility for beginners learning to use ELECTRA

## Before and After
**Before**: Basic code examples without explanations
**After**: Commented code that teaches users what each line does + easy access to models

Fixes #36979

Comments:
Hey, ELECTRA has already been updated in #37063. Please check the list before opening any new PRs!
docs(swinv2): Update SwinV2 model card to new standard format
Author: BryanBradfo
Pull request: yes

# What does this PR do?

This PR updates the Swin Transformer V2 model card (`swin_transformer_v2.md`) to align with the new standardized format.

-   Follows the template provided in [Community contributions] Model cards #36979.
-   Includes working Pipeline and AutoModel examples (tested locally).
-   Removed the transformers-cli example (consistent with other recent model card updates).

Relates to #36979

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [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).
- [ ] Did you write any new necessary tests?

## Who can review?

@stevhliu

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

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37942). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[Tests] Update model_id in AIMv2 Tests
Author: yaswanth19
Pull request: yes

As per the title, updates model_id in Aimv2 integration tests with that of official ones as the PRs for HF compatible weights are merged.

Comments:
CC: @ydshieh 


run-slow: aimv2

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

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

Great, thank you a lot!

There is

```
        # handle device
        expected_logits = torch.tensor([[34.2415, 24.6724]]).to(model.device)
>       self.assertTrue(torch.allclose(outputs.logits_per_image, expected_logits, atol=1e-3))
E       AssertionError: False is not true
```

I will check on A10 runner, and if it looks reasonable, I will simply update the expected value and merge.

Thanks :pray: It was updated by Cyril in this [commit](https://github.com/huggingface/transformers/pull/36625/commits/4b2ccdc7d2279a595677270acecc1706a0c864b7).  The previous values were on CPU. Please update the values even if it's close to the previous values

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

run-slow: aimv2
[flash attn 3] bring back flags
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/39288 and brings back `_supports_flash_attn3=True` flags in all models where FA2 is supported

I believe the flag was deleted by accident, but lmk if that was intended

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39294). 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: aimv2, arcee, aria, audio_spectrogram_transformer, aya_vision, bamba, bark, bart, biogpt, bitnet, blenderbot, blenderbot_small, blip_2, chameleon, clip, cohere

Merging, I can't actually run tests but assuming FA2 supports means FA3 is also supported and FA3 was tested in prev PRs, we should be good

Yup, both use the same ish interface so if either is supported it usually means both are 😄
id2label assignment problem in run_glue.py
Author: lyrmagical
Pull request: no

https://github.com/huggingface/transformers/blob/51d732709e5ae424e8fb6c4e58b72057a3e413c2/examples/pytorch/text-classification/run_glue.py#L440 seems not right?
Should It be model.config.id2label = {id: label for label, id in label_to_id.items()}?
Same as https://github.com/huggingface/transformers/blob/51d732709e5ae424e8fb6c4e58b72057a3e413c2/examples/pytorch/text-classification/run_glue.py#L443
Can someone check it? This problem is similar as https://github.com/huggingface/transformers/issues/28589

Comments:
Hi @lyrmagical, do you get an error when running it? What's the effect of this bug?

@Rocketknight1 Sorry, I haven't run it yet, as I'm still in the process of modifying the code based on my task requirements.

That's okay! If you get a chance, you can update this issue with a command that shows the error. We can't really declare it a bug and fix it until we can see the issue it's causing!

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.
Fix some bug for finetune and batch infer For GLM-4.1V
Author: zRzRzRzRzRzRzR
Pull request: yes
Labels: name: for patch


Comments:
Hi @zRzRzRzRzRzRzR, can you be clearer about the bugs you're fixing here? Is there any code that reproduces them?

This PR aims to address two issues
1. The absence of setting disable_grouping=disable_grouping leads to the inability to use fast proceeding, resulting in an error
```TypeError: group_images_by_shape() missing 1 required positional argument: 'disable_grouping'``` cc @ArthurZucker at slack
2. When fine-tuning the model, for batch images, the loop index for images should be placed outside the for loop.

What needs to be discussed is in the video_processing
```
data = {
            "pixel_values_videos": pixel_values_videos,
"video_grid_thw": video_grid_thw,
"timestamps": timestamps_list,
}
return BatchFeature(data=data, tensor_type=return_tensors)
```
"timestamps" does not support batchfeature (each video length is different)
This results in the current model still not supporting batch video inference.

Should go in patch, GLM inference is broken in 4.53.1
fix `aria` tests
Author: ydshieh
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_39277). 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: aria
[modular] Allow method with the same name in case of @property decorator
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. See added examples. Needed for #39301 as well


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39308). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[sliding window] revert and deprecate
Author: zucchini-nlp
Pull request: yes
Labels: name: for patch

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/39290


Comments:
The modular file complains when we have the a property and its setter, I think I saw that once with other models 🤔 

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

Ha indeed since the methods have the same name, one is overwritten by the other in modular linter. Let me see if I can quickly patch it

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

run-slow: cohere2, gemma3
🌐 [i18n-KO] Translated quark.md to Korean
Author: maximizemaxwell
Pull request: yes

# What does this PR do?

Translated the quark.md file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179
## Before reviewing

  - [x]  Check for missing / redundant translations (번역 누락/중복 검사)
  - [x] Grammar Check (맞춤법 검사)
  - [x] Review or Add new terms to glossary (용어 확인 및 추가)
  - [x]  Check Inline TOC (e.g. [[lowercased-header]])
  - [ ]  Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

@4N3MONE, @harheem @jungnerd @yijun-lee 
## 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#start-contributing-pull-requests),
    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.
   - [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).
   - [ ]  Did you write any new necessary tests?

## Who can review? (Final)

@stevhliu May you please review this PR?

Comments:
 made a few minor typo corrections and translation suggestions.

nice job 👍👍👍 

edit : please mention final reviewer (at this case, @ stevhliu) when you're done with all the reviews.

additionally, please also include a `toctree.yml` file in your PR that contains the changes you made to the file



It happened because the editor automatically applied prettier format to the yml file. 

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

@stevhliu i think it is ok to be merged. thanks! 🤗
Fix consistency and a few docstrings warnings
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

Race condition on modular conversion for Deepseek v2 + a few docstrings at the same time.

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

run-slow: d_fine, deepseek_v2, dinov2_with_registers, instructblipvideo, mimi, smolvlm

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39314). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
add `stevhliu` to the list in `self-comment-ci.yml`
Author: ydshieh
Pull request: yes

# What does this PR do?

welcome @stevhliu 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39315). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Check docstring inside modular files as well
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

We should check docstring in modular files as well! Otherwise, most of the time if the docstring is wrong in modular, e.g. in a Config, `make fix-copies` will apply modular with wrong docstring, then `check_docstring` will fix it, but we still have inconsistency between the modular (which was not fixed automatically) and the modeling which has been fixed! Thus reapplying the modular later will lead to wrong docstrings again.
This PR solves this circular inconsistency, and improves the overall modular workflow.

Also fixes some bad modulars at the same time (use relative imports everywhere, and remove bad inheritance of BambaCache)

cc @yonigozlan as you touched it a lot quite recently, and cc @ArthurZucker 

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

We discussed offline with @yonigozlan:
- this fix works nicely for the check without auto-docstring, as classes inherit docs from parent, so even if doc is not present but expected to be "recopied automatically" by modular, the check passes as the `__doc__` attribute is inherited
- For `check_auto_docstring` it's in general not an issue either, as there are 2 scenarios: either we inherit from an upstream class, and we don't need the decorator explicitly as it will be inherited automatically, or we use it explicitly but we also overwrite the doc in this case anyway, so the check will pass (only if explicitly adding the decorator but without the doc then the test will complain, but IMO it is right to complain in that case, even if the doc could be inherited -> why overwrite the decorator then if everything is the same as upstream??)

In any case, @yonigozlan said he wanted to refactor `check_auto_docstring` to use the `__doc__` attribute and make it more robust 

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

run-slow: aya_vision, bamba, biogpt, colpali, colqwen2, conditional_detr, data2vec, deformable_detr, dinov2_with_registers, dpt, falcon_h1, gemma3, gemma3n, got_ocr2, granitemoehybrid, grounding_dino
[CI ENERGY Waste] The exist jobs in `Doctests` that has never completed successfully
Author: souhailaS
Pull request: no




# Problem 

`Doctests` workflow (https://github.com/huggingface/transformers/actions/runs/15988670157) runs a total of 479 jobs resulting in average of 22h in each run (https://github.com/huggingface/transformers/actions/runs/15988670157/usage). 337 out of the total run jobs are constantly failing. Would you consider removing the jobs with 100% failure rate or adding adequate pre-check to avoid running these jobs ? 


# Additional Context

We are a team of researchers from University of Zurich (https://www.ifi.uzh.ch/en/zest.html) currently working on automating energy optimizations in GitHub Actions workflows. This workflow has been detected by our heuristics because of it high resource overload and failure rate.

souhaila.serbout@uzh.ch
 

Comments:
Yep sounds good! cc @ydshieh !

Happy to disable for now until I get the bandwidth for this.

Thank you for reporting 🤗
skip files in `src/` for doctest (for now)
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix #39159

Merge directly as 

https://github.com/huggingface/transformers/issues/39159#issuecomment-3045160413

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