noamaanMulla-03/transformers-issues huggingface dataset:
[serge] Fix 22 integration tests for model `whisper` failing with `other` (other (20), shape/size mismatch (2))
Author: sergereview[bot]
Pull request: yes

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

## Original CI failure

- Failure group: `1/1: 22 integration tests for model `whisper` failing with `other` (other (20), shape/size mismatch (2))`
- `tests/models/whisper/test_modeling_whisper.py::WhisperModelIntegrationTests::test_distil_token_timestamp_generation` [multi-gpu] (other, seen 7/7)

<!-- serge-task:integration-failure-triage:sha256:cb0ec086dc28124db10f983efc175fa156296babd9df994e8f9d9117ad160b07 -->
Relates to #47053

The Whisper integration tests fail with `UnboundLocalError: local variable 'is_updated' referenced before assignment` (and cascading errors) because `WhisperAttention.forward` only defines `is_updated` inside the `isinstance(past_key_values, EncoderDecoderCache)` branch. When a different cache type is used, the variable is undefined and the subsequent cross-attention reuse check crashes.

Root cause: missing initialization of `is_updated` before the conditional, unlike the equivalent code in bart and other encoder-decoder models.

Patch: add `is_updated = False` before the `EncoderDecoderCache` check in `WhisperAttention.forward` so the fallback path behaves correctly for non-EncoderDecoderCache caches.

---
_This change was produced automatically by serge from a CI failure report. The patch was generated by an LLM and applied by serge; review before merging._

_serge `v0.1.0` · model: `moonshotai/Kimi-K2.7-Code` · 53 LLM turns · 60 tool calls · 111.0s · 2093703 in / 4990 out tokens_

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

run-slow: whisper

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47056). 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=47056)
**Latest run:** [28699482656:1](https://github.com/huggingface/transformers/actions/runs/28699482656)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,501 | **Failures:** 7 | **Duration:** 24h 32m

<!-- ci-dashboard-recap:end -->
[serge] Fix 8 integration tests for model `mamba2` failing with `OOM` (other (8))
Author: sergereview[bot]
Pull request: yes

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

## Original CI failure

- Failure group: `1/1: 8 integration tests for model `mamba2` failing with `OOM` (other (8))`
- `tests/models/mamba2/test_modeling_mamba2.py::Mamba2IntegrationTest::test_batched_equivalence_with_cache` [multi-gpu] (OOM, seen 7/7)

<!-- serge-task:integration-failure-triage:sha256:50ea11303615c77def535e48657a6664d56a28a84b33a7d97560d27a8a591e29 -->
Relates to #47053

The mamba2 integration tests were OOMing on 22 GB CI GPUs. Root cause: the tests loaded the 7B `Mamba-Codestral-7B-v0.1` checkpoint with `dtype=torch.bfloat16`, which is not the `from_pretrained` argument for weight dtype; the kwarg is ignored, so weights load in float32 and roughly double memory usage. The patch switches those calls to `torch_dtype=torch.bfloat16`, adds a `torch.cuda.empty_cache()` in `setUp` to reduce fragmentation between tests, and lowers the mixer equivalence test sequence length from 512 to 128 to further reduce activation memory.

---
_This change was produced automatically by serge from a CI failure report. The patch was generated by an LLM and applied by serge; review before merging._

_serge `v0.1.0` · model: `moonshotai/Kimi-K2.7-Code` · 48 LLM turns · 49 tool calls · 205.6s · 2131666 in / 15914 out tokens_

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

run-slow: mamba2

<!-- 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=47058)
**Latest run:** [28699495193:1](https://github.com/huggingface/transformers/actions/runs/28699495193)
**Result:** `success` | **Jobs:** 5 | **Tests:** 335 | **Failures:** 0 | **Duration:** 4m 38s

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

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47058). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
fix mask return-type contract regression and add correctness guard for
Author: kaixuanliu
Pull request: yes

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

This PR fixes issue: https://github.com/huggingface/transformers/issues/46962
1. fix return-type regression for `create_masks_for_generate` func
2. Add strict restriction for ` _can_skip_causal_mask_xpu`: only when kv_offset==0 can we use fast path
@ArthurZucker @CyrilVallez pls help review. Thx!

Comments:
Also cc @Cyrilvallez to double check in the end please 🫡 

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

run-slow: deepseek_v32, glm_moe_dsa

<!-- 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=47019)
**Latest run:** [28762479384:2](https://github.com/huggingface/transformers/actions/runs/28762479384)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,238 | **Failures:** 6 | **Duration:** 25h 58m

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

> Just pushed a commit, LGTM to me now! @kaixuanliu, I changed the condition `kv_offset == 0` to `q_offset == 0`, which is the correct condition for an empty cache, as per my comment in [#46962 (comment)](https://github.com/huggingface/transformers/issues/46962#issuecomment-4863002399). This is the only case when the upper left mask of sdpa with `is_causal=True` will be correctly aligned

Oh,thx for correcting my mistake!
[cache] Simplify cache dispatch based on layer_types
Author: Cyrilvallez
Pull request: yes

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

# What does this PR do?

As per the title. This create a mapping for sliding layers as well, because we are currently in a place where we have a mapping but it's not used to dispatch static layers. Also makes the mappings more explicit by only using `__init_subclass__` if the cache layer lives in another modeling file.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47118). 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=47118)
**Latest run:** [28843909101:1](https://github.com/huggingface/transformers/actions/runs/28843909101)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,324 | **Failures:** 6 | **Duration:** 20h 11m

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

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

run-slow: deepseek_v4, minimax_m3_vl
Small improvement
Author: Cyrilvallez
Pull request: yes

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

# What does this PR do?

Was supposed to be in https://github.com/huggingface/transformers/pull/47118, but did not make it due to small git mismanip

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47128). 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=47128)
**Latest run:** [28850056496:1](https://github.com/huggingface/transformers/actions/runs/28850056496)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,334 | **Failures:** 6 | **Duration:** 24h 17m

<!-- ci-dashboard-recap:end -->
we want to run the CI in the release branches
Author: tarekziade
Pull request: yes

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

# What does this PR do?

We missed the release branches in the new WF

The CircleCI to AWS migration swapped an implicit "run on every branch" model for an explicit allowlist (main, ci-*) and we did not add release branches.

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=47125)
**Latest run:** [28847496114:1](https://github.com/huggingface/transformers/actions/runs/28847496114)
**Result:** `success` | **Jobs:** 1 | **Tests:** 6 | **Failures:** 0 | **Duration:** 18s

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

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47125). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
tests/cli fail with huggingface_hub 1.22.0: 'HFCliTyperGroup' object has no attribute '_add_completion':
Author: Madhav-000-s
Pull request: no
Labels: name: bug

### System Info

transformers: main (5.14.0.dev0)
huggingface_hub: 1.22.0
typer: 0.26.8 / click: 8.4.2 (also reproduces with typer 0.24.1)
Python 3.10 (CI docker image) — also reproduced on Python 3.11 / Windows
Note: `transformers env` itself crashes with this bug, so output is unavailable.

### Who can help?

_No response_

### Information

- [x] 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

pip install huggingface_hub==1.22.0
python -m pytest tests/cli/test_system.py -x
# AttributeError: 'HFCliTyperGroup' object has no attribute '_add_completion'
#   at typer/main.py::get_command -> typer_instance._add_completion

### Expected behavior

tests/cli passes; `transformers env` / `version` work with the latest huggingface_hub.

Comments:
Root-caused this. Since `huggingface_hub 1.22.0` (released 2026-07-03), `typer_factory` returns hub's own click command group (`HFCliTyperGroup`) instead of a `typer.Typer`.

Two distinct breakages:
1. **The 6 CI failures**: `tests/cli/conftest.py` drives the app with `typer.testing.CliRunner`,
   whose `invoke()` calls typer's `get_command()` and reads `._add_completion` — an attribute
   only real `Typer` instances have → `AttributeError`. (`transformers env` works interactively
   because direct invocation never goes through `get_command()`.)
2. **A runtime bug behind it**: `serve`'s `--reasoning` declares its default as the enum member
   `ReasoningMode.AUTO`; click validates defaults against the string choices and rejects it, so
   `transformers serve` itself fails under hub 1.22.0 — not just the tests.

Fix for both in #47064: drive the app with `click.testing.CliRunner` (identical `invoke`
signature; the app is a genuine click group now) and default `--reasoning` to the enum's value.
`tests/cli`: 6 failed → 74 passed, 0 failed.
Add cache-aware streaming and RNN-T head for Parakeet
Author: jmayank1511
Pull request: yes
Labels: name: Audio

# What does this PR do?

  Extends Parakeet TDT (#44171) with cache-aware streaming + an RNN-T
   head. The cache-aware variant is shipped as **Nemotron Speech
  Streaming** (`nvidia/nemotron-speech-streaming-en-0.6b`).

  ### Adds
  - `ParakeetForRNNT` — RNN-T head (LSTM prediction net + joint
  network) on the shared encoder. Supports regular and cache-aware
  checkpoints. Offline via `generate(...)`.
  - `ParakeetCacheAwareStreamingBuffer` + `streaming_step()` +
  `get_initial_streaming_state()` — chunk-by-chunk greedy RNN-T
  decoding with encoder KV cache, decoder LSTM state, and last-token
  threaded across chunks. Mirrors NeMo's
  `_greedy_decode_blank_as_pad_loop_frames`.
  - Prompt-conditioned multilingual — one-hot language MLP after
  encoder, resolved via `target_lang`.
  - NeMo `CausalConv2D` padding alignment in subsampling.
  - Unigram SentencePiece support in `ParakeetConverter`.
  - Doc + unit tests for `ParakeetForRNNT`.



## Code Agent Policy
- [x]  I confirm that this is not a pure code agent PR.

 ## Before submitting
  - [ ] This PR fixes a typo or improves the docs.
  - [x] Did you read the [contributor
  guideline](https://github.com/huggingface/transformers/blob/main/CON
  TRIBUTING.md#create-a-pull-request)?
  - [ ] Was this discussed/approved via a Github issue or the forum?
  - [x] Did you make sure to update the documentation with your
  changes?
  - [x] Did you write any new necessary tests?


## Who can review?

 @eustlb @ebezzam @vasqu





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

run-slow: auto, parakeet

This was added in #46331, closing here
[serge] Fix 12 integration tests for model `dac` failing with `output_mismatch` (tensor values differ (6), other (6))
Author: sergereview[bot]
Pull request: yes

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

## Original CI failure

- Failure group: `1/1: 12 integration tests for model `dac` failing with `output_mismatch` (tensor values differ (6), other (6))`
- `tests/models/dac/test_modeling_dac.py::DacIntegrationTest::test_integration_0_dac_16khz` [multi-gpu] (output_mismatch, seen 6/7)

<!-- serge-task:integration-failure-triage:sha256:aa1fcb5380a3e3d76ad969311cc7b698661a763e3eeb57ab7999254a9eac3f00 -->
Relates to #47120

The DAC integration tests have been failing with output mismatches across all `descript/dac_*` checkpoints.

**Root cause:** `DacPreTrainedModel._init_weights` does not call `super()._init_weights(module)`, unlike the other audio codec models (EnCodec, Mimi, SpeechT5, FastSpeech2Conformer). Skipping the base initialization can leave parameters incorrectly initialized or marked when pretrained weights are loaded, which changes the encoder/quantizer outputs that the integration tests assert against.

**Fix:** Add `super()._init_weights(module)` at the start of `DacPreTrainedModel._init_weights` so it follows the same initialization convention as the rest of the library.

---
_This change was produced automatically by serge from a CI failure report. The patch was generated by an LLM and applied by serge; review before merging._

_serge `v0.1.0` · model: `moonshotai/Kimi-K2.7-Code` · 55 LLM turns · 58 tool calls · 117.8s · 2093962 in / 14730 out tokens_

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

run-slow: dac

<!-- 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=47121)
**Latest run:** [28846271628](https://github.com/huggingface/transformers/actions/runs/28846271628)
**Result:** `success` | Grafana metrics are not available yet.

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

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47121). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add option to export  encoder hidden states for Granite-speech
Author: zvik
Pull request: yes

# What does this PR do?

This PR allows the Granite-speech model to use hidden states from the encoder hidden layers.

This is an internal model option that is required for the next generation of Granite-speech models.

## Changes:

- New config parameter: encoder_hidden_layers: list[int] | None # e.g., [6, 12, 18]
- Validation for the parameter values
- Concatenation of the required hidden layers to the final output of the encoder

We chose to add a new parameter instead of using the output_hidden_states option for the following reasons:
- The hidden layers from the encoder are only used internally and are not needed outside of the model.
- The output_hidden_states return all the layers instead of just those that are needed.
- In our case, we only need a small number of hidden layers. Returning all of them with the output_hidden_states flag can increase the memory footprint, especially for large audio data. This can impact the allowed decoding batch size.


## 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?

- audio models: @eustlb @ebezzam @vasqu

(@gsaon @avihu111 )

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

run-slow: granite_speech

Hi @eustlb 
I have now uploaded a model that can be used for testing: `konszvi/granite-4.0-1b-speech-rt-v0.09.00-merged`
I've also merged recent changes from main.
Please let me know how to proceed with this PR. If you wish, we can continue on slack.
Thanks

Such a feature was handled directly via a dedicated modeling in #45695, closing here
Fix CLI compatibility with huggingface_hub 1.22 (#47059)
Author: dhruv7477
Pull request: yes

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

# What does this PR do?

Fixes #47059

`huggingface_hub 1.22.0` changed `typer_factory` to return a click command group (`HFCliTyperGroup`) instead of a `typer.Typer`, breaking transformers in two places:

- **`tests/cli/conftest.py`**: `typer.testing.CliRunner.invoke()` calls typer's `get_command()`, which reads `._add_completion` off the app — only real `Typer` objects have it → the 6 CI failures on every PR. Switched to `click.testing.CliRunner` (identical `invoke` signature), which drives the click group natively.
- **`src/transformers/cli/serve.py`**: `--reasoning` declared its default as the enum member `ReasoningMode.AUTO`; click validates defaults against the string choices and rejects it, so `transformers serve` fails at runtime under hub 1.22.0. The default is now the enum's value; runtime comparisons are unaffected (`ReasoningMode` is a str enum, so `"on" == ReasoningMode.ON`).

`tests/cli`: 6 failed → **74 passed, 0 failed** (verified against hub 1.22.0 + typer 0.26.8 + click 8.4.2, the CI combination). Note: setup.py allows `huggingface-hub>=1.5.0`; the click runner assumes the ≥1.22 group-shaped app, which is what any fresh install resolves to — happy to gate on the app type instead if you'd rather keep the test compatible with older hubs.

## Who can review?

@Wauplin @ArthurZucker

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

> Could we make it BC friendly pleaese? I would like to avoid raising the minimum version for the hub for only "small" changes

Done in [e9ba04d](https://github.com/huggingface/transformers/pull/47064/commits/e9ba04d61dca5a1a5a34d0ec7573e09b599c8664) —
the fixture now handles both shapes without touching the hub version floor: with `huggingface_hub >= 1.22` the app is already a click command group and is invoked natively; with older hubs it's a `typer.Typer`, converted via `typer.main.get_command()` first. Verified the full `tests/cli` suite passes against both huggingface_hub 1.21.0 and 1.22.0 locally.


<!-- 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=47064)
**Latest run:** [28852121895:2](https://github.com/huggingface/transformers/actions/runs/28852991207)
**Result:** `success` | **Jobs:** 3 | **Tests:** 204 | **Failures:** 0 | **Duration:** 2m 55s

<!-- ci-dashboard-recap:end -->
Fix legacy list-based special_tokens handling in _set_model_specific_special_tokens
Author: ZubairAli999
Pull request: yes

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

## Summary

This PR adds backward compatibility for legacy tokenizer configurations where
`special_tokens` is stored as a list instead of a dictionary.

## Problem

`_set_model_specific_special_tokens()` assumes that `special_tokens` is always a
dictionary and immediately calls:

```python
special_tokens.keys()

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=47132)
**Latest run:** [28857479211:2](https://github.com/huggingface/transformers/actions/runs/28859002588)
**Result:** `failure` | **Jobs:** 2 | **Tests:** 22 | **Failures:** 1 | **Duration:** 1m 58s

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

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