noamaanMulla-03/transformers-issues huggingface dataset:
make sure hub errors are surfaced
Author: tarekziade
Pull request: yes
Labels: name: bug

# What does this PR do?

in `PreTrainedTokenizerBase.from_pretrained` this commit https://github.com/huggingface/transformers/commit/73a13f86f6d208882d59d1200609986c5a5f49a7#diff-85b29486a884f445b1014[…]f4ae701ee758a754fddcc1L1679 silenced hub errors, this is surfaced by 

```
pytest -sv tests/models/auto/test_tokenization_auto.py::AutoTokenizerTest::test_tokenizer_identifier_non_existent
```

with 

```
E           AssertionError: "julien-c/herlolip-not-exists is not a local folder and is not a valid model identifier" does not match "401 Client Error. (Request ID: Root=1-69806dfe-29b61b47408bd03420a3cdac;e2386594-f169-4d1b-9171-050ec211b4c8)
```

This patch removes the try/except block

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

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

run-slow: auto
[CB] Refactor logic for inputs and outputs outside of the main API
Author: remi-or
Pull request: yes

This PR refactors all of the logic linked to the inputs and outputs of continuous batching into a new class `ContinuousBatchingIOs` itself in a new file. This will be quite useful when we introduce async scheduling, because there will be two sets of host-side IOs and one set of device-side IOs. 
To avoid having this major refactoring AND the async logic in the same PR, I think it would be good if we can first merge this part, which does not change much, and then add the async logic.
This PR also makes the test file `ty` compatible and adds a bit more documentation. 

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

# What does this PR do?

As per the title. This simplifies the use of `LoadStateDictInfo` a bit everywhere, and makes it clear that the entries within the struct are mutated in-place all the time.

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

Alright, resplit the 2 methods indeed!
Since nothing really changed after last review and the test failing is unrelated, merging!
refactor + robusts tests for Tensor Parallel 
Author: 3outeille
Pull request: yes

<img width="354" height="475" alt="image" src="https://github.com/user-attachments/assets/64dd14da-387b-454a-863b-c2e3c7ef965d" />

- distributed training CI (https://github.com/huggingface/transformers/pull/42765) needs FSDP to be refactor.  We need same FSDP degree to compare training loss properly (https://github.com/pytorch/torchtitan/blob/main/docs/converging.md#guidelines) 
- Referencing https://github.com/huggingface/transformers/pull/43157 because it uses it and hasn't been review


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

referencing https://github.com/huggingface/transformers/pull/43003

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=42809&sha=372aab

A little offside: Can you also add the plan for ernie vl moe? It might be more of a special case since it has two sets of Moes :eyes: 

run-slow: afmoe, apertus, arcee, aria, bamba, cohere, cohere2, cwm, dbrx, deepseek_v2, deepseek_v3, diffllama, doge, dots1, emu3, ernie4_5

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

models: ["models/afmoe", "models/apertus", "models/arcee", "models/aria", "models/bamba", "models/cohere", "models/cohere2", "models/cwm", "models/dbrx", "models/deepseek_v2", "models/deepseek_v3", "models/diffllama", "models/doge", "models/dots1", "models/emu3", "models/ernie4_5"]
quantizations: []

run-slow: afmoe, apertus, arcee, aria, bamba, cohere, cohere2, cwm, dbrx, deepseek_v2, deepseek_v3, diffllama, doge, dots1, emu3, ernie4_5

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

models: ["models/afmoe", "models/apertus", "models/arcee", "models/aria", "models/bamba", "models/cohere", "models/cohere2", "models/cwm", "models/dbrx", "models/deepseek_v2", "models/deepseek_v3", "models/diffllama", "models/doge", "models/dots1", "models/emu3", "models/ernie4_5"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/21484571621)

✅ No failing test specific to this PR 🎉 !


> could you notably confirm that chaining several "matching" layers, such as a MLP which contains 2 colwise and 1 rowwise will only incur a communication at the very end, after the final rowwise?

yes ! 

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

run-slow: afmoe, apertus, arcee, aria, bamba, cohere, cohere2, cwm, dbrx, deepseek_v2, deepseek_v3, diffllama, doge, dots1, emu3, ernie4_5
[loading] Fix forced upcasting to fp32
Author: Cyrilvallez
Pull request: yes
Labels: name: for patch

# What does this PR do?

As per the title. https://github.com/huggingface/transformers/pull/41580 broke the `keep_in_fp32_modules` flag as it's supposed to be used only with fp16, not bf16.
I added very strict tests on this to avoid name clashing/typos etc!

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

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

run-slow: afmoe
Cast byte_count to int in caching_allocator_warmup for MPS compatibility
Author: tobyliu2004
Pull request: yes

…tibility

# What does this PR do?

Fixes #43582

Fixes TypeError on Apple Silicon (MPS) when loading models with quantization by ensuring `byte_count // 2` returns a Python int.

## The Issue

On line 4762 in `modeling_utils.py`, `torch.empty(byte_count // 2, ...)` fails with TypeError on MPS devices because:
1. `byte_count` comes from `total_byte_count` as a torch/numpy scalar
2. For CUDA/XPU: line 4760 casts it to Python int
3. For MPS: this casting is skipped (device type check on line 4748 doesn't include "mps")
4. `byte_count // 2` on a torch scalar returns float
5. `torch.empty()` expects int, receives float → TypeError

## The Fix

Wrap the division in `int()` on line 4762:
```python
_ = torch.empty(int(byte_count // 2), dtype=torch.float16, device=device, requires_grad=False)
```

This defensive fix works for all device types (CUDA, XPU, MPS, and future additions).

## Testing

**Reproduced on main branch:**
- Loading GPT-2 with BitsAndBytes 4-bit quantization on MPS → TypeError

**Verified fix works:**
- Same setup with fix → Model loads successfully without error

Tested on Apple Silicon M3 Pro with PyTorch 2.10.0.

## Before submitting
- [x] This PR fixes a bug
- [x] Tested on actual hardware (M3 Pro MPS)
- [x] Code follows existing patterns

cc @vasqu @Cyrilvallez

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43608). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
custom tok init fix
Author: itazap
Pull request: yes
Labels: name: for patch

custom tokenizers fail on super._init_() call that tries to update vocab size before all vocab attrs are defined


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

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

run-slow: auto

run-slow: auto
update guide with new attr name for toks
Author: itazap
Pull request: yes

`additional_special_tokens_ids`: Removed. Use `extra_special_tokens_ids` instead

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

# What does this PR do?

As per the title!
Most important change is the removal of the 2 deprecated auto classes

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

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

run-slow: audioflamingo3, auto, bark, beit, bert, blenderbot, bros, donut, ernie, flava, fnet, layoutlmv3, lxmert, megatron_bert, mobilebert

View the CircleCI Test Summary for this PR:

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

@Cyrilvallez @ArthurZucker Why e.g. `return_all_scores` support in text classification was removed?

Hey @djstrong! See the following snippet that was removed:
```python
elif return_all_scores is not None:
    warnings.warn(
        "`return_all_scores` is now deprecated,  if want a similar functionality use `top_k=None` instead of"
        " `return_all_scores=True` or `top_k=1` instead of `return_all_scores=False`.",
        UserWarning,
    )
    if return_all_scores:
        postprocess_params["top_k"] = None
    else:
        postprocess_params["top_k"] = 1
```
🚨 Refactor DETR to updated standards
Author: yonigozlan
Pull request: yes

# What does this PR do?

This PR aims at refactoring DETR as part of an effort to standardize vision models in the library, in the same vein as https://github.com/huggingface/transformers/pull/41546.
Expect to see much more PRs like this for vision models as we approach v5!

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

Hello @molbap @ArthurZucker!
The long overdue refactor of DETR is ready for a first review. I'm waiting for your reviews to run fix-copies as this will have a lot of impacts on other models (through `# Copied from` for now, modular later ;) )

Thanks for the review @vasqu ! I standardized attention and masking following your advice :)

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

run-slow: d_fine, deformable_detr, detr, lw_detr, omdet_turbo, rt_detr, rt_detr_v2, yolos

Hello @vasqu ! Thanks a lot for the reviews, I have addressed your comments and refactored DetrMaskHeadSmallConv.

As this PR is getting quite a big, and we need some of the refactored models merged quite quickly as there a few PRs open depending on them, I removed some outdated copied from that I'll change to modular in a subsequent PR, so that we can merge this PR.

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=41549&sha=7821c4

Hey @molbap @vasqu ! I added a small refactor to rt_detr, and I think we can merge this for now before the PR gets too big. This should make for a good basis to continue the refactoring work on vision models :)
[CB] Keep order of incoming requests
Author: remi-or
Pull request: yes

The test `tests/generation/test_paged_attention.py::TestBatchGeneration::test_generate_batch_consistency` is failing because CB shuffles incoming request to maximize prefix caching. This is not a problem unless the user expects outputs to have the same order as the inputs when using `generate_batch`, which is reasonable. This PR ensures this and fixes the test on GPU.

On CPU, the test is still half broken, probably because of numerical difference between the implementations. I added a TODO and a FIXME to later check this out. In the meantime, this PR 1. fixes the CI and 2. adds order to the API which was needed anyway

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

# What does this PR do?

This PR makes it easier to go through TrainingArguments ! This should help making trainer less bloated for the users. A nice first step to make Trainer simpler to use. 

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

<img width="935" height="505" alt="Screenshot 2026-01-28 at 12 10 14 PM" src="https://github.com/user-attachments/assets/f0e7741e-983c-461a-af62-b7a19d7908ee" />


this looks way better, nice pr!!

only detail, there are 3 "Distributed Training" sections
Add Claude Skill for PEFT/LoRA fine-tuning guidance
Author: jeeth-kataria
Pull request: yes

## What does this PR do?

Adds a Claude SKILL for PEFT (Parameter-Efficient Fine-Tuning) and LoRA guidance, complementing the transformers-api skill in #43340.

## Why is this needed?

PEFT/LoRA is one of the most popular integrations with Transformers for memory-efficient fine-tuning. This skill helps Claude Code users with:
- LoRA configuration (r, lora_alpha, target_modules)
- QLoRA setup for consumer GPUs
- Adapter operations (save, load, merge, multi-adapter)
- Training integration with Trainer/SFTTrainer
- Common troubleshooting patterns

## Structure
.claude/skills/peft-lora/
├── SKILL.md # Main entry point
├── reference/areas/
│ ├── lora-basics.md # LoRA fundamentals
│ ├── qlora-quantization.md # 4-bit/8-bit training
│ ├── adapter-operations.md # Load/save/merge
│ ├── training-integration.md # Trainer & SFTTrainer
│ └── troubleshooting.md # Common errors
└── templates/
└── minimal_repro.md # Bug report template

## Related PRs

- #43340 - Claude code skills for transformers-api (this complements that PR)
- Addresses issue #42971


Comments:
Fix crash of custom models in Notebook or Repl
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

Fix https://github.com/huggingface/transformers/issues/43645. It's quite unusual, but no reason it should crash in general

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

Due to current implem, the warning would be shown all the time, even when the model is not even a MoE, so I think it would be even more confusing tbh...
Fix Quickstart Colab dependency mismatch
Author: Justynita
Pull request: yes

# What does this PR do?


The Quickstart "Open in Colab" example can fail in a fresh Google Colab environment due to an incompatible preinstalled version of `huggingface_hub`.

This PR updates the installation command to explicitly constrain `huggingface_hub` to the version range required by `transformers`, ensuring the example runs as intended.



Comments:
We definitely do not want to constrain `huggingface_hub<1.0` for modern versions of Transformers! I'm not sure how you encountered this bug.
Better error message when loading adapter models with peft dependency missing
Author: maxjeblick
Pull request: no
Labels: name: Feature request

name: PEFT

### Feature request

Loading adapter models (such as https://huggingface.co/lightonai/MonoQwen2-VL-v0.1/tree/main) fails with an error message when peft isn't installed. The error message
`OSError: lightonai/MonoQwen2-VL-v0.1 does not appear to have a file named pytorch_model.bin, model.safetensors, tf_model.h5, model.ckpt or flax_model.msgpack.`
 is a bit cryptic and requires the user to understand that
- the model that will be loaded is a peft adapter
- peft isn't installed in the current env

To improve UX, it would be useful to show a different error message such as `"The model lightonai/MonoQwen2-VL-v0.1 is an adapter model. To load it, you need to install peft (hint: run `pip install peft`)".`

### Motivation

Improve UX. The user may get the impression that the model repository is corrupted. 

### Your contribution

This feature should probably be implemented by core maintainers that are familiar with the internals of the model loading code.

Comments:
That seems fair indeed! Would you like to open a PR with your proposed change? cc @SunMarc @BenjaminBossan 

Closing stale issues to keep the code agents away
Improve error message for PEFT adapter without peft
Author: KOKOSde
Pull request: yes
Labels: name: Code agent slop

## Summary
Detect adapter repositories (via `adapter_config.json`) and raise a clear, actionable error when `peft` is not installed, instead of the generic "missing pytorch_model.bin/model.safetensors" message.

## Changes
- Check for `adapter_config.json` before raising the generic missing-weights error.
- Suggest `pip install peft` and link to PEFT docs.

## Test plan
- Added unit test `tests/utils/test_peft_missing_error_message.py`.

Ref: #34733

Comments:
Add _get_signature_columns method to allow custom trainers to override column filtering
Author: abigailllr
Pull request: yes

Adds _get_signature_columns method that custom trainers can override to specify which columns to preserve when remove_unused_columns=True.    
                                                                                                                                                      
Currently, TRL trainers (DPO, GRPO) must override _set_signature_columns_if_needed entirely just to change the column list. This PR extracts the column logic into a separate overridable method.

Fixes https://github.com/huggingface/transformers/issues/43595?issue=huggingface%7Ctransformers%7C43598

Comments:
cc @SunMarc
Fix model/processor mismatch in SigLIP2 quantization example
Author: jonathan-fulton
Pull request: yes

## What does this PR do?

Fixes the model/processor mismatch in the SigLIP2 documentation quantization example.

Fixes #39692

## The Problem

The quantization example used mismatched model and processor checkpoints:
- Model: `google/siglip2-large-patch16-512`
- Processor: `google/siglip2-base-patch16-224`

This mismatch caused errors because the processor configuration (designed for 224px base model) didn't match the model being used (512px large model).

## The Fix

Updated the example to use matching model and processor:
- Model: `google/siglip2-base-patch16-224`
- Processor: `google/siglip2-base-patch16-224`

## Before submitting

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

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_43652). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix CLIPOutput attentions not being returned
Author: jonathan-fulton
Pull request: yes

## What does this PR do?

Fixes #43618

### Problem

Since v5, `CLIPVisionModel` and `CLIPTextModel` no longer return attention weights when `output_attentions=True`:

```python
model = CLIPModel.from_pretrained(model_path, attn_implementation="eager")
vision_outputs = model.vision_model(pixel_values=pixel_values, output_attentions=True)
assert vision_outputs.attentions is not None  # FAILS - attentions is None
```

### Root Cause

`CLIPVisionTransformer.forward()` and `CLIPTextTransformer.forward()` both call their respective encoders which return a `BaseModelOutput` containing `hidden_states` and `attentions`. However, when constructing the `BaseModelOutputWithPooling` return value, only `last_hidden_state` and `pooler_output` were being passed - the `hidden_states` and `attentions` fields were omitted.

### Solution

Pass through `hidden_states` and `attentions` from the encoder outputs to the return value in both transformers:

```python
return BaseModelOutputWithPooling(
    last_hidden_state=last_hidden_state,
    pooler_output=pooled_output,
    hidden_states=encoder_outputs.hidden_states,  # NEW
    attentions=encoder_outputs.attentions,        # NEW
)
```

## Who can review?

@yonigozlan @molbap

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

run-slow: clip, metaclip_2

run-slow: clip, metaclip_2

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

models: ["models/clip", "models/metaclip_2"]
quantizations: []

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

Thanks @Rocketknight1! Appreciate the quick review. 🙏

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/21632136748)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [d860c893](https://github.com/huggingface/transformers/commit/d860c893f7f3ddef9276ab058a12863c97d0f6e0) | merge commit |
| PR | [ab3db54d](https://github.com/jonathan-fulton/transformers/commit/ab3db54da6f874264f71b7f8826ce1f99c43a0d4) | branch commit |
| main | [432ddfad](https://github.com/huggingface/transformers/commit/432ddfadcdeb5c0b0d597fed6c1edc30efb511b6) | base commit |

✅ No failing test specific to this PR 🎉 👏 !
CLIPOutput attentions is no longer assigned
Author: dbellavista-ai
Pull request: no
Labels: name: bug

name: Vision

### System Info

- transformers 5.0.0
- python 3.12.11

### Who can help?

@yonigozlan  @molbap

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

In previous version, you could use

```
model = CLIPModel.from_pretrained(model_path, attn_implementation="eager")
vision_outputs = model.vision_model(pixel_values=pixel_values, output_attentions=True)
assert vision_outputs.attentions is not None
```

since version `5.0.0` the attentions is not filled anymore (it's still declared in the CLIPOutput, but never used), but I didn't find this breaking change in the log. Is there a way to obtain the attentions layers?

Thanks


### Expected behavior

```
vision_outputs.attentions
```

should contain the attention layers

Comments:
Looks like the same issue as in Siglip (https://github.com/huggingface/transformers/issues/42759). I will take a closer look later. Update: indeed the same issue as in SigLip

It will be fixed by @yonigozlan soon ;)
Qwen3ForCausalLM leaks VRAM if used in multiple dataloader threads
Author: dxqb
Pull request: no
Labels: name: bug

### System Info

reopening, please see https://github.com/huggingface/transformers/issues/42673
this is still an issue, but auto-closed by `github-actions`. That it expects a reaction within a little over a week isn't great.

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

see above

### Expected behavior

see above

Comments:
Closing this to reopen the original