PULL REQUEST #46081: fix(cache): StaticLayer.get_seq_length() should return int not Tensor
State: closed  |  Merged: False
Author: rmotgi1227  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T17:59:32Z

Fixes #45987.

## Summary

`StaticLayer.get_seq_length()` declares `-> int` (matching the abstract base class contract) but returns `self.cumulative_length` directly, which is a shape-`(1,)` tensor stored that way intentionally for `torch.compile` / `mark_static_address` compatibility.

Returning the raw tensor breaks:
- `isinstance(seq, int)` checks downstream
- arithmetic with plain Python ints (`input_len - cache.get_seq_length()` returns `tensor([0])` instead of `0`)
- any code that passes the result to a function expecting a plain `int`

## Fix

Call `.item()` to extract the scalar value before returning:

```python
# BEFORE
return self.cumulative_length if self.is_initialized else 0

# AFTER
return self.cumulative_length.item() if self.is_initialized else 0
```

The internal `self.cumulative_length` tensor is untouched — it is still used as a tensor in `update()` for `cache_position` arithmetic and `mark_static_address`, so `torch.compile` behavior is unaffected.

--- Comment by github-actions[bot] at 2026-05-19T18:20:55Z ---
View the CircleCI Test Summary for this PR:

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


PULL REQUEST #46080: Fix wrong variable in check_model_type isinstance check
State: open  |  Merged: False
Author: SebTardif  |  Base: main
Labels:
Created: 2026-05-19T17:17:53Z

## What does this PR do?

Fixes a bug in `Pipeline.check_model_type()` where the inner loop over `_model_mapping._extra_content` (line 1102) uses `model` as its iteration variable, but the `isinstance` check on line 1103 referenced `model_name` from the outer loop. This caused incorrect tuple/non-tuple branching for dynamically registered models (via `AutoModel.register()`), potentially raising `AttributeError`.

This bug was introduced in #24960 (2023-07-21) and has been present for nearly 2 years.

- [x] I confirm that this is not a pure code agent PR.

## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request), Pull Request section?
- [x] Did you make sure to update the documentation with your changes? N/A, no doc changes needed.
- [ ] Did you write any new necessary tests? No existing tests for `check_model_type`; the fix is a self-evident 1-word variable rename.

## Who can review?

@Rocketknight1 (pipelines)

--- Comment by HuggingFaceDocBuilderDev at 2026-05-20T11:41:18Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46080). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46079: Fix Gemma4 use_bidirectional_attention="all" mask behavior
State: open  |  Merged: False
Author: oliverholworthy  |  Base: main
Labels:
Created: 2026-05-19T17:01:20Z

Fixes #46077

This makes `Gemma4TextConfig(use_bidirectional_attention="all")` set `config.is_causal = False`.

Gemma4 already marks attention modules as non-causal for `"all"`, but mask creation goes through the shared masking helpers, which use `config.is_causal` to switch from causal masks to bidirectional masks. Without the config flag, `"all"` can still produce causal masks.

The change is intentionally small: one config line plus a regression test that checks Gemma4 eager attentions are actually unmasked for future tokens.

## Code Agent Policy

- [x] I confirm that this is not a pure code agent PR.

AI assistance was used to investigate and draft the patch. I reviewed the changed lines and ran the checks below.

## Before submitting

- [ ] This PR fixes a typo or improves the docs.
- [x] I read the contributor guideline Pull Request section.
- [x] This was discussed/approved via GitHub issue: #ISSUE_NUMBER
- [x] Documentation changes are not needed; this fixes behavior to match existing bidirectional attention docs.
- [x] I wrote a regression test.

## Duplicate-work check

I did not find a direct duplicate. Related but different work:

- #45201 / #45202: Gemma4 FlashAttention `global_head_dim=512` compatibility.
- #45482: Gemma4 CPU offload/device mismatch issues.
- #43705: general merged `is_causal` support for decoder-only models as encoders.

## Tests

```bash
TRANSFORMERS_TEST_DEVICE=cpu PYTHONPATH=src uv run --no-sync python -m pytest tests/models/gemma4/test_modeling_gemma4.py::Gemma4TextModelTest::test_all_bidirectional_attention_uses_bidirectional_mask -q
```

Result: `1 passed, 26 warnings in 4.23s`.

```bash
make style
```

Result: passed.

--- Comment by github-actions[bot] at 2026-05-19T17:02:37Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma4


PULL REQUEST #46076: add flash base test and fix the incorrect and crash issue during enab…
State: open  |  Merged: False
Author: sywangyi  |  Base: deepgemm-isolation
Labels:
Created: 2026-05-19T12:04:25Z

- Intel XPU: @IlyasMoutawwakil

--- Comment by sywangyi at 2026-05-19T12:06:42Z ---
@IlyasMoutawwakil Hi, I worked in your branch and reenabling flash-base, during the enabling, I also found the crash and incorrect output in deepseek v4 flash. it may be introduced by your rebasing, please take a look

--- Comment by github-actions[bot] at 2026-05-20T00:49:06Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: deepseek_v4, finegrained_fp8


PULL REQUEST #46075: Adding test to ensure Gemma 4 processing of batches with mixed image and text-only samples
State: closed  |  Merged: False
Author: gabrielspmoreira  |  Base: main
Labels:
Created: 2026-05-19T11:29:49Z

This PR adds a test to demonstrate how to process a batch with image and text-only samples with Gemma 4.
For samples with no image, the `[]` placeholder should be used as follows, as included in this test.

```python
out_images_and_text_batch = processor(
            text=[text_image, text_no_image, text_no_image], images=[[image], [], []], return_tensors="np"
        )
```

Related to issue #40263

cc @zucchini-nlp

--- Comment by github-actions[bot] at 2026-05-19T11:30:53Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma4


[ALM] flaky alm tests

PULL REQUEST #46074: [ALM] flaky alm tests
State: closed  |  Merged: True
Author: eustlb  |  Base: main
Labels:
Created: 2026-05-19T10:36:16Z

# What does this PR do?

two things:
1. fix the flakyness of test_mismatching_num_audio_tokens
it duplicates audio[:1, ...] and expects the model to raise ValueError because total audio tokens no longer match total placeholders. This only fires if the duplicated sample contributes ≥ 1 audio token. For encoders with aggressive temporal downsampling like glmasr,  the audio mask can result to 0 audio tokens,  making that duplicating this remains 0 tokens and therefore no error is raised → flaky test

2. remove overwrittes of `create_audio_mask`

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T10:47:20Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46074). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by github-actions[bot] at 2026-05-20T10:13:56Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: audioflamingo3, musicflamingo, qwen2_audio

--- Comment by vasqu at 2026-05-19T11:31:43Z ---
I would highlight this a bit - I assume this is the new forcing of at least one valid entry

--- Comment by vasqu at 2026-05-19T11:34:10Z ---
Can we not just use mock patching, e.g. with ...? I think it's a bit more elegant than manually doing this (and safer because these are written for exactly this)

--- Comment by vasqu at 2026-05-19T11:36:20Z ---
```suggestion
        dup_idx = int((input_dict[audio_feature_key] == audio_token_id).sum(-1).argmax().item())
```
just for consistency?

--- Comment by vasqu at 2026-05-19T11:37:18Z ---
Super nit: And maybe `dup_idx` --> `audio_token_idx`. I think that's a bit more clearer

--- Comment by eustlb at 2026-05-20T10:09:03Z ---
agree, important to hightlight! adding a comment

--- Comment by eustlb at 2026-05-20T10:16:00Z ---
absolutely! was not aware of that, thanks for the suggestion 🙏


PULL REQUEST #46073: [CTRL] Support attn_implementation="sdpa" dispatch
State: open  |  Merged: False
Author: YangKai0616  |  Base: main
Labels:
Created: 2026-05-19T09:25:05Z

# What does this PR do?

The `CTRL` model fails during the initialization phase when using `from_pretrained(..., attn_implementation="sdpa")`. This PR enables standard `attn_implementation="sdpa"` dispatch to `CTRL` .

Hi @ArthurZucker, pls help review, thx!

--- Comment by github-actions[bot] at 2026-05-20T06:55:52Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: ctrl


PULL REQUEST #46070: [CB] [Major] Rework manager to have clearer control flow + handle TP
State: open  |  Merged: False
Author: remi-or  |  Base: main
Labels:
Created: 2026-05-19T07:56:46Z

# Summary

This PR reworks the continuous batching manager in order to make its control flow clearer and separate the background and main thread. Notably:
- the methods inside the `ContinuousBatchingManager` class are now clearly categrorized
- the status of the background thread now lives in a dedicated object

It also modifies the manager to avoid race conditions in TP.

## Performance

TBD

## Tests

TBD

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T08:08:17Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46070). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by github-actions[bot] at 2026-05-20T12:57:20Z ---
View the CircleCI Test Summary for this PR:

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


PULL REQUEST #46069: [ShieldGemma2] Support attn_implementation dispatch
State: open  |  Merged: False
Author: YangKai0616  |  Base: main
Labels:
Created: 2026-05-19T07:10:50Z

# What does this PR do?

This PR enables `ShieldGemma2ForImageClassification` to work with `transformers`’ standard `attn_implementation` argument, including `attn_implementation="sdpa"`.

The model is a thin wrapper around `Gemma3ForConditionalGeneration`, whose text and vision backbones already support SDPA. The missing top-level support flag caused `from_pretrained(..., attn_implementation="sdpa")` to fail during initialization.

Hi @ArthurZucker , please help review, thanks!

--- Comment by Rocketknight1 at 2026-05-19T10:40:13Z ---
cc @vasqu maybe? No rush!

--- Comment by github-actions[bot] at 2026-05-20T05:54:18Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: shieldgemma2

--- Comment by vasqu at 2026-05-19T14:54:02Z ---
Could there be even more flags we support? It depends on the underlying auto model so there might be even more. Doesn't necessarily have to be this PR

--- Comment by vasqu at 2026-05-19T14:54:51Z ---
Ig we never had proper tests for this in the first place, imo we should either make a full test suite OR just the integration tests tbh. This is not that useful by itself

--- Comment by vasqu at 2026-05-19T14:55:32Z ---
the test above essentially does the same now as we default to sdpa now, we should specify it above as well

--- Comment by stevhliu at 2026-05-20T05:20:04Z ---
would also be nice to add the appropriate badges, like sdpa, on shieldgemma2.md (see [here](https://github.com/huggingface/transformers/blob/ba06e3fbdf355c363ac067ebcda210017e90a852/docs/source/en/model_doc/gemma.md?plain=1#L19) for example)

--- Comment by YangKai0616 at 2026-05-20T06:06:33Z ---
Done. Added the flags for attention and badges for doc.

--- Comment by YangKai0616 at 2026-05-20T06:09:14Z ---
Done. Added test suite.

--- Comment by YangKai0616 at 2026-05-20T06:09:35Z ---
Done.


PULL REQUEST #46068: fix: adapt Whisper models to use self.loss_function with num_items_in_batch support
State: closed  |  Merged: False
Author: Ashutosh-177  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T06:28:43Z

## Summary

- Fixes gradient accumulation for Whisper by replacing the manual `CrossEntropyLoss` instantiation with `self.loss_function`, which supports the `num_items_in_batch` parameter introduced in #34191.
- Adds an explicit `num_items_in_batch` parameter to both `WhisperForConditionalGeneration.forward()` and `WhisperForCausalLM.forward()`.
- Sets `self.loss_type = "ForMaskedLM"` in both Whisper class `__init__` methods so the correct (no-shift) loss is used without touching the global `LOSS_MAPPING`.

## Changes

**`src/transformers/models/whisper/modeling_whisper.py`**

- `WhisperForConditionalGeneration.__init__`: sets `self.loss_type = "ForMaskedLM"`. Encoder-decoder models receive labels already aligned with decoder logits — no token shifting is needed.
- `WhisperForConditionalGeneration.forward()`: adds `num_items_in_batch` parameter; replaces manual `CrossEntropyLoss` block with `self.loss_function(...)`.
- `WhisperForCausalLM.__init__`: same `self.loss_type = "ForMaskedLM"` override, preserving the original no-shift behavior.
- `WhisperForCausalLM.forward()`: same treatment.

**`src/transformers/loss/loss_utils.py`**

- No global mapping changes — `LOSS_MAPPING["ForConditionalGeneration"]` remains `ForCausalLMLoss` to avoid affecting decoder-only models like `LlavaForConditionalGeneration` and `PaliGemmaForConditionalGeneration` that rely on label shifting.

## Behavior

- When `num_items_in_batch=None` (default): loss is identical to the previous `CrossEntropyLoss(reduction="mean")` call — no behavior change.
- When `num_items_in_batch` is provided by the Trainer: loss is normalized correctly across gradient accumulation steps, fixing the GA bug.

## Test plan

- [ ] Verify loss is unchanged when `num_items_in_batch=None`
- [ ] Verify loss is correctly normalized when `num_items_in_batch` is supplied
- [ ] Run existing Whisper tests: `pytest tests/models/whisper/ -x`

Closes #36119

--- Comment by github-actions[bot] at 2026-05-19T07:37:49Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: whisper

--- Comment by Ashutosh-177 at 2026-05-19T08:00:52Z ---
Opened PR #46068 that fixes this. All CI checks are passing — would appreciate a review.

--- Comment by Copilot at 2026-05-19T06:34:34Z ---
Changing `LOSS_MAPPING["ForConditionalGeneration"]` to `ForMaskedLMLoss` will alter the default `self.loss_function` for *all* `*ForConditionalGeneration` models. Several of these (e.g. `LlavaForConditionalGeneration`, `PaliGemmaForConditionalGeneration`) are decoder-only and rely on `ForCausalLMLoss` shifting behavior; switching to `ForMaskedLMLoss` will compute loss against unshifted labels and give incorrect training loss/gradients. A safer approach is to keep the mapping as causal and set `self.loss_type = "ForMaskedLM"` (or a new seq2seq-specific loss type) in encoder-decoder `ForConditionalGeneration` models like Whisper, or select the loss based on `config.is_encoder_decoder`.

--- Comment by Copilot at 2026-05-19T06:34:35Z ---
The new `num_items_in_batch` path changes loss normalization under gradient accumulation, but there’s no Whisper-specific unit test asserting (a) loss is unchanged when `num_items_in_batch=None` and (b) loss is correctly normalized when `num_items_in_batch` is provided. Adding a small regression test in `tests/models/whisper/test_modeling_whisper.py` would help prevent future GA regressions.

This issue also appears on line 1218 of the same file.


PULL REQUEST #46067: [loading] Fix base_model_prefix issues in conversions
State: open  |  Merged: False
Author: Cyrilvallez  |  Base: main
Labels:
Created: 2026-05-19T06:13:03Z

# What does this PR do?

Based on https://github.com/huggingface/transformers/pull/45996 (just created a new branch/PR to not mess directly with yours @yonigozlan just in case)

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T06:26:12Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46067). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by yonigozlan at 2026-05-20T16:16:00Z ---
This might break scope if we have nested models with the same base_model_prefix no? (e.g. model.model.) Can we try removing the base_model_prefix as a third try in `_scoped_match` instead?


PULL REQUEST #46066: Remove mask visualization tool from `masking_utils.py`
State: closed  |  Merged: True
Author: Cyrilvallez  |  Base: main
Labels:
Created: 2026-05-19T04:54:32Z

# What does this PR do?

We actually never use it. It should live somewhere else anyway in any case

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T05:07:21Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46066). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


Restore test utils fix

PULL REQUEST #46065: Restore test utils fix
State: closed  |  Merged: True
Author: remi-or  |  Base: main
Labels:
Created: 2026-05-19T04:49:28Z

This PR restore the change made in https://github.com/huggingface/transformers/pull/45351 that was overwritten in recent commits.

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T05:01:15Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46065). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46064: Fix grammar in core_model_loading comment
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:45:45Z

## What does this PR do?

Fixes two grammar issues in a comment in `src/transformers/core_model_loading.py` (around the PrefixChange weight-conversion fallback):

- `would otherwise add a unwanted prefix` -> `would otherwise add an unwanted prefix`
- `as we dont have any information` -> `as we don't have any information`

Comment-only change.

## Before submitting
- [x] Comment typo fix.


PULL REQUEST #46063: Fix typo in Qwen2.5-Omni docs example (cant -> can)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:45:27Z

## What does this PR do?

Fixes the same `cant` -> `can` typo in two code examples in `docs/source/en/model_doc/qwen2_5_omni.md` (mirrors the same fix in the qwen3 doc PR).

## Before submitting
- [x] Docs typo fix.


PULL REQUEST #46062: Fix article in ViTPose docs (a object detector -> an object detector)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:44:53Z

## What does this PR do?

Fixes article in `docs/source/en/model_doc/vitpose.md`: `It uses a object detector` -> `It uses an object detector` (object starts with a vowel sound).

Docs-only change.

## Before submitting
- [x] Docs typo fix.


PULL REQUEST #46061: Fix articles in add_new_model docs (a -> an for vowel-initial words)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:44:36Z

## What does this PR do?

Fixes three article errors in `docs/source/en/add_new_model.md` where `a` is used before vowel-initial words:

- `Is it a encoder, decoder, or encoder-decoder model?` -> `Is it an encoder, ...`
- `or a efficient integrated development environment` -> `or an efficient integrated ...`
- `Create a instance of `SimpleModel`` -> `Create an instance of ...`

Docs-only change.

## Before submitting
- [x] Docs typo fix.


PULL REQUEST #46060: Fix article in T5 and Whisper model docs (a encoder-decoder -> an encoder-decoder)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:44:03Z

## What does this PR do?

Both the T5 and Whisper model doc pages describe the model as `a encoder-decoder transformer`. Since `encoder` starts with a vowel sound, the article should be `an`.

Files updated:
- `docs/source/en/model_doc/t5.md`
- `docs/source/en/model_doc/whisper.md`

Docs-only change.

## Before submitting
- [x] Docs typo fix.


PULL REQUEST #46059: Fix article in task tutorials (load a evaluation -> load an evaluation)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels:
Created: 2026-05-19T04:43:49Z

## What does this PR do?

Five task tutorials share the same templated paragraph that starts with `You can quickly load a evaluation method`. Since `evaluation` starts with a vowel sound, the article should be `an`.

Files updated:
- `docs/source/en/tasks/summarization.md`
- `docs/source/en/tasks/multiple_choice.md`
- `docs/source/en/tasks/translation.md`
- `docs/source/en/tasks/token_classification.md`
- `docs/source/en/tasks/sequence_classification.md`

Docs-only change.

## Before submitting
- [x] Docs typo fix.


Fix mangled words in GOT-OCR2 abstract

PULL REQUEST #46058: Fix mangled words in GOT-OCR2 abstract
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels:
Created: 2026-05-19T04:41:26Z

## What does this PR do?

The paper abstract in `docs/source/en/model_doc/got_ocr2.md` contains two mangled words where a newline character appears to have been replaced with a literal `n` during a copy:

- `people'snusage` -> `people's usage`
- `opticalncharacters` -> `optical characters`

No other content changes; just splits the run-together words. Verified against the [arXiv abstract](https://arxiv.org/abs/2409.01704).

## Before submitting
- [x] Docs typo fix.


PULL REQUEST #46057: Fix typo in modular multimodal example (everytime -> every time)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:40:59Z

## What does this PR do?

Fixes a typo in the module docstring of `examples/modular-transformers/modular_multimodal2.py`: `add the prefix everytime` -> `add the prefix every time` ("everytime" is not a standard English word; the adverbial phrase is two words).

## Before submitting
- [x] Docstring typo fix.


PULL REQUEST #46056: Fix typo in SQuAD processor docstring (dependant -> dependent)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:40:41Z

## What does this PR do?

Fixes a typo in the docstring of `squad_convert_examples_to_features` in `src/transformers/data/processors/squad.py`: `model-dependant` -> `model-dependent`.

Docstring-only change.

## Before submitting
- [x] Docstring typo fix.


PULL REQUEST #46055: Fix typo in Falcon-H1 comments (dependant -> dependent)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels:
Created: 2026-05-19T04:40:24Z

## What does this PR do?

Fixes the same comment typo in both the modular and modeling files for Falcon-H1: `input dependant` -> `input dependent`. Comment-only change.

- `src/transformers/models/falcon_h1/modular_falcon_h1.py`
- `src/transformers/models/falcon_h1/modeling_falcon_h1.py`

Both files are kept in sync (modular + generated) per the modular models convention.

## Before submitting
- [x] Comment-only typo fix.

--- Comment by github-actions[bot] at 2026-05-19T04:41:24Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: falcon_h1


PULL REQUEST #46054: Fix typo in HiggsAudioV2 processor (lenghts -> lengths)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:40:06Z

## What does this PR do?

Fixes a typo in the local variable name inside `HiggsAudioV2Processor.__call__` in `src/transformers/models/higgs_audio_v2/processing_higgs_audio_v2.py`: `lenghts` -> `lengths`. The variable is only used locally within the same `if` block (three references), so no public API is affected.

## Before submitting
- [x] Trivial rename of a local variable (typo fix), no behaviour change.

--- Comment by github-actions[bot] at 2026-05-19T04:41:16Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: higgs_audio_v2


PULL REQUEST #46053: Fix typo in Qwen3-Omni-MoE docs example (cant -> can)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:39:25Z

## What does this PR do?

Fixes a typo in `docs/source/en/model_doc/qwen3_omni_moe.md`. The user-message text in two code examples reads `"What cant you hear and see in this video?"`. The intent (asking the model what it perceives in the clip) is the affirmative form `"What can you hear and see in this video?"`.

## Before submitting
- [x] This PR fixes a typo or improves the docs.


PULL REQUEST #46052: Fix typo in Voxtral docs example (speach -> speech)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:39:02Z

## What does this PR do?

Fixes a small typo in the Voxtral model docs at `docs/source/en/model_doc/voxtral.md`: the example user message reads `"Who's speaking in the speach"`, which should be `"speech"`.

## Before submitting
- [x] This PR fixes a typo or improves the docs.


PULL REQUEST #46051: Fix typos in input_outputs.py docstring (sytem, adresses)
State: closed  |  Merged: False
Author: AI-Safeter  |  Base: main
Labels: Code agent slop
Created: 2026-05-19T04:38:35Z

## What does this PR do?

Fixes two small typos in the `ContinuousBatchingAsyncIOs` class docstring in `src/transformers/generation/continuous_batching/input_outputs.py`:

- `CUDA sytem` -> `CUDA system`
- `static adresses` -> `static addresses`

Docstring-only change, no behaviour modified.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests)?
- [ ] Did you write any new necessary tests?


PULL REQUEST #46049: Fix Gemma4 generation from inputs_embeds and per_layer_inputs
State: closed  |  Merged: True
Author: Cyrilvallez  |  Base: main
Labels:
Created: 2026-05-19T02:48:14Z

# What does this PR do?

As per the title. If both are provided, `per_layer_inputs` must subsequently be dropped from inputs, see https://github.com/huggingface/transformers/pull/45927#issuecomment-4481586615 as well

--- Comment by github-actions[bot] at 2026-05-19T02:49:21Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma4

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T03:04:52Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46049). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by vasqu at 2026-05-19T07:20:33Z ---
Could this be involved into the else conditional above? I.e. what about the no cache cases

--- Comment by vasqu at 2026-05-19T07:21:24Z ---
Nit: We can also keep the ^ notation just for consistency

--- Comment by Cyrilvallez at 2026-05-19T07:23:41Z ---
Even without cache, we would need to recompute them based on full input_ids!

--- Comment by Cyrilvallez at 2026-05-19T07:24:04Z ---
Nop, this would be wrong. We only want to raise if BOTH are not None


Add TDT loss kernel

PULL REQUEST #46048: Add TDT loss kernel
State: open  |  Merged: False
Author: ebezzam  |  Base: main
Labels:
Created: 2026-05-19T02:32:47Z

# What does this PR do?

Add a kernel for faster TDT loss computation (and thus faster training).

Corresponding PR in `kernels-community`: https://github.com/huggingface/kernels-community/pull/882

cc @eustlb

--- Comment by github-actions[bot] at 2026-05-19T06:46:07Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: parakeet

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T07:01:27Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46048). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by ebezzam at 2026-05-19T06:46:36Z ---
Related comment: https://github.com/huggingface/transformers/pull/44171/changes#r3094638013

--- Comment by ebezzam at 2026-05-19T06:50:14Z ---
Should we also test for sigma != 0?


PULL REQUEST #46046: Add the other processors to auto-mappings
State: open  |  Merged: False
Author: zucchini-nlp  |  Base: main
Labels:
Created: 2026-05-19T00:50:17Z

# What does this PR do?

As per title, looks like there are no unexpected hidden bugs with automatic mapping creation, so I am adding the rest into it. NOTE: there were two models that had its own processor but was mapping to a different one, and now it is fixed (GlmImage and Wav2vec2-Bert)

The models can't be added, since there is no clear naming convention yet and it all depends on the model arch/intention/etc.

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T01:01:13Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46046). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by github-actions[bot] at 2026-05-19T01:48:07Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, granite_speech

--- Comment by zucchini-nlp at 2026-05-19T01:48:26Z ---
run-slow: auto, granite_speech

--- Comment by github-actions[bot] at 2026-05-19T01:49:38Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26071216366)

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

models: ["models/auto", "models/granite_speech"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-19T02:07:28Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26071216366)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [161a9242](https://github.com/huggingface/transformers/commit/161a92426cc0541d51bef755870eeebb856bcae4) | workflow commit (merge commit) |
| PR | [fb816ad0](https://github.com/zucchini-nlp/transformers/commit/fb816ad0fa396a6957f27a38d04b3422479e88eb) | branch commit (from PR) |
| main | [7d025c5f](https://github.com/huggingface/transformers/commit/7d025c5f5172ecb55d1599abf0d8d77ef404cd73) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !

--- Comment by zucchini-nlp at 2026-05-19T01:48:00Z ---
all feature extractors inherit from `SequenceFeatureExtractor` and use same naming for number of mels (feature-size)

I think this was simply missed when reviewing the PR, so I fixed it

--- Comment by vasqu at 2026-05-19T12:45:57Z ---
```suggestion
                matching_lines = re.findall(
                    rf'( {{8,12}}\(\s*"{old_lowercase_name}",.*?\),\n)(?: {{4,12}}\(|\])', block, re.DOTALL
                )
```
I guess hardcoding was faster 😂

--- Comment by vasqu at 2026-05-19T12:46:21Z ---
Let's make this a prive constant in this file and make a comment not to touch these

--- Comment by vasqu at 2026-05-19T12:47:05Z ---
can we add a comment to explain what happens here

--- Comment by vasqu at 2026-05-19T12:47:21Z ---
Love it!

--- Comment by vasqu at 2026-05-19T12:48:58Z ---
Imo could be refactored a bit for each file type to have one real function and these being wrapper like functions but no big deal

--- Comment by zucchini-nlp at 2026-05-20T02:44:05Z ---
reverting stuff that I added in the past for prev auto mapping. So basically, just do whatever it was doing prev, without conditional blocks for image/video processor

--- Comment by zucchini-nlp at 2026-05-20T02:45:48Z ---
yeah, a lot of similarity between the fn. I was just doing the fastest way 😆  Lemme do it next week or once back to Paris


PULL REQUEST #46044: Fix remaining RAG doc examples that crash on current transformers
State: closed  |  Merged: True
Author: Sriniketh24  |  Base: main
Labels:
Created: 2026-05-18T23:43:42Z

## Summary

Follow-up to #46035 (merged), which fixed issue 3 of 3 from #46015. This PR addresses the remaining two issues:

**Issue 1 — First doc example crashes with `ValueError`:**
`RagRetriever.from_pretrained("facebook/dpr-ctx_encoder-single-nq-base", ...)` passes a DPR checkpoint to `RagConfig`, which lacks the required `question_encoder` and `generator` sub-configs. Fixed by using `"facebook/rag-sequence-nq"` which ships a proper `RagConfig`.

**Issue 1 (cont.) — `prepare_seq2seq_batch` removed:**
`tokenizer.prepare_seq2seq_batch()` no longer exists. Replaced with the standard `tokenizer()` call.

**Issue 2 — Wrong model for `RagSequenceForGeneration`:**
The examples used `"facebook/rag-token-nq"` with `RagSequenceForGeneration`, but the consistent checkpoint is `"facebook/rag-sequence-nq"`.

### Changes
- `docs/source/en/model_doc/rag.md`: Fix model IDs, replace deprecated tokenizer call, fix formatting
- `src/transformers/models/rag/retrieval_rag.py`: Fix model IDs in all 4 `RagRetriever` docstring examples

### Coordination
- Issue thread: #46015 (comment from reporter confirming issues 1 & 2 remain after #46035)
- No duplicate open PRs found
- AI assistance was used (see disclosure below)

closes: #46015

---

AI-assisted: Yes — Claude Code (Opus 4.6) was used to identify the fixes and draft this PR. All changes were reviewed by the human submitter.

--- Comment by github-actions[bot] at 2026-05-18T23:44:54Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: rag

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T02:17:09Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46044). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46043: [Gemma 4] Adds support to batches with mixed samples with only images and only text
State: closed  |  Merged: False
Author: gabrielspmoreira  |  Base: main
Labels:
Created: 2026-05-18T23:25:12Z

Currently, if `Gemma4Processor.__call__()` is called for a batch where some samples have images and some don't have (e.g. text-only samples), it raises an exception.
This PR adds support to calling `Gemma4Processor` with a batch containing samples with image mixed with samples containing only text.

## Who can review?
 @Cyrilvallez @yonigozlan

--- Comment by github-actions[bot] at 2026-05-18T23:26:21Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma4

--- Comment by github-actions[bot] at 2026-05-18T23:31:06Z ---
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46043&sha=4d8f6d

--- Comment by zucchini-nlp at 2026-05-19T00:43:02Z ---
Found it, see pls https://github.com/huggingface/transformers/issues/40263 which was resolved. If it doesn't work for gemma4, ping me and I will check what went wrong. Ideally we want a general fix, not per model

--- Comment by gabrielspmoreira at 2026-05-19T11:33:32Z ---
Thanks for the review @zucchini-nlp . You are right in your example, passing `[ ]` placeholder for empty images is a valid way to have text-only examples in a batch with image samples. I have tested and it works.
So I am closing this PR, and have opened a new PR #46075 with a new test to demonstrate/ensure this behaviour.

--- Comment by zucchini-nlp at 2026-05-19T00:39:00Z ---
iirc we had a PR allowing an empty list for samples with no images. So if users want to pass mixed batch, it is on them to correctlly format and pass `images` list. Otherwise auto-inferring is not reliable

So you should be able to pass `images=[[im1, im2], [], [im3]]` for bs=3 and second sample is only text. Can you check if this works ootb because it was merged and supposed to work, unless PR got stale (lemme look for it)


PULL REQUEST #46042: docs(readme): use canonical `huggingface.co` domain in prose links
State: closed  |  Merged: True
Author: kiwigitops  |  Base: main
Labels:
Created: 2026-05-18T23:18:34Z

Two README prose links pointed to `huggingface.com` instead of `huggingface.co`. `.com` does redirect to `.co`, but every other link in the README (and across the org's docs) uses `.co`, so this is an inconsistency in the user-facing prose.

```diff
-There are over 1M+ Transformers [model checkpoints](https://huggingface.co/models?library=transformers&sort=trending) on the [Hugging Face Hub](https://huggingface.com/models) you can use.
+There are over 1M+ Transformers [model checkpoints](https://huggingface.co/models?library=transformers&sort=trending) on the [Hugging Face Hub](https://huggingface.co/models) you can use.
```

```diff
-Explore the [Hub](https://huggingface.com/) today to find a model and use Transformers to help you get started right away.
+Explore the [Hub](https://huggingface.co/) today to find a model and use Transformers to help you get started right away.
```

(Left the badge link on line 28 alone in case the `.com` there is deliberate; happy to update that too if a maintainer prefers.)

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T02:16:27Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46042). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


Fix post processing RF-DETR

PULL REQUEST #46041: Fix post processing RF-DETR
State: closed  |  Merged: True
Author: yonigozlan  |  Base: main
Labels:
Created: 2026-05-18T22:17:19Z

# What does this PR do?

The post processing used for RF-DETR was the same as the one for DETR, which is incorrect. We now use similar post-processing for both detection and segmentation as the original repo.
The preprocessing also introduced some differences with the original one as the original preprocessing rescale then resize, and we usually do the opposite in Transformers. We are now aligned with the original repo, and the remaining very small differences are due to differences in how we convert the images from pil to torch (pil_to_tensor then scale compared to to_tensor in the original repo), although this shouldn't affect the quality of the predictions.

Cc @molbap @SkalskiP

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T22:28:18Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46041). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by yonigozlan at 2026-05-19T00:47:50Z ---
run-slow: rf_detr

--- Comment by github-actions[bot] at 2026-05-19T00:49:08Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26069238007)

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

models: ["models/rf_detr"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-19T01:03:26Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26069238007)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [02df063c](https://github.com/huggingface/transformers/commit/02df063ca930675f7cbe03bb54c637eedfc26c4a) | workflow commit (merge commit) |
| PR | [14dd7eb7](https://github.com/yonigozlan/transformers/commit/14dd7eb7835f8290c7490d4d73a7b9c6a2ba2b9a) | branch commit (from PR) |
| main | [73d91596](https://github.com/huggingface/transformers/commit/73d9159697a851c85623d0f03fcfbdd863d38975) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !

--- Comment by github-actions[bot] at 2026-05-19T16:43:33Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, lw_detr, rf_detr

--- Comment by yonigozlan at 2026-05-19T16:50:39Z ---
run-slow: rf_detr, lw_detr

--- Comment by github-actions[bot] at 2026-05-19T16:52:00Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26111910826)

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

models: ["models/lw_detr", "models/rf_detr"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-19T17:17:54Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26111910826)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [c8038f4d](https://github.com/huggingface/transformers/commit/c8038f4d13b8f8a1f3467c0bf842498c6c6656e2) | workflow commit (merge commit) |
| PR | [80832327](https://github.com/yonigozlan/transformers/commit/80832327d89cb47e7cf7f55df4955fa327b8d2a9) | branch commit (from PR) |
| main | [b797f0d4](https://github.com/huggingface/transformers/commit/b797f0d4c74ded2e368bbc971c4aaca9004318cc) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !

--- Comment by molbap at 2026-05-19T13:02:51Z ---
why is this removed for my information?

--- Comment by molbap at 2026-05-19T13:05:11Z ---
is the invalid_mask still used, since removed below?

--- Comment by yonigozlan at 2026-05-19T15:14:54Z ---
Actually I was wrong earlier, this can still be useful in training, adding it back


PULL REQUEST #46040: fix: prevent OOM/hang in smart_resize for large images
State: closed  |  Merged: False
Author: poojansatani  |  Base: main
Labels: Code agent slop
Created: 2026-05-18T20:19:48Z

# What does this PR do?

## Problem
Qwen2-VL and Qwen2.5-VL models use `smart_resize` which has no
protection against extremely large images. High-resolution images
(e.g. bee.jpg at 18MP) generate 10,000+ visual tokens causing
infinite hang or OOM on consumer GPUs (tested on T4).

Fixes #45753

## Motivation
In #46007, I added a docs-level fix — setting `min_pixels` and
`max_pixels` in the processor example along with a WARNING note.

During review, @stevhliu noted it would be nice to have a more
broad/general fix, and @zucchini-nlp pointed out this affects
all models using `smart_resize` — not just one.

This PR addresses the root cause directly in `smart_resize` so
all models benefit automatically without needing per-model doc fixes.

## Solution
Three-layer protection added to `smart_resize` in
`image_processing_qwen2_vl.py`:

1. **Auto GPU VRAM detection** - Automatically lowers `max_pixels`
   based on available GPU memory to prevent OOM before it happens
2. **Token count warning** - Warns user when image will generate
   >5000 visual tokens so they can act before inference hangs
3. **Hard limit error** - Raises clear `ValueError` when image
   would exceed 16384 tokens instead of silently hanging

## Testing
- `smart_resize(1000, 1000)` → Normal resize
- `smart_resize(3000, 3000)` → UserWarning
- `smart_resize(10000, 10000)` → ValueError

## Before submitting
- [x] Did you read the [[contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request)](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/)](https://discuss.huggingface.co/)? #45753 #46007

## Who can review?
@zucchini-nlp @stevhliu

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

Fixes # (issue)

## Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
**we ask that new users do not submit pure code agent PRs** at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read [`CONTRIBUTING.md`](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).

- [x] I confirm that this is not a pure code agent PR.

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

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc
- kernels: @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->

--- Comment by github-actions[bot] at 2026-05-18T20:20:59Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: qwen2_vl

--- Comment by zucchini-nlp at 2026-05-19T00:44:16Z ---
Do not open identical PRs from the same account please, I see https://github.com/huggingface/transformers/pull/46007 is already open

--- Comment by poojansatani at 2026-05-19T03:31:27Z ---
see  @zucchini-nlp, these are two different fixes:

- #46007 adds a doc-level warning (min_pixels/max_pixels in processor example)
- This PR (#46040) fixes the root cause directly in `smart_resize` with:
  1. Auto GPU VRAM detection
  2. Token count warning
  3. Hard limit ValueError

As you mentioned in #46007 review — "would be nice to have a more broad/general fix" — this PR is exactly that broader fix.

Could you please reopen? Happy to make any changes needed.


PULL REQUEST #46039: [`Kernels`] Sync and add SwigluMLP + CausalLMLoss
State: open  |  Merged: False
Author: vasqu  |  Base: main
Labels:
Created: 2026-05-18T17:49:15Z

WIP

Need to fix the upstream init of the kernel - see https://gist.github.com/vasqu/09cc54006faae94460fe6470bc638ed8
- We had `_` instead of `-` so it pointed to the wrong repo lmao
- We have a few validation strictness issues, e.g.
    - Match signature when fn
    - No init for module

--- Comment by github-actions[bot] at 2026-05-18T17:50:35Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: llama

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T18:01:55Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46039). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by vasqu at 2026-05-19T16:09:28Z ---
Yep, will do :saluting_face: thinking about memory benchmarks mostly since this is the key behind the new loss kernel from liger


Widen tols for float16/bfloat16

PULL REQUEST #46036: Widen tols for float16/bfloat16
State: open  |  Merged: False
Author: Rocketknight1  |  Base: main
Labels:
Created: 2026-05-18T15:06:54Z

We have [some flaky tests](https://app.circleci.com/pipelines/github/huggingface/transformers/175084/workflows/94a9c675-ec4a-4b6c-aa39-f21b9bbb53bb/jobs/2314705) caused by bfloat16 + narrow tolerances . This PR just modifies the checks so that we use wider tolerances when the test isn't `float32`.

--- Comment by Rocketknight1 at 2026-05-18T15:07:25Z ---
cc @ydshieh @tarekziade

--- Comment by github-actions[bot] at 2026-05-18T15:08:14Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma3n

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T15:22:00Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46036). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46035: Fix AttributeError in RAG generate() for missing config fields
State: closed  |  Merged: True
Author: Sriniketh24  |  Base: main
Labels:
Created: 2026-05-18T14:41:15Z

Fixes #46015.

## What this does

`RagSequenceForGeneration.generate()` crashes with `AttributeError: 'RagConfig' object has no attribute 'num_return_sequences'` because the config never defined `num_beams` or `num_return_sequences`.

**Fix (2 lines in `modeling_rag.py`):** Uses `getattr` with a default of 1 (matching the documented defaults in the `generate` docstring) instead of direct attribute access.

Adding these fields directly to `RagConfig` was not viable — it triggers the generation utils validation error (`"You have modified the pretrained model configuration to control generation"`), since generation params belong in `generation_config`, not the model config.

Also removes two stale references to `examples/rag/use_own_knowledge_dataset.py` in `retrieval_rag.py` docstrings, which no longer exists in the repo.

## Coordination

- Issue discussion and approval: https://github.com/huggingface/transformers/issues/46015#issuecomment-new
- No existing open PR addresses this fix.

## Tests run

```python
from transformers import AutoConfig
config = AutoConfig.from_pretrained("facebook/rag-token-nq")
# Previously: AttributeError: 'RagConfig' object has no attribute 'num_return_sequences'
# Now: resolves to default of 1 via getattr
assert getattr(config, "num_return_sequences", 1) == 1
```

```bash
ruff check src/transformers/models/rag/  # All checks passed
ruff format --check src/transformers/models/rag/  # Already formatted
```

Note: `pytest tests/models/rag/test_modeling_rag.py` segfaults on macOS ARM due to `faiss-cpu` — this is a pre-existing environment issue, not related to this change.

AI assistance (Claude Code) was used; all changes were reviewed and tested manually.

--- Comment by github-actions[bot] at 2026-05-18T14:42:36Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: rag

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T15:48:56Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46035). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by someone282801 at 2026-05-18T17:15:15Z ---
Hi, thank you for take look to one part of https://github.com/huggingface/transformers/issues/46015 and fix 1 of possibly bunch of issues this could have.

The issue of not defined attributes is gone due to default usage of 1 in this case but this not fixes main points as reference to an up to date example instead of removing reference pointed in.

We are supposed to be in this state unless i am missing something as the new label on main issue seems to be (Good First Issue), i don't know what does it means but could be related to fix 1 of 3 things maybe ?

1. First example provided crashes directly. - Not fixed, same crash happens + documentation wasn't updated taking in count that `tokenizer.prepare_seq2seq_batch` not exists.
2. Second example based in custom dataset, referencing to a not defined path. - Can't be considered as resolved because not provided required information as up to date way to have a custom dataset with embeddings.
3. Third customized script for reveal internal non existent properties from RAGConfig. - Resolved.


Fix outdated RAG documentation example

PULL REQUEST #46034: Fix outdated RAG documentation example
State: closed  |  Merged: False
Author: 0Sh1khar  |  Base: main
Labels:
Created: 2026-05-18T14:39:35Z

## Summary

Updates outdated RAG documentation example:

* replaces deprecated `prepare_seq2seq_batch` usage
* uses `facebook/rag-sequence-nq` for `RagRetriever.from_pretrained`

This resolves the original RAG config instantiation error from the example.

Tested locally on current Transformers version.

--- Comment by stevhliu at 2026-05-19T02:05:28Z ---
closing in favor of #46044 as the fix is more comprehensive


[`HRM Text`] Add integration tests

PULL REQUEST #46033: [`HRM Text`] Add integration tests
State: closed  |  Merged: True
Author: vasqu  |  Base: main
Labels:
Created: 2026-05-18T13:45:09Z

As per title

--- Comment by vasqu at 2026-05-18T13:45:32Z ---
run-slow: hrm_text

--- Comment by github-actions[bot] at 2026-05-18T13:46:24Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: hrm_text

--- Comment by github-actions[bot] at 2026-05-18T13:47:01Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26037467636)

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

models: ["models/hrm_text"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-18T13:54:27Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26037467636)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [4b87133b](https://github.com/huggingface/transformers/commit/4b87133bf22f9679280243d1a8b9f2174b7a06ba) | workflow commit (merge commit) |
| PR | [8fd5e664](https://github.com/huggingface/transformers/commit/8fd5e664c8827513de51ae884915252ad2c716bf) | branch commit (from PR) |
| main | [ca80e957](https://github.com/huggingface/transformers/commit/ca80e95782220b009afbeec6bf864258a67d988b) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T13:58:23Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46033). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by vasqu at 2026-05-18T14:02:49Z ---
cc @ydshieh just that you are in the loop


Support Granite Speech NAR (NLE)

PULL REQUEST #46031: Support Granite Speech NAR (NLE)
State: open  |  Merged: False
Author: avihu111  |  Base: main
Labels: New model, Audio
Created: 2026-05-18T12:52:13Z

# What does this PR do?

Adds **GraniteSpeechNar** — a non-autoregressive LLM-based ASR model.
Unlike the autoregressive `GraniteSpeech` model (which uses `GenerationMixin`), this model performs non-autoregressive transcript editing, and refines the speech encoder transcript using a bidirectionally-augmented LLM.
GraniteSpeechNar consists of an encoder (conformer), a q-former projector, and a bidirectional LLM (non-causal mask).
The paper is based on the following paper: [NLE: Non-autoregressive LLM-based ASR by Transcript Editing](https://arxiv.org/abs/2603.08397)

It's a bit different than most of the models in the hub (due to its non-autoregressive nature), but achieves high transcription throughput and competative accuracy.
It is ranked 3rd on the [Open ASR Leaderboard](https://huggingface.co/spaces/hf-audio/open_asr_leaderboard) with faster inference speeds. The speedups are even more significant with a batch size of 1 (e.g. in latency critical real-time settings).

The model is available with bundled code here:
https://huggingface.co/ibm-granite/granite-speech-4.1-2b-nar

## Key design decisions
- Inherit Granite classes, changing the attention pattern to bidirectional.
- Inherit the base conformer encoder from GraniteSpeech, which is shared.
- `output_encoder_logits=False` (default): Free the encoder BPE logits tensor (~T/4 × 100K) to reduce peak memory. Pass `True` to retain it.
- Flat sequence batching: All batch items are concatenated into `[1, N_total, D]` with per-sample position resets, avoiding padding waste on variable-length audio.
- CTC collapse (deduplication and blank removal) is done in the model, decoding is done in the processor.
- Supports finetuning the model - exposes the editing loss, encoder loss and the copying-regularization loss described in the paper above.

## 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 (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).
- [x] Did you write any new necessary tests?

## Who can review?
- audio models: @eustlb @ebezzam @vasqu
Thanks!
CC: @gsaon

--- Comment by github-actions[bot] at 2026-05-21T09:54:35Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, granite_speech_nar

--- Comment by github-actions[bot] at 2026-05-21T10:11:17Z ---
View the CircleCI Test Summary for this PR:

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


Init the actual tensor, not a copy

PULL REQUEST #46030: Init the actual tensor, not a copy
State: closed  |  Merged: True
Author: Rocketknight1  |  Base: main
Labels:
Created: 2026-05-18T11:54:19Z

Our weight init code did `init.normal_(module.weight.float())` which is broken because it makes a `float32` copy of the tensor and then initializes that. It worked when the model was `float32` already, because then the dtype conversion was a no-op.

cc @arthurzucker since this snuck in during #45643!

Hopefully fixes #46002

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T12:06:24Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46030). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46029: [MultimodalLM] add language_model to the get/set_input_embeddings logic
State: closed  |  Merged: True
Author: eustlb  |  Base: main
Labels:
Created: 2026-05-18T10:43:36Z

# What does this PR do?

As per-title, since we're checking self.model for encoder/decoder models, IMO there is no reason **not** to do it for ALM/VLMs too.

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T10:54:28Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46029). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by eustlb at 2026-05-18T12:50:33Z ---
run-slow: aria, audioflamingo3, aya_vision, blip_2, cohere2_vision, deepseek_vl, deepseek_vl_hybrid, ernie4_5_vl_moe, exaone4_5, fast_vlm, florence2, fuyu, gemma3, gemma3n, gemma4, glm46v

--- Comment by github-actions[bot] at 2026-05-18T12:51:58Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26034586115)

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

models: ["models/aria", "models/audioflamingo3", "models/aya_vision", "models/blip_2", "models/cohere2_vision", "models/deepseek_vl", "models/deepseek_vl_hybrid", "models/ernie4_5_vl_moe", "models/exaone4_5", "models/fast_vlm", "models/florence2", "models/fuyu", "models/gemma3", "models/gemma3n", "models/gemma4", "models/glm46v"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-18T16:15:34Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26034586115)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [6f3de50d](https://github.com/huggingface/transformers/commit/6f3de50dcff56386664cfa67c8a5170bb481061b) | workflow commit (merge commit) |
| PR | [09c86a93](https://github.com/huggingface/transformers/commit/09c86a931044179b77e1e81f9a1c54cf1930906a) | branch commit (from PR) |
| main | [ca80e957](https://github.com/huggingface/transformers/commit/ca80e95782220b009afbeec6bf864258a67d988b) | base commit (on `main`) |

### Model CI Report

❌ **[1 new failed tests from this PR](https://huggingface.co/datasets/hf-internal-testing/transformers_pr_ci/raw/b43a18c497e9d26e28e78eb33dee21010e72f330/2026-05-18/runs/34805-26034586115/ci_results_run_models_gpu/new_failures_with_bad_commit.json)** 😭

- [gemma4](https://github.com/huggingface/transformers/actions/runs/26034586115/job/76530316664):
    tests/models/gemma4/test_modeling_gemma4.py::Gemma4IntegrationTest::test_export_text_only (❌ ⟹ ❌)

--- Comment by vasqu at 2026-05-18T16:20:51Z ---
It's the process number :melting_face: so all good it seems

--- Comment by eustlb at 2026-05-18T16:48:25Z ---
Perfect! merging

--- Comment by github-actions[bot] at 2026-05-18T17:37:02Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: aria, audioflamingo3, aya_vision, blip_2, cohere2_vision, deepseek_vl, deepseek_vl_hybrid, ernie4_5_vl_moe, exaone4_5, fast_vlm, florence2, fuyu, gemma3, gemma3n, gemma4, glm46v

--- Comment by github-actions[bot] at 2026-05-18T17:47:01Z ---
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46029&sha=11f297

--- Comment by vasqu at 2026-05-18T17:51:47Z ---
Flaky test merged myself :hugs:

--- Comment by eustlb at 2026-05-18T10:46:52Z ---
⚠ **this is not related to the addition of `language_model` to EmbeddingAccessMixin**. This was already redundant as get/set_input_embeddings already checks self.model

--- Comment by vasqu at 2026-05-18T14:09:20Z ---
Not on you but could you put a 5) below (similar to the set method)

--- Comment by eustlb at 2026-05-18T14:51:02Z ---
ofc!

--- Comment by zucchini-nlp at 2026-05-19T00:32:20Z ---
actually this is same as `self.get_decoder()` for all MLLMs, so we could

```
# Same as base model, we can check if embedding is inside a decoder for
# enc-dec models and for MLLMs
decoder = self.get_decoder()
embedding_layer = decoder.embedding_layer
```


PULL REQUEST #46028: Support FA2 flash_attn_with_kvcache for XPU continuous batching
State: open  |  Merged: False
Author: YangKai0616  |  Base: main
Labels:
Created: 2026-05-18T10:38:02Z

# What does this PR do?

XPU now supports `flash_attn_with_kvcache` in `kernels-community/flash-attn2`. This PR enables the relevant path in CB. `transformers` pipeline test results:
```
| label                  |   samples |   avg_in |   max_new |   time (s) |   tokens |   tok/s |   mem (GB) |
|------------------------|-----------|----------|-----------|------------|----------|---------|------------|
| fast_decode_off_varlen |         2 |      512 |      1024 |      59.91 |     2048 |   34.18 |       9.09 |
| fast_decode_on_kvcache |         2 |      512 |      1024 |      44.9  |     2048 |   45.61 |       9.09 |
fast_decode_on_kvcache speedup over fast_decode_off_varlen: 1.33x
|------------------------|-----------|----------|-----------|------------|----------|---------|------------|
| fast_decode_off_varlen |         8 |      512 |      1024 |      60.76 |     8192 |  134.82 |       9.09 |
| fast_decode_on_kvcache |         8 |      512 |      1024 |      35.11 |     8192 |  233.33 |       9.09 |
fast_decode_on_kvcache speedup over fast_decode_off_varlen: 1.73x
| fast_decode_off_varlen |         8 |     2048 |       512 |      31.04 |     4096 |  131.94 |       9.09 |
| fast_decode_on_kvcache |         8 |     2048 |       512 |      22.39 |     4096 |  182.92 |       9.09 |
fast_decode_on_kvcache speedup over fast_decode_off_varlen: 1.39x
```
Model: `Qwen/Qwen3-0.6B`.
Device: `B60`.

Hi @ArthurZucker , pls help review, thanks!

--- Comment by YangKai0616 at 2026-05-20T07:07:31Z ---
Hi @vasqu , could you help review this PR related to attention, thank you!


PULL REQUEST #46027: docs: sync legacy ACL anthology URLs and update metrics across i18n READMEs
State: closed  |  Merged: True
Author: irfaan101  |  Base: main
Labels:
Created: 2026-05-18T08:59:56Z

# What does this PR do?

Following up on PR #46001, this PR ensures documentation consistency across the international translations in the `i18n/` directory.

- **URL Synchronization:** Synchronized legacy ACL Web anthology URLs with the current official `aclanthology.org` domain across all 17 translated README files (affecting text hyperlinks and BibTeX blocks).
- **Metric Updates:** Updated the core architecture metric from "Dozens" to "Hundreds" in Hindi (`दर्जनों` ➡ `सैकड़ों`) and Urdu (`درجنوں` ➡ `سینکڑوں`) to match the main documentation, ensuring correct regional grammar.

Fixes # (Not applicable - Translation and consistency follow-up)

## Code Agent Policy

- [x] I confirm that this is not a pure code agent PR.

## 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?
- [x] Did you make sure to update the documentation with your changes?

## Who can review?

cc: @stevhliu

--- Comment by HuggingFaceDocBuilderDev at 2026-05-19T01:00:31Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46027). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46026: fix: add pickle support to _LazyConfigMapping for spawn multiprocessing
State: open  |  Merged: False
Author: kfojcik-intel  |  Base: main
Labels:
Created: 2026-05-18T08:12:12Z

# What does this PR do?

Adds pickle serialization support to _LazyConfigMapping (and _LazyAutoMapping) in transformers/models/auto/configuration_auto.py.

Currently, _LazyConfigMapping cannot be pickled because its __init__ requires a positional mapping argument. When Python's pickle protocol attempts to reconstruct the object, it calls cls() with no arguments, resulting in:

This breaks any downstream library that uses spawn multiprocessing and needs to serialize objects referencing CONFIG_MAPPING or similar auto-mapping globals. In particular, this affects vLLM on Intel XPU (and potentially other accelerators), where spawn is the only supported multiprocessing method.

Changes
Add __reduce__ method to _LazyConfigMapping that serializes the mapping as a plain dict

## Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
**we ask that new users do not submit pure code agent PRs** at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read [`CONTRIBUTING.md`](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).

- [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://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc
- kernels: @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->

--- Comment by github-actions[bot] at 2026-05-18T08:13:15Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto

--- Comment by github-actions[bot] at 2026-05-18T08:32:08Z ---
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46026&sha=917f5c

--- Comment by Rocketknight1 at 2026-05-18T12:26:01Z ---
Hmmn, I see the need here, but I'm a bit worried because this drops things like the `_extra_content` attribute, used for registering custom code models. I feel like this might also have some other weird side effects, but it'll need a deep dive to figure out exactly which ones

--- Comment by Rocketknight1 at 2026-05-18T12:52:45Z ---
cc @hmellor maybe since it affects vLLM, but it might be more of a weird core issue that needs a deep dive and a few finicky dunder methods


Add hrm text

PULL REQUEST #46025: Add hrm text
State: closed  |  Merged: True
Author: abcd1927  |  Base: main
Labels: New model
Created: 2026-05-18T08:06:44Z

# What does this PR do?

Adds the HRM-Text architecture (Hierarchical Reasoning Model — autoregressive language-modeling variant) by Sapient Intelligence. HRM-Text uses two transformer stacks (H = high-level / slow, L = low-level / fast) traversed in a nested recurrence over the same input embeddings, giving effectively unbounded compute depth at bounded parameter count.

The 1B base checkpoint is published at [`sapientinc/HRM-Text-1B`](https://huggingface.co/sapientinc/HRM-Text-1B).

Companion review thread (5 rounds of feedback addressed): https://github.com/huggingface/new-model-addition-hrm/pull/2.

## Architectural traits

- Dual H/L transformer stacks, hierarchical recurrence (`H_cycles × (L_cycles + 1)` traversals over the same input)
- PrefixLM mask via `token_type_ids` (paligemma pattern; bidirectional inside the prefix block, causal elsewhere)
- Per-head sigmoid output gate applied to the attention output before `o_proj` (Qwen3-Next-style)
- Parameterless RMSNorm (inherits `NanoChatRMSNorm`)
- `L_bp_cycles` k-step gradient routing — training-time only, no effect at inference
- KV-cache slot expansion across the recurrent invocations (`num_layers_per_stack × H_cycles × (L_cycles + 1)` slots)
- Conditional FlashAttention support: rejected when `config.prefix_lm=True` (FA cannot represent the 4-D mask overlay), allowed when `prefix_lm=False`

## Files

- `src/transformers/models/hrm_text/{configuration,modeling,modular}_hrm_text.py`
- `src/transformers/models/hrm_text/__init__.py`
- `src/transformers/conversion_mapping.py` (entry for legacy `attn.gqkv_proj` → `self_attn.{gate,q,k,v}_proj` split + `attn.o_proj` → `self_attn.o_proj` rename + `mlp.gate_up_proj` → `mlp.{gate,up}_proj` split)
- `docs/source/en/model_doc/hrm_text.md`
- `tests/models/hrm_text/test_modeling_hrm_text.py`

## Before submitting

- [x] Read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md)
- [x] Tests added / updated (`tests/models/hrm_text/`)
- [x] Documentation added (`docs/source/en/model_doc/hrm_text.md`)
- [x] Pre-commit / `make fix-repo` passes (verified locally and on H100×8 devbox)

## Test commands run

- `pytest tests/models/hrm_text/` → 146 / 0 failed locally (Mac M4)
- `pytest tests/models/hrm_text/` on H100×8 devbox → 154 / 0 failed (default), 167 / 0 failed (`RUN_SLOW=1`)
- `make fix-repo` → no diff on HRM-Text-owned files; tree-wide ruff catch-up bundled in commit `3f535ed05e`
- End-to-end smoke on the released 1.2B base checkpoint (loaded via `trust_remote_code=True` and via in-tree path; logits bitwise identical):
  - `z_L_init` Parameter `requires_grad=False`, 885 unique trained values in `[-3.02, 3.00]`
  - Greedy generation: `<|im_start|><|object_ref_start|>The capital of France is<|im_end|>` → `Paris<|box_end|>`
  - SDPA vs FA-2 (`prefix_lm=False`) top-1 100% match

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T08:34:39Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46025). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by github-actions[bot] at 2026-05-18T08:42:59Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, hrm_text

--- Comment by vasqu at 2026-05-18T08:50:11Z ---
run-slow: hrm_text

--- Comment by github-actions[bot] at 2026-05-18T08:51:30Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26023261943)

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

models: ["models/hrm_text"]
quantizations: []

--- Comment by github-actions[bot] at 2026-05-18T09:02:28Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26023261943)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [7bc14b27](https://github.com/huggingface/transformers/commit/7bc14b27f4118477b4183fb6b7e776670ce32961) | workflow commit (merge commit) |
| PR | [8895dcb0](https://github.com/abcd1927/transformers/commit/8895dcb070dd08f3e91f522fd1eddd1302760d61) | branch commit (from PR) |
| main | [461d4288](https://github.com/huggingface/transformers/commit/461d42880e90cfe6ed541f7dd3bc7ae16b83d86e) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !


PULL REQUEST #46024: fix(llama4): align MoE interface for EP/TP compatibility
State: open  |  Merged: False
Author: Chao1Han  |  Base: main
Labels:
Created: 2026-05-18T08:00:06Z

# What does this PR do?
Llama4 router and experts use a non-standard interface that is incompatible with the EP/TP hooks in tensor_parallel.py, causing ValueError when running with device_map or tensor parallelism.

- Router now returns (router_logits, top_k_weights, top_k_index) matching what RouterParallel expects
- Experts forward takes (hidden_states, top_k_index, top_k_weights) matching MoeTensorParallelExperts hooks
- MoE forward simplified accordingly
<!--
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 -->

## reproduce the issue
```python
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-4-Scout-17B-16E", tp_plan="auto")
# ValueError at RouterParallel._prepare_output_fn
```

## Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
**we ask that new users do not submit pure code agent PRs** at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read [`CONTRIBUTING.md`](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).

- [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).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc
- kernels: @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->

--- Comment by github-actions[bot] at 2026-05-18T08:01:17Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: llama4

--- Comment by Chao1Han at 2026-05-18T08:19:07Z ---
Hi @Rocketknight1. Could you please take a look at this PR? I do have a requirement to run EP with Llama 4, but the current implementation of the Llama 4 router does not match the assumptions made by `MoeTensorParallelExperts`.
I believe the current test coverage is already sufficient to ensure that this change will not introduce any BC issues. If needed, I can add an EP test case as well.

--- Comment by Rocketknight1 at 2026-05-18T13:41:18Z ---
cc @cyrilvallez for TP I think!

--- Comment by Chao1Han at 2026-05-20T05:39:08Z ---
Hi @Cyrilvallez . Could you please take a look?


chore(linter): fix for rules 16-17-18

PULL REQUEST #46023: chore(linter): fix for rules 16-17-18
State: open  |  Merged: False
Author: tarekziade  |  Base: main
Labels:
Created: 2026-05-18T05:16:10Z

# What does this PR do?

Adds support for rules 16/17/18 that will be part of the next mlinter release  (the branch switches on its main branch temporarily)

The model fixes are mechanical, done through automation.

--- Comment by tarekziade at 2026-05-18T05:22:49Z ---
run-slow: albert, align, altclip, autoformer, bit, blt, bridgetower, chinese_clip, clap, clip, clipseg, clvp, colmodernvbert, colpali, colqwen2, conditional_detr

--- Comment by github-actions[bot] at 2026-05-18T05:24:07Z ---
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26015124997)

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

models: ["models/albert", "models/align", "models/altclip", "models/autoformer", "models/bit", "models/blt", "models/bridgetower", "models/chinese_clip", "models/clap", "models/clip", "models/clipseg", "models/clvp", "models/colmodernvbert", "models/colpali", "models/colqwen2", "models/conditional_detr"]
quantizations: []

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T05:27:39Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46023). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by github-actions[bot] at 2026-05-18T05:43:07Z ---
## CI Results
[Workflow Run ⚙](https://github.com/huggingface/transformers/actions/runs/26015124997)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [64943dac](https://github.com/huggingface/transformers/commit/64943dac9274b0ca14f9bc55177518a67a2daf09) | workflow commit (merge commit) |
| PR | [15c0ac4f](https://github.com/huggingface/transformers/commit/15c0ac4f6136565ce77ddf0a57ba057408c5ecf2) | branch commit (from PR) |
| main | [ad327c9b](https://github.com/huggingface/transformers/commit/ad327c9b8c1ebc292275ea41e1782be8b1607c2d) | base commit (on `main`) |

✅ No failing test specific to this PR 🎉 👏 !

--- Comment by github-actions[bot] at 2026-05-19T07:41:54Z ---
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: albert, align, autoformer, bit, bridgetower, clap, clip, clvp, colmodernvbert, colpali, colqwen2, conditional_detr, cvt, dab_detr, depth_pro, detr

--- Comment by zucchini-nlp at 2026-05-18T05:24:07Z ---
i am not sure about this part, since it means we won't be able to copy `init_weights` from the parent anymore.

In a modular file we check for `PreTrainedModel._init_weights(module)` or checking that the body exists iirc, what was the complain from mlinter?

--- Comment by hmellor at 2026-05-18T05:51:22Z ---
🤔

--- Comment by vasqu at 2026-05-18T16:13:13Z ---
that's quite a few skips :D let's iterate fast then

--- Comment by vasqu at 2026-05-18T16:13:56Z ---
Different issue but mentioning https://github.com/huggingface/transformers-mlinter/issues/5#top just to keep track

--- Comment by tarekziade at 2026-05-19T01:01:45Z ---
We need to be extra sure! ;)

--- Comment by tarekziade at 2026-05-19T01:02:25Z ---
I am happy to push all of the ~190 models in the same PR, let me know

--- Comment by tarekziade at 2026-05-19T07:39:59Z ---
Inlining `super()._init_weights(module)` is the bug TRF018 catches: the generated file ends up with the parent's body copied in but no chain to `PreTrainedModel._init_weights`, silently  breaking init

Keeping the call literal preserves the chain at runtime via MRO and satisfies the linter. If a model genuinely wants to skip the chain, `# trf-ignore: TRF018` is the escape hatch.

--- Comment by vasqu at 2026-05-19T14:41:09Z ---
I think we could do splits based on this branch and only have them add smaller batches; then we merge them into this branch bit by bit. Wdyt?


PULL REQUEST #46022: fix: include transitive relative imports when loading from local directory
State: open  |  Merged: False
Author: trducng  |  Base: main
Labels:
Created: 2026-05-18T04:44:13Z

# What does this PR do?

When loading a custom model from a local folder with trust_remote_code=True, only direct relative imports of the entry-point file were copied into the module cache and included in the content hash. Transitive imports (i.e. imports of imports) were silently skipped, causing ImportError at runtime for any dependency beyond the first level.

Fix both sites in the local branch to use get_relative_import_files, which already walks the full transitive closure. Also remove the now-unused module_file and modules_needed parameters from _compute_local_source_files_hash.

## Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
**we ask that new users do not submit pure code agent PRs** at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read [`CONTRIBUTING.md`](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).

- [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://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).
- [x] Did you write any new necessary tests?

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc
- kernels: @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->

--- Comment by Rocketknight1 at 2026-05-18T12:19:51Z ---
Do we have examples where this was failing? We're trying to avoid merging pure "theoretical fixes" right now, since code agents have a tendency to find very obscure paths, and it requires a lot of maintainer work to validate them

--- Comment by trducng at 2026-05-18T22:05:52Z ---
@Rocketknight1 I get this issue when loading a cloned https://huggingface.co/moonshotai/Kimi-K2.6 from local folder. That model has the following import chain: `modeling_kimi_k25` -> `configuration_kimi_k25` -> `configuration_deepseek`. When loading from local, the `configuration_deepseek` file is not copied to Huggingface cache, resulting a failed import. It happens because the old implementation only copies files that are directly imported in the `modeling_kimi_k25.py` file. The `configuration_deepseek` import only exists in `configuration_kimi_k25` so it's not copied.

I reproduced a simple example here: https://huggingface.co/trducng/test_dynamic_model_transitive_imports , you can clone and run this script before and after this fix.

```
from transformers import AutoModel

local_path = "./test_dynamic_model_transitive_imports/"
model = AutoModel.from_pretrained(local_path, trust_remote_code=True)

print(model)
```

Before the fix, you should get an error looks something like:

```
FileNotFoundError: [Errno 2] No such file or directory: '...huggingface/modules/transformers_modules/test_dynamic_model_transitive_imports/47c82084ffefac3e/configuration2.py'
```

--- Comment by Rocketknight1 at 2026-05-20T11:28:42Z ---
Thanks for the rebases to get the CI green! I'll try merging now :sweat_smile:

--- Comment by HuggingFaceDocBuilderDev at 2026-05-20T11:41:54Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46022). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

--- Comment by Rocketknight1 at 2026-05-19T11:28:21Z ---
```suggestion
    Computes a stable hash from the bytes of the local source file and its relative-import source files.
```


[docs] tp for continuous batching

PULL REQUEST #46019: [docs] tp for continuous batching
State: open  |  Merged: False
Author: stevhliu  |  Base: main
Labels:
Created: 2026-05-18T02:12:03Z

adds docs for #45821

--- Comment by HuggingFaceDocBuilderDev at 2026-05-18T02:22:59Z ---
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_46019). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.


PULL REQUEST #46014: Fix cache collision 45632(NaNs in classification heads upon checkout + init)
State: closed  |  Merged: False
Author: Jeevang1-epic  |  Base: main
Labels: Code agent slop
Created: 2026-05-17T16:45:05Z

## Title
Fix NaNs when initializing missing low-precision weights in `from_pretrained`

## Summary
This PR fixes a NaN initialization issue affecting newly created (missing) parameters during `from_pretrained` when the model is loaded in low precision.

In affected setups, missing parameters such as classification/pooler linear weights could contain NaNs right after load, especially when initialized on CPU in `float16`/`bfloat16`.

## Root cause
Missing parameters are materialized and then initialized through random init paths.
For low-precision CPU tensors, direct random init can be numerically unstable on some torch/runtime combinations, which may produce NaNs.

## What changed
- Added a shared initialization fallback in `src/transformers/initialization.py`:
  - `_run_init_with_fp32_cpu_fallback(...)`
  - For CPU tensors in `float16` or `bfloat16`, random init is performed in temporary `float32`, then copied back to the original dtype.
- Applied this fallback to random-init primitives:
  - `uniform_`, `normal_`, `xavier_uniform_`, `xavier_normal_`, `kaiming_uniform_`, `kaiming_normal_`, `trunc_normal_`, `orthogonal_`, `sparse_`.
- Added regression test in `tests/utils/test_modeling_utils.py`:
  - `test_missing_keys_init_is_finite_in_low_precision`
  - Verifies that missing-key initialization remains finite (no NaNs) under low-precision load.

## Why this is safe
- Scope is limited to initialization-only functions.
- Behavior is unchanged for non-CPU or non-low-precision tensors.
- Existing `_is_hf_initialized` guards are preserved.

## Validation
- `python -m py_compile src/transformers/initialization.py tests/utils/test_modeling_utils.py` passed.
- Targeted pytest execution in this local environment was blocked by missing local dependencies (`torch` not available in this runtime), so full runtime validation should be run in CI.

## Issue
Fixes #46002


PULL REQUEST #46013: docs: document flash attention supports_mapping
State: open  |  Merged: False
Author: nightcityblade  |  Base: main
Labels:
Created: 2026-05-17T15:26:27Z

# What does this PR do?

Documents the `supports_mapping` argument in `_process_flash_attention_kwargs` and fixes the docstring section heading from `Return` to `Returns`.

Fixes #45995

## 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. Issue: #45995
- [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).
- [x] Did you write any new necessary tests? No new tests were needed for this docstring-only change; ran `python3 -m py_compile src/transformers/modeling_flash_attention_utils.py` and `python3 -m ruff check src/transformers/modeling_flash_attention_utils.py`.

## Who can review?

Documentation: @stevhliu
Attention: @vasqu @ArthurZucker @CyrilVallez

--- Comment by stevhliu at 2026-05-18T00:49:36Z ---
just specifying the wording a bit more :)

```suggestion
            A dict containing the underlying information of the Flash Attention function on its supported parameters. Keys are all valid parameters (and alternative names) across all standards and values indicate whether each parameter could be found in the active backend's signature. For more information, please check `_lazy_define_process_function` that creates this mapping.
```

--- Comment by vasqu at 2026-05-18T07:18:10Z ---
Can we take a similar description to #45153?

--- Comment by stevhliu at 2026-05-18T07:34:10Z ---
updated to match the existing description


PULL REQUEST #46012: fix: handle OOV token ids gracefully in convert_ids_to_tokens
State: closed  |  Merged: False
Author: lalitha2410  |  Base: main
Labels: Code agent slop
Created: 2026-05-17T13:42:37Z

## What does this PR do?

Fixes #29159

When a token id exceeds the vocabulary size, `id_to_token()` returns
`None` silently. Previously this `None` was returned/appended without
any warning, causing silent incorrect behavior.

This fix adds a warning log and:
- Returns `""` (empty string) for single OOV token ids
- Skips OOV tokens when processing a list of ids

This aligns behavior consistently and makes OOV ids visible to the user.

## Before
- Single OOV id → returns `None` silently
- List with OOV ids → appends `None` to results silently

## After
- Single OOV id → logs warning + returns `""`
- List with OOV ids → logs warning + skips token

--- Comment by lalitha2410 at 2026-05-18T05:29:23Z ---
Hi @ArthurZucker!

I've submitted this fix for issue #29159 which has been
open since February 2024.

The PR includes:
- Fix for inconsistent OOV token handling
- 3 unit tests
- All 23 CI checks passing

Would love to get your feedback when you have time!
Thank you!