noamaanMulla-03/transformers-issues huggingface dataset:
Fix off-by-one in MoonshineStreaming sliding window right context
Author: sridhar-3009
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47231)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47231)
<!-- ci-dashboard-badge:end -->

## What

`sliding_window_mask_function` uses strict less-than for the right context:

```python
right_mask = (dist < 0) & (-dist < right_window_size)
```

With `w_right=4`, this only attends to 3 future frames (distances 1, 2, 3) because `-dist` must be strictly less than 4. The Moonshine v2 paper defines `w_right` as the **number** of future frames to attend to, so the condition should be `<=`.

Fix: change `<` to `<=` so that `w_right=4` attends to exactly 4 future frames.

Both `modular_moonshine_streaming.py` (source) and `modeling_moonshine_streaming.py` (generated) are updated.

Fixes #46305.

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

run-slow: moonshine_streaming

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47231)
**Latest run:** [29068649591:2](https://github.com/huggingface/transformers/actions/runs/29070233657)
**Result:** `failure` | **Jobs:** 4 | **Tests:** 266 | **Failures:** 1 | **Duration:** 1m 21s

> **Code quality check failed**: test jobs were skipped. Fix the code quality issues and push again to run tests.

<!-- ci-dashboard-recap:end -->
Fix double-shift training loss in CohereAsrForConditionalGeneration
Author: sridhar-3009
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47235)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47235)
<!-- ci-dashboard-badge:end -->

Fixes #46894

## Problem

`CohereAsrForConditionalGeneration.forward()` has a double-shift bug that corrupts training loss:

1. When `labels` are provided, `shift_tokens_right()` is called to produce `decoder_input_ids` (line 483 of `modular_cohere_asr.py`).
2. The model runs with these shifted inputs and produces `logits`.
3. `self.loss_function()` is then called — but this maps to `ForCausalLMLoss`, which **shifts labels again** internally (`labels[..., 1:]`) in `loss/loss_utils.py`.

The net effect is training against `labels[..., 1:]` instead of `labels`, causing silent gradient corruption and divergent training loss.

This is the same bug that was fixed in Moonshine in #46784 (commit d8c235494e). `CohereAsr` inherits from Moonshine and overrides `forward`, but the fix was not carried over.

## Fix

Replace `self.loss_function(logits=logits, labels=labels, ...)` with a direct `CrossEntropyLoss()` call — identical to the Moonshine fix:

```python
loss_fct = CrossEntropyLoss()
loss = loss_fct(logits.reshape(-1, self.config.vocab_size), labels.reshape(-1))
```

Applied to both `modular_cohere_asr.py` (source) and `modeling_cohere_asr.py` (generated).

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

run-slow: cohere_asr

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47235)
**Latest run:** [29069313247](https://github.com/huggingface/transformers/actions/runs/29069313247)
**Result:** `success` | Grafana metrics are not available yet.

<!-- ci-dashboard-recap:end -->
Fix Swin2SR over-padding when dimensions are already aligned
Author: Functionhx
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47207)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47207)
<!-- ci-dashboard-badge:end -->

Fixes #46697

The padding formula (dim // divisor + 1) * divisor - dim always adds an extra divisor of padding even when the dimension is perfectly divisible. For example, an 800px image with divisor=8 gets 8px of padding instead of 0.

Replace with (divisor - dim % divisor) % divisor, which returns 0 when already aligned and the correct amount otherwise.

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

run-slow: swin2sr

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47207)
**Latest run:** [29020004956:2](https://github.com/huggingface/transformers/actions/runs/29020004956)
**Result:** `success` | **Jobs:** 5 | **Tests:** 293 | **Failures:** 0 | **Duration:** 3s

<!-- ci-dashboard-recap:end -->
FileNotFoundError when loading a trust_remote_code model from cache
Author: ldkhang1201
Pull request: no
Labels: name: bug

### System Info

transformer version: 5.10.1
vllm 0.22

### Who can help?

@Cyrilvallez 

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

1. Pull a trust_remote_code model
2. Try to serve it with vllm, which load it from cache
3. `FileNotFoundError: [Errno 2] No such file or directory:
'.../blobs/transformers_4_44_2__modeling_rope_utils.py'`

### Expected behavior

The model successfully loads from the cache and serve

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

I have already create a PR waiting for merge

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.
pr_build_doc_with_comment.yml is rejected at startup (job 'if:' references a job not in its 'needs:') — 3,086 startup failures, no notification
Author: kobihikri
Pull request: no

Hi — I think `pr_build_doc_with_comment.yml` has been failing to start since early April, quietly.

In the `verity_pr_commit` job:

```yaml
if: ${{ needs.get-pr-number.outputs.PR_NUMBER != ''}}
runs-on: ubuntu-22.04
needs: get-pr-info
```

The `if:` refers to `get-pr-number`, but only `get-pr-info` is listed in `needs:`. A job's `if:` can only reference jobs in its own `needs:`, so GitHub rejects the workflow when it parses it.

Because it fails at parse time it produces no failing check and no notification, which I suspect is why it hasn't been noticed. Run history:

```
startup_failure: 3086
success:           34   (last one: 2026-04-02)
```

The five most recent runs (today) are all `startup_failure`. So a maintainer commenting `build-doc` on a PR currently gets silence.

Adding the missing dependency looks like it would fix it:

```yaml
needs: [get-pr-number, get-pr-info]
```

I'm happy to open a PR if that's welcome — I held off because the PR checklist asks first-time contributors to confirm the description and code aren't LLM-written, and I used AI assistance here, so I didn't want to tick that box untruthfully.

*(Checked at `01dd2fd817a51a67eeb9126233faf9cbb380a17c`.)*


Comments:
Hello @kobihikri  could you please assign this issue to me ?? 

Hi @siva23367 — thank you, that's kind of you to pick this up! 🙏

I don't have write access to the repo, so GitHub won't let me formally assign it — but please consider it yours and go right ahead.

For reference, the fix looks like a one-liner: the `verity_pr_commit` job has `if: needs.get-pr-number.outputs.PR_NUMBER != ''` but only lists `needs: get-pr-info`, so adding `get-pr-number` to that `needs:` (e.g. `needs: [get-pr-number, get-pr-info]`) should let the workflow start again. Happy to help review or test if that's useful. Thanks again for taking it on.
Fix TimesFM window_size AttributeError (#46821)
Author: maslinedwin
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47223)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47223)
<!-- ci-dashboard-badge:end -->

Fixes #46821

Fixes AttributeError raised when using window_size argument in TimesFM 2.5 models. Removed incorrect AttributeError() assignments in config class.

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

run-slow: timesfm2_5

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47223)
**Latest run:** [29047733923](https://github.com/huggingface/transformers/actions/runs/29047733923)
**Result:** `failure` | Grafana metrics are not available yet.

<!-- ci-dashboard-recap:end -->

The consistency check failure may be due to missing documentation. The fix is straightforward: removed incorrect AttributeError() assignments in TimesFM 2.5 config that were causing the window_size parameter to fail. Added comprehensive test coverage with integration tests for the window_size parameter. All Python files are syntactically valid and follow the existing codebase patterns.

The 'Check repository consistency' failure is likely due to the test files being updated. The fix itself is straightforward and tests are syntactically valid. As suggested by the CI bot, could you run the slow test for TimesFM?

Command: run-slow: timesfm2_5

This will allow the repository consistency check to pass.
Make `MODEL_IDS_TO_TOKENIZERS_BACKEND` capture all DeepSeek R1 distills
Author: hmellor
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47296)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47296)
<!-- ci-dashboard-badge:end -->

The existing key only triggers for one distill, but we know that `LlamaTokenizerFast` is incorrect for all of these checkpoints.

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

run-slow: auto

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

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47296)
**Latest run:** [29240981206:1](https://github.com/huggingface/transformers/actions/runs/29240981206)
**Result:** `success` | **Jobs:** 15 | **Tests:** 171,030 | **Failures:** 0 | **Duration:** 14h 39m

<!-- ci-dashboard-recap:end -->
Polish repository docs in transformers
Author: bglglzd
Pull request: yes

I fixed a small set of formatting issues that were easy to clean up without touching behavior.

Comments:
Thank you for your contribution 🤗!

## CI Security Gate — automatic approval blocked

This PR was **not** automatically approved for CI because the security gate failed.

**Possible reasons:**
- The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
- A changed file is outside the allowed directories (`src/`, `tests/`, `docs/`, `utils/`), has a disallowed extension (only `.py`, `.txt`, `.md` permitted outside `tests/` and `docs/`), or is not `.md`/`.yml` inside `docs/`
- A new high-severity security issue was detected in the changed Python files (Bandit check)

See the [workflow run](https://github.com/huggingface/transformers/actions/runs/29186192597) for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

We don't really want PRs for these kinds of automated sweeps! They're painful to review (and we have to check them for security, to make sure nothing is hiding in there), and we can just do them ourselves with a code agent
Fix minor text formatting in transformers (#47254)
Author: bglglzd
Pull request: yes

This patch keeps scope tight and should not alter runtime behavior.

Related to #47254.

Comments:
Thank you for your contribution 🤗!

## CI Security Gate — automatic approval blocked

This PR was **not** automatically approved for CI because the security gate failed.

**Possible reasons:**
- The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
- A changed file is outside the allowed directories (`src/`, `tests/`, `docs/`, `utils/`), has a disallowed extension (only `.py`, `.txt`, `.md` permitted outside `tests/` and `docs/`), or is not `.md`/`.yml` inside `docs/`
- A new high-severity security issue was detected in the changed Python files (Bandit check)

See the [workflow run](https://github.com/huggingface/transformers/actions/runs/29186209792) for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.
fix: restore dict return type in create_masks_for_generate (#46962)
Author: davidnichols-ops
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47267)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47267)
<!-- ci-dashboard-badge:end -->

## Summary

- PR #46446 added an early return `return attention_mask` in `create_masks_for_generate` when any `layer_type` is not in `LAYER_PATTERN_TO_MASK_FUNCTION_MAPPING`. This broke the dict return type contract that models like Qwen3, Cohere2, Bamba, DeepseekV32, etc. rely on via `isinstance(attention_mask, dict)`, causing unnecessary mask recomputation and performance regression (issue #46962).
- Replaced the early return with inline handling: unmapped types get the raw `attention_mask` as their dict value, so the model still receives a dict and can use pre-computed masks for mapped types while deferring to the model for unmapped types.
- Net-negative: 2 insertions, 4 deletions.

**Deleted:** the early return `if any(layer_type not in ...): return attention_mask` (3 lines) — replaced with a `.get()` + conditional in the existing loop, preserving the dict return type contract that all hybrid models depend on.

#### Test plan

- [x] Single layer type (all `full_attention`) → returns `dict` with `full_attention` key (was bare value before)
- [x] Mixed layer types (`full_attention` + `sliding_attention`) → returns `dict` with both keys
- [x] No `layer_types` attribute → returns bare value (unchanged behavior)
- [ ] Full Qwen3 model test suite (requires GPU)

Generated with [Devin](https://devin.ai)

Comments:
<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47267)
**Latest run:** [29203277893:2](https://github.com/huggingface/transformers/actions/runs/29203277893)
**Result:** `success` | **Jobs:** 15 | **Tests:** 170,764 | **Failures:** 0 | **Duration:** 14h 27m

<!-- ci-dashboard-recap:end -->

Thanks for taking a look. Could you share the reason for closing this? If there’s a technical issue with the approach or if it doesn’t align with project policy, I’d appreciate the feedback.
[i18n-<supremeA AI Model ai.th AI >] Translating docs to <Copilot>
Author: imgoingbacktheonlything239-ops
Pull request: no
Labels: name: WIP

name: Code agent slop

<!--
Note: Please search to see if an issue already exists for the language you are trying to translate.
-->

Hi!

Let's bring the documentation to all the <languageName>-speaking community 🌐 (currently 0 out of 267 complete)

Who would want to translate? Please follow the 🤗 [TRANSLATING guide](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md). Here is a list of the files ready for translation. Let us know in this issue if you'd like to translate any, and we'll add your name to the list.

Some notes:

* Please translate using an informal tone (imagine you are talking with a friend about transformers 🤗).
* Please translate in a gender-neutral way.
* Add your translations to the folder called `<languageCode>` inside the [source folder](https://github.com/huggingface/transformers/tree/main/docs/source).
* Register your translation in `<languageCode>/_toctree.yml`; please follow the order of the [English version](https://github.com/huggingface/transformers/blob/main/docs/source/en/_toctree.yml).
* Once you're finished, open a pull request and tag this issue by including #issue-number in the description, where issue-number is the number of this issue. Please ping @stevhliu for review.
* 🙋 If you'd like others to help you with the translation, you can also post in the 🤗 [forums](https://discuss.huggingface.co/).

## Get Started section

- [ ] [index.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/index.md) https://github.com/huggingface/transformers/pull/20180
- [ ] [quicktour.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/quicktour.md) (waiting for initial PR to go through)
- [ ] [installation.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/installation.md).

## Tutorial section
- [ ] [pipeline_tutorial.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/pipeline_tutorial.md)
- [ ]  [autoclass_tutorial.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/autoclass_tutorial.md)
- [ ]  [preprocessing.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/preprocessing.md)
- [ ]  [training.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/training.md)
- [ ]  [accelerate.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/accelerate.md)
- [ ]  [model_sharing.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_sharing.md)
- [ ]  [multilingual.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/multilingual.md)

<!--
Keep on adding more as you go 🔥
-->

Comments:
Hello @imgoingbacktheonlything239-ops could you please assign this issue to me ?? 

both of you are blocked lmao
Standardize COCO test image fixture loading
Author: DivyanshPoothiya
Pull request: yes
Labels: name: Code agent slop

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47260)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47260)
<!-- ci-dashboard-badge:end -->

## What does this PR do?

This PR adds a shared `load_test_image()` helper for loading test image fixtures and replaces direct COCO image downloads using `httpx.get()` and `requests.get()` with the shared helper.

The updated tests now use the Hugging Face COCO fixture mirror, making fixture loading consistent with the existing CI prefetching behavior.

### Validation

- Ran `python -m compileall` on modified files.
- Ran `ruff check --fix`.
- Ran:
  - `pytest tests/models/vitpose/test_image_processing_vitpose.py -k test_backends_equivalence`
  - `pytest tests/models/flava/test_image_processing_flava.py -k test_slow_fast_equivalence`

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

run-slow: aimv2, aria, deepseek_vl_hybrid, eomt, eomt_dinov3, fast_vlm, flava, fuyu, idefics, imagegpt, kimi_k25, layoutlmv2, lfm2_vl, llava, minimax_m3_vl, pix2struct

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47260)
**Latest run:** [29157457414:2](https://github.com/huggingface/transformers/actions/runs/29157457414)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 170,756 | **Failures:** 0 | **Duration:** 14h 19m

<!-- ci-dashboard-recap:end -->

The code quality and repository consistency checks are passing.

The remaining `examples_torch` job was terminated with exit code 137:

`Executing the custom container implementation failed. Please contact your self hosted runner administrator.`

This appears to be a self-hosted runner/resource issue unrelated to the changes in this PR. Could the failing job please be rerun?

No code agent PRs from first-time contributors, please check AGENTS.md
Fix get_json_schema crash on non-string docstring choices
Author: Sreekant13
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47072)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47072)
<!-- ci-dashboard-badge:end -->

# What does this PR do?

`get_json_schema` parses a docstring's `(choices: ...)` block with `json.loads`, so it accepts any JSON values, but it then calls `.strip()` on every element. This raises `AttributeError: 'int' object has no attribute 'strip'` for non-string choices such as `(choices: [1, 2, 3])` or `(choices: [true, false])`:

```python
def rate(score: int):
    """Rate it.

    Args:
        score: The score to give (choices: [1, 2, 3])
    """

get_json_schema(rate)  # AttributeError: 'int' object has no attribute 'strip'
```
The equivalent `Literal[1, 2, 3]` type hint already produces a valid non-string enum (covered by `test_literal`), so this makes the docstring `(choices: ...)` path consistent: strip only string choices and leave other JSON values (ints, bools, ...) as-is. Added a regression test (`test_enum_extraction_non_string_choices`) covering int and bool choices.

No prior issue; this is a small, self-contained bug fix.

- [x] I confirm that this is not a pure code agent PR.

## 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://huggingface.co/docs/transformers/contributing) and the
      [Pull Request](https://huggingface.co/docs/transformers/pr_checks) checks?
- [ ] 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. (No prior issue; small bug fix.)
- [ ] Did you make sure to update the documentation with your changes according to the [guidelines](https://github.com/huggingface/transformers/tree/main/docs)? (No docs change needed.)
- [X] Did you write any new necessary [tests](https://huggingface.co/docs/transformers/testing)? (Added `test_enum_extraction_non_string_choices`.)


## Who can review?

@Rocketknight1 (chat templates / tool-use JSON schema)

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

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47072)
**Latest run:** [29253844638:2](https://github.com/huggingface/transformers/actions/runs/29253844638)
**Result:** `success` | **Jobs:** 15 | **Tests:** 166,009 | **Failures:** 0 | **Duration:** 12h 43m

<!-- ci-dashboard-recap:end -->