noamaanMulla-03/transformers-issues huggingface dataset:
[Bugfix][informer]: Correct tensor shape for input_size=1
Author: Flink-ddd
Pull request: yes

Hi @Rocketknight1, thanks for the great guidance on the previous PR!

This new pull request follows your suggestion to fix the bug at its source. It resolves a RuntimeError that occurs in time series models inheriting from TimeSeriesTransformerModel (such as InformerModel) when config.input_size is set to 1.

The root cause was that when `input_size=1`, the loc and scale tensors calculated by the scaler retained an extra dimension (e.g., shape [B, 1, 1] instead of [B, 1]). This incorrect shape caused a dimension mismatch error during a later expand() operation.

Instead of overriding the method in the child class, this PR applies a minimal and robust fix directly to the create_network_inputs method in the parent TimeSeriesTransformerModel. It refactors the logic to unconditionally apply .squeeze(1) to both the loc and scale tensors. This approach handles all input_size cases correctly and avoids code duplication.

Fixes #38745

Comments:
cc @kashif since you worked on the original informer PR , can you take a look? I suggested this change be moved to the original function for `TimeSeriesTransformer`, but I'm not certain about that - I don't know the models well enough to know what the expected behaviour should be for `config.input_size == 1`

thanks @Flink-ddd  can you also kindly confirm that autoformer model also works?

Hi @kashif and @Rocketknight1 ,

Thanks for the great suggestion to check `Autoformer`!

You were right to be cautious. I can confirm that `AutoformerModel` also suffers from the exact same bug. I was able to verify this locally by running a test against the unfixed code, which failed with the identical RuntimeError as Informer did.

This PR fixes the bug in the shared parent class, `TimeSeriesTransformerModel`, so it should resolve the issue for both Informer, Autoformer, and any other inheriting models.

All relevant CI checks are now passing. Thanks for helping me get to a much cleaner and more robust solution!

Hi @kashif , thanks again for the approval! Just wanted to gently check in and see if there is anything else needed from my side to get this merged. Thanks!

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_38856). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Update ASR, audio classification, and TTS documentation
Author: Deep-unlearning
Pull request: yes

Update ASR, audio classification, and TTS documentation to include additional library dependencies and correct dataset references. Added 'report_to' parameter for tracking in training examples.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43356). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add ResNet image processor with BICUBIC interpolation
Author: boomesh11
Pull request: yes
Labels: name: Code agent slop

## Description

This PR adds an image processor for ResNet models with BICUBIC interpolation, matching the original torchvision ResNet implementation.

The original ResNet implementation uses BICUBIC interpolation for preprocessing, but this feature was missing from HuggingFace Transformers.

## Changes

- Added `image_processing_resnet.py` with `ResNetImageProcessor` class
- Default resample method is set to `Image.BICUBIC` to match torchvision implementation
- Includes standard ImageNet normalization (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
- Updated `__init__.py` to export the new processor
- Added proper docstrings following HuggingFace conventions

## Related Issue

Fixes part of #28180

## Testing

The implementation has been tested with standard ImageNet normalization and BICUBIC interpolation. The default parameters match the original torchvision ResNet preprocessing pipeline.

Comments:
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43351&sha=92e637
[`Qwen3 Omni Moe`] Fix 16 byte alignment in tests
Author: vasqu
Pull request: yes

As per title, this is required for `torch._grouped_mm`; related failures e.g. https://app.circleci.com/pipelines/github/huggingface/transformers/160384/workflows/1c47e8a5-8aea-4fd5-9ec6-b6aab32e4e55/jobs/2110308/parallel-runs/3

I cannot reproduce these issues locally, would be nice to have something that could Edit: needs to be run on CPU to trigger

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

run-slow: qwen3_omni_moe, qwen3_vl_moe

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

models: ["models/qwen3_omni_moe", "models/qwen3_vl_moe"]
quantizations: []

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

run-slow: qwen3_omni_moe, qwen3_vl_moe

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43353&sha=3c87f7

Discussed internally, we will move this to the conversions instead for all moes for now
Perf: enable pin_memory in DataLoader for CLM no_trainer example
Author: RinZ27
Pull request: yes

This PR enables `pin_memory=True` in the `DataLoader` for the causal language modeling standalone example.

Pinned memory is a PyTorch best practice that improves host-to-device transfer efficiency.

Comments:
thanks! tho we don't really maintain these anymore! @merveenoyan do you want to merge?

Hi @ArthurZucker, thanks for the response. @merveenoyan, just checking in to see if you have any thoughts on merging this. It's a small change but would be beneficial for anyone still using these examples for reference. Thanks!

I've squashed the commits into a single clean one and ensured the `pin_memory` configuration properly checks for CUDA availability. The implementation is now streamlined and ready. @merveenoyan, would you mind taking a look for a final review when you have a moment? Thanks!
docs: add Chinese translation for generation_strategies.md
Author: liuyun7345
Pull request: yes

# What does this PR do?

This PR adds Chinese translation for the `generation_strategies.md` documentation.

## Content translated

1. **Basic decoding methods**
   - Greedy search (贪婪搜索)
   - Sampling (采样)
   - Beam search (束搜索)

2. **Custom generation methods**
   - How to use custom generation methods
   - How to create custom generation methods  
   - generate.py specifications
   - requirements.txt
   - README.md guidelines
   - Finding custom generation methods

## Files changed

- `docs/source/zh/generation_strategies.md` - New Chinese translation file (325 lines)
- `docs/source/zh/_toctree.yml` - Added new document to table of contents

## 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?
- [ ] 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).
- [ ] Did you write any new necessary tests?

## Who can review?

@stevhliu (Documentation)

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

- builds on the awesome work in #42277 to add docs for how to use kernels in transformers
- also adds docs for loading local kernels in `KernelConfig` from #42800 

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

replaces large markdown tables with the cleaner dataset viewer

<img width="966" height="722" alt="Screenshot 2026-01-07 at 2 24 23 PM" src="https://github.com/user-attachments/assets/53f71b23-9d25-4855-abb5-f0eedb2acf3f" />


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

Love the idea @stevhliu !
Can you please update it with these results (include prefill, decode and generate times)
json: [results.json](https://github.com/user-attachments/files/24490807/results.json)
md: [results.md](https://github.com/user-attachments/files/24490813/results.md)
For reproduction we can link to this script: https://gist.github.com/IlyasMoutawwakil/8b70f5604c60efb56fcf8565fbdb05a5
We can also add these plots to summarize the numbers (plotting script in https://gist.github.com/IlyasMoutawwakil/6040b1e6803bf959138933e44fd93af2)
<img width="6300" height="4500" alt="generate" src="https://github.com/user-attachments/assets/c25c3ee5-a7ca-4b3c-b102-c48f861ec61b" />
<img width="4200" height="3000" alt="decode" src="https://github.com/user-attachments/assets/c2dba090-75ab-44b5-90e0-b6b33f97e135" />
<img width="4200" height="3000" alt="prefill" src="https://github.com/user-attachments/assets/c85ccf7a-1b53-4757-9791-518a4b380e81" />


updated the dataset with new results and thinking about embedding this chart in there as well (trying to figure out how to make it work on Spaces atm)!


https://github.com/user-attachments/assets/a3a38891-5c83-4866-8a41-e3408fba99b0



@IlyasMoutawwakil, updated with the [plots](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43158/en/experts_interface#benchmarks) as well now. let me know what you think!

thanks @stevhliu ! isn't it a bit hard to read ? the generation / prefill / decode latencies are different metrics so it's counterintuitive to see them next to each other in the same bar plot, there is a way to put them in the same plot if that's the goal ; by stacking prefill and decode = generate:
<img width="5000" alt="prefill+decode" src="https://github.com/user-attachments/assets/d87f4b22-395d-4c5d-91b0-445849443729" />
but we also lose the info about the speedup which is imo very eye-catching and straight-to-the-point
[docs] finetuning
Author: stevhliu
Pull request: yes

adds ecosystem integration docs for axolotl, trl, and unsloth

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

A couple of minor changes on the Axolotl side but LGTM, thank you for the shout out!
Feature request: Support resume_from_checkpoint for checkpoints stored on Hugging Face Hub
Author: meodbr
Pull request: no
Labels: name: Feature request

### Feature request

Currently `Trainer.train(resume_from_checkpoint=...)` only supports local paths.

It would be useful if `resume_from_checkpoint` could also accept a Hugging Face Hub repo (optionally with a checkpoint tag), similar to `from_pretrained()`. 
As checkpoints are automatically pushed with `TrainingArguments(hub_strategy="all_checkpoints" | "checkpoint")`.

I was thinking of an API like that:
```python
trainer.train(
    resume_from_checkpoint="user/repo-id@checkpoint-1000",
)
```
or alternatively:
```python
trainer.train(
    resume_from_checkpoint="checkpoint-1000",
    checkpoint_repo_id="user/repo-id",
)
```

### Motivation

I often use the `hub_strategy="all_checkpoints"` when working on preemptible GPU environments (but this applies to any cloud training pipeline).

**Problem** is, the current way of resuming training from hub is taking a few steps:
1. **Training and Saving Checkpoints**, with `hub_strategy`
2. **Fetching Checkpoint**, with `huggingface_hub.snapshot_download`
3. **Resuming Training**, with `trainer.train(resume_from_checkpoint="local_downloaded_checkpoint")`


```python
from huggingface_hub import snapshot_download

RESUME_RUN = True
CHECKPOINT_REPO = "user/repo-id"
CHECKPOINT_REVISION = "checkpoint-1000"
OUTPUT_DIR = "local/path"

if RESUME_RUN:
    logger.info(f"Resuming from checkpoint {CHECKPOINT_REVISION} in repo: {CHECKPOINT_REPO}")
    snapshot_download(
        repo_id=CHECKPOINT_REPO,
        local_dir=OUTPUT_DIR,
        repo_type="model",
    )

# [...]

if RESUME_RUN:
    trainer.train(resume_from_checkpoint=f"{OUTPUT_DIR}/{CHECKPOINT_REVISION}")
```

It could be seamlessly integrated directly in `Trainer.train`

### Your contribution

I would love to work on a PR for this feature if it aligns with what you want. feedback on the idea would be very welcome.

Comments:
Related to this huggingface forum issue :

[Resuming Training from Checkpoints Stored on Hugging Face Hub (without downloading manually)](https://discuss.huggingface.co/t/resuming-training-from-checkpoints-stored-on-hugging-face-hub-without-downloading-manually/138919/1)

cc @sunmarc
fix(models) : string mutation bug in from_proteinnet_string
Author: aarushisingh04
Pull request: yes

### what does this PR do?

fixes a `TypeError` in `openfold_utils/protein.py` where `from_proteinnet_string` attempts to mutate an immutable string in-place.

the original code tried to assign seq[i] = "X" to handle unknown residues, which crashes. this pr replaces that logic with a list comprehension to safely sanitize the sequence, resolving the existing `FIXME`.

### 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?

@ArthurZucker 


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43380). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
fix: add device cast to position_ids_expanded in LlamaRotaryEmbedding
Author: sasankkurnella
Pull request: yes

## What does this PR do?

Fixes #43350

The `position_ids_expanded` tensor was not being moved to the same device as the input tensor `x`, causing a `RuntimeError` when `position_ids` is on CPU while the model is on CUDA.

### The Problem

In `LlamaRotaryEmbedding.forward()`, `inv_freq_expanded` is correctly moved to `x.device`, but `position_ids_expanded` was left on whatever device `position_ids` came from. This causes the matrix multiplication to fail:

```
RuntimeError: Expected all tensors to be on the same device, but got mat2 is on cpu, different from other tensors on cuda:0
```

### The Fix

Added `.to(x.device)` to `position_ids_expanded`, mirroring the behavior of `inv_freq_expanded`:

```python
# Before
position_ids_expanded = position_ids[:, None, :].float()

# After
position_ids_expanded = position_ids[:, None, :].float().to(x.device)
```

This is a safe no-op when tensors are already on the same device.

### Impact

This fix cascades to all models inheriting from `LlamaRotaryEmbedding` (Mistral, Ministral3, Qwen2, Gemma2, DeepSeek, etc.).

## 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)?
- [x] Was this discussed/approved via a Github issue? Yes, #43350
- [x] Did you make sure to update the documentation with your changes?
- [x] Did you write any new necessary tests?

Comments:
I've updated `modeling_llama.py` with the fix.

To ensure consistency, I also ran:
1. `python utils/modular_model_converter.py --all` (propagated changes to ~47 modular models)
2. `python utils/check_copies.py --fix_and_overwrite` (synced docstrings/copies for models like Falcon)
3. Manually updated `kyutai_speech_to_text` which was missed by the automated tools.

**Update:** `check_repository_consistency` is now **PASSING** ✅. The PR should be ready for review!

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43369&sha=90e26b

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

run-slow: afmoe, apertus, arcee, aria, bamba, bitnet, chameleon, csm, dbrx, deepseek_v3, dia, diffllama, doge, emu3, evolla, falcon

**Re: `tests_torch` failure on `Qwen3OmniMoe`**

The failing tests (`test_eager_matches_sdpa_inference_*` in `Qwen3OmniMoeThinkerForConditionalGenerationModelTest`) are **unrelated to this PR**.

This PR only modifies `LlamaRotaryEmbedding` and its downstream auto-generated files. The `Qwen3OmniMoe` model:
- Uses its own `Qwen3OmniMoeRotaryEmbedding` class
- - Is not touched by this PR
- - Fails with `RuntimeError: expected data_ptr to be aligned to 16 bytes` - a memory alignment issue in SDPA, not a device mismatch
I believe this test may be flaky or failing on `main`. Could a maintainer please verify and/or re-run CI?

Not necessary as discussed in #43350!
Allow Path type in transformers.image_utils.load_image function
Author: mrdbourke
Pull request: yes

Updated transformers.image_utils.load_image helper function to accept Path type for image input.

I've been extracting images from folders with `pathlib` so added a simple fix to `load_image` to allow Path types as input.

Comments:
@bot /style

Style fix is beginning .... [View the workflow run here](https://github.com/huggingface/transformers/actions/runs/21210663666).

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

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43382&sha=3857c1

Red CI due to torch 2.10 issues, we'll pin 2.9 and try rerunning
pin `torch==2.9.1` for now
Author: ydshieh
Pull request: yes

# What does this PR do?

Apparently, the new release has some issues on our CI.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43392). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add conversion mapping to Qwen3 Omni MoE Thinker submodel
Author: IlyasMoutawwakil
Pull request: yes

# What does this PR do?

This makes sure the thinker is loaded correctly when directly using `Qwen3OmniMoeThinkerForConditionalGeneration`.
This also fixes the misalignment issue that can be observed by running `TRANSFORMERS_TEST_DEVICE=cpu pytest tests/models/qwen3_omni_moe/ -k "test_eager_matches_sdpa_inference" -vvvv`
@vasqu 

## 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 @MekkCyber
- kernels: @MekkCyber @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.

 -->



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43373). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix: resolve lazy-load ImportError for PreTrainedModel (#42548)
Author: karthik-0306
Pull request: yes

## Description
This PR fixes the `ImportError: cannot import name 'PreTrainedModel' from 'transformers'` reported in #42548. 

**The Issue:**
`PreTrainedModel` was missing from the `_import_structure` in `src/transformers/__init__.py`. This caused the lazy-loading mechanism to fail when core frameworks (like PyTorch) were not present or specifically disabled, even though the source file existed.

**Changes:**
- Added `modeling_utils` mapping to `_import_structure` including `PreTrainedModel`, `PushToHubMixin`, and `unwrap_model`.
- Updated the `TYPE_CHECKING` block to include these exports for IDE/static analysis support.
- Formatted with `ruff` to ensure style compliance.

**Verification:**
Running the following in a minimal environment now succeeds:
`python -c "from transformers import PreTrainedModel; print('Success')"`

Fixes #42548

Comments:
View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43365&sha=59182c

I noticed a failure in tests/models/glm_image/test_modeling_glm_image.py. It seems unrelated to this PR's changes in __init__.py, as it appears to be a gradient checkpointing issue in that specific model.