noamaanMulla-03/transformers-issues huggingface dataset:
Simplify Mixtral and its modular children
Author: Cyrilvallez
Pull request: yes

# What does this PR do?

As per the title. This is useful for modular with models to be released

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39252). 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: minimax, mixtral, qwen3_moe

run-slow: minimax, mixtral, qwen3_moe

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

models: ['models/minimax', 'models/mixtral', 'models/qwen3_moe']
quantizations: [] ...

slow tests are identical to main cc @ArthurZucker
fix some flaky tests in `tests/generation/test_utils.py`
Author: ydshieh
Pull request: yes

# What does this PR do?

Use the helper functions to set the norm layers to have eps=1.0 to avoid numerical issues.

Now the following pass

> RUN_SLOW=1 python3 -m pytest -v -n 6 --flake-finder --flake-runs=500 tests/models/kosmos2/test_modeling_kosmos2.py::Kosmos2ModelTest::test_eager_matches_sdpa_generate

> RUN_SLOW=1 python3 -m pytest -v -n 6 --flake-finder --flake-runs=500 tests/models/glm4v/test_modeling_glm4v.py::Glm4vModelTest -k "test_generate_from_inputs_embeds"

The following

> RUN_SLOW=1 python3 -m pytest -v -n 6 --flake-finder --flake-runs=100 tests/models/csm/test_modeling_csm.py::CsmForConditionalGenerationTest::test_eager_matches_sdpa_generate

pass, while on `main` it has 22 failures.

> RUN_SLOW=1 python3 -m pytest -v -n 6 --flake-finder --flake-runs=500 tests/models/csm/test_modeling_csm.py::CsmForConditionalGenerationTest::test_eager_matches_sdpa_generate

still has 1 failure.

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

# What does this PR do?

Adds Ukrainian translation of the main README.md file to improve accessibility for Ukrainian-speaking developers and researchers.

## Changes made

- Created `i18n/README_uk.md` with a complete Ukrainian translation of the main README.md
- Added link to Ukrainian version in the main README.md language navigation
- Translation includes all sections: installation, quickstart, examples, model showcases, etc.
- Adapted code examples and explanations for Ukrainian language context
- Maintained all original links, images, and technical references

## Motivation

This change improves the accessibility of the Transformers library for the Ukrainian developer community. With over 40 million Ukrainian speakers worldwide, this translation will help more developers and researchers easily understand and use the library in their native language.

The Ukrainian translation follows the same high-quality standards as other language versions in the repository, providing a comprehensive and accurate translation that maintains the technical accuracy of the original documentation.

## 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), 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?

@stevhliu - Documentation

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

run-slow: auto, fsmt
Update LED model card
Author: dross20
Pull request: yes

# What does this PR do?

This PR replaces the LED model card with a new model card matching the format introduced in https://github.com/huggingface/transformers/issues/36979.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

## Who can review?
@stevhliu 


Comments:
Thank you for the feedback, @stevhliu! I applied your suggestions.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39233). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Clarify per_device_train_batch_size scaling in TrainingArguments (#38…
Author: Shohail-Ismail
Pull request: yes

## What does this PR do?

This PR clarifies in the `TrainingArguments` docstring that `per_device_train_batch_size`
is multiplied by the number of devices when training on multiple GPUs or with distributed training.

Closes #38484

## Before submitting

- [x] This PR fixes a typo or improves the docs

## Who can review?

- @zach-huggingface  
- @SunMarc  
- @qgallouedec  


Comments:
Usually we call it the _global_ batch size

Ready for final review and merge. Thanks!

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_38857). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length.
Author: mumu029
Pull request: no
Labels: name: bug

### System Info

```bash
Traceback (most recent call last):
  File "/home/cx/miniconda3/envs/demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 767, in convert_to_tensors
    tensor = as_tensor(value)
  File "/home/cx/miniconda3/envs/demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 729, in as_tensor
    return torch.tensor(value)
ValueError: expected sequence of length 15757 at dim 1 (got 16242)
```
*DataCollatorForLanguageModeling* seems to only padding input ids and ignore labels, resulting in different lengths of labels in a batch. Why is this?

### Who can help?

_No response_

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

```python
def _process_fn(samples, tokenizer : PreTrainedTokenizerFast, config):
    samples = [[{"role" : "user", "content" : x[0]}, {"role" : "assistant", "content" : x[1]}]
                for x in zip(samples["input"], samples["output"])]
    # tokenized_data = tokenizer.apply_chat_template(samples, 
    #                                             return_tensors="pt",
    #                                             return_dict=True,
    #                                             padding="max_length",
    #                                             truncation=True,
    #                                             max_length=8000)
    tokenized_data = tokenizer.apply_chat_template(samples, 
                                                return_tensors="pt",
                                                return_dict=True,
                                                padding=True
                                                )
    samples_ids = tokenized_data["input_ids"]
    attention_mask = tokenized_data["attention_mask"]
    output_ids = []
    for i, seq in enumerate(samples_ids):
        output_index = torch.where(seq == SPECIAL_GENERATE_TOKEN_ID)[0]
        mask = attention_mask[i]
        if len(output_index) == 1:
            output_index = output_index[0].item()
        else:
            continue
        temp = torch.full_like(seq, -100)
        temp[output_index:] = seq[output_index:]
        temp[mask == 0] = -100
        output_ids.append(temp)

    labels = torch.stack(output_ids)
    return {"input_ids" : samples_ids,
            "labels" : labels,
            "attention_mask" : attention_mask}

trainer = Trainer(
        model=peft_model,
        args=train_config,
        train_dataset=train_data,
        eval_dataset=eval_data,
        data_collator=DataCollatorForLanguageModeling(
            tokenizer=tokenizer,
            mlm=False,
            pad_to_multiple_of=8 if torch.cuda.is_available() else None,
            return_tensors="pt"
        )
    )
```


### Expected behavior

run code

Comments:
Unable to deploy Gemma 3 on AWS SageMaker due to lack of support in tranfomers release
Author: ehrun32
Pull request: no

hi,

it seems when i deploy the model

```
huggingface_model = HuggingFaceModel(
    model_data=model_s3_uri,    
    role=role,
    transformers_version="4.49.0",  
    pytorch_version="2.6.0",
    py_version="py312",
)

predictor = huggingface_model.deploy(
    instance_type="ml.g5.48xlarge",
    initial_instance_count=1,
    endpoint_name="gemma-27b-inference",
    container_startup_health_check_timeout=900
)

response = predictor.predict({
    "inputs": "what can i do?"
})
print(response)
```

```
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) 
from primary with message "{
  "code": 400,
  "type": "InternalServerException",
  "message": "The checkpoint you are trying to load has model type gemma3_text but Transformers does not 
recognize this architecture. This could be because of an issue with the checkpoint, or because your version of 
Transformers is out of date.\n\nYou can update Transformers with the command pip install --upgrade transformers.
```

now i know HuggingFaceModel doesnt support anything above 4.49.0 so if i try to run 4.50.0 it will give an error saying please use this version. the thing is gemma3 is not available in 4.49 so how to fix this? i have the model in my bucket trained just cant deploy it due to the versions of transformers. is there a way to override the container inside the huggingface that takes a more advanced transformer?

I did this, but the issue now is in sagemaker, cuz i cannot use this for the huggingface version as it doesn't support it
pip install git+https://github.com/huggingface/transformers@v4.49.0-Gemma-3

Comments:
Hey, I am not sure of your usecase but can you run this same model using normal transformers API in an virtual env. I usually install transformers from main in the script itself coz SM doesn't support latest like in this case. If you can do that then IG there won't be any issue

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
ModernBERT for MLM outputs incorrect hidden state shape.
Author: jfkback
Pull request: no
Labels: name: bug

### System Info

When using `ModernBERTForMaskedLM` with `output_hidden_states=True` the hidden state is not correctly padded when it is returned. A minimal example is included below:

```
import torch
from transformers import AutoTokenizer, ModernBertForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("answerdotai/ModernBERT-base")
model = ModernBertForMaskedLM.from_pretrained("answerdotai/ModernBERT-base").to("cuda")

inputs = tokenizer(
    [
        "The capital of France is <mask>.",
        "The name of the first president of the united states is <mask>.",
    ],
    padding=True,
    return_tensors="pt",
).to("cuda")

with torch.no_grad():
    outputs = model(**inputs, output_hidden_states=True)

print(inputs["attention_mask"].sum())
# >>> 26
print(outputs.hidden_states[-1].shape)
# >>> torch.Size([26, 768])


assert outputs.hidden_states[-1].shape == inputs["input_ids"].shape + (
    model.config.hidden_size,
)
```

I'm using the following library versions:
- `transformers==4.48.2`
- `torch==2.6.0`

It appears that what is returned is the flattened version as the tensor is 2D and the first dimension corresponds to the sum of the attention mask. This issue doesn't happen when using the non MLM version.

I searched modern bert and hidden state and looked at the recent commits and didn't see any mention of this issue, but it might have been fixed in a newer version without it being obvious.



### Who can help?

@ArthurZucker 

### Information

- [x] The official example scripts
- [x] 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

Run the code provided in the issue with flash attention on a Cuda GPU.

### Expected behavior

The hidden states should have shape [batch size, max sequence length, model dim] but they have shape [unknown dim (I think the number of unpadded tokens), model dim].

Comments:
@jfkback have you tried installing from `main` to see if the issue still exists? Use `pip install --upgrade git+https://github.com/huggingface/transformers.git`

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
Fix license text, duplicate assignment, and typo in constant names
Author: gudwls215
Pull request: yes

# What does this PR do?

This PR fixes several minor but important issues across the codebase:

1. **License text completion** in Italian documentation
2. **Code syntax error** in Perceiver model conversion script  
3. **Typo in metadata constant** name

## Changes Made

### 📄 Documentation Fix
- **File**: `docs/source/it/perf_train_special.md`
- **Issue**: Incomplete Apache License 2.0 text (missing ending)
- **Fix**: Added the missing license text ending

### 🐍 Code Syntax Fix  
- **File**: `src/transformers/models/perceiver/convert_perceiver_haiku_to_pytorch.py`
- **Issue**: Duplicate assignment `name = name = name.replace(...)`
- **Fix**: Removed duplicate assignment to `name = name.replace(...)`

### 🔧 Metadata Constant Fix
- **File**: `utils/update_metadata.py`
- **Issue**: Typo in constant name `"MODEL_FOR_FOR_VISION_2_SEQ_MAPPING_NAMES"` (duplicate "FOR")
- **Fix**: Corrected to `"MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES"`

## Testing

- All changes are minor text/syntax fixes
- No functional changes to model behavior
- Verified syntax correctness in Python files

## 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. (N/A - minor fixes)
- [x] Did you make sure to update the documentation with your changes? (Documentation fix included)
- [x] Did you write any new necessary tests? (N/A - no functional changes)

## Who can review?

@stevhliu (Documentation fixes) or any community member - these are minor text/syntax corrections.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39250). 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: perceiver
Skip `test_eager_matches sdpa generate` and update an integration test for blip-like models
Author: ydshieh
Pull request: yes

# What does this PR do?

For skip, see [this comment](https://github.com/huggingface/transformers/pull/38510#discussion_r2121138005). Let's make the CI report clean though for now.





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

run-slow: blip_2, instructblip, instructblipvideo

run-slow: blip_2, instructblip, instructblipvideo

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

models: ['models/blip_2', 'models/instructblip', 'models/instructblipvideo']
quantizations: [] ...

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

The failing slow CI jobs are all in multi-gpu runners, which are not treated at this moment.
remove broken block
Author: molbap
Pull request: yes

# What does this PR do?

Removes an unused (and broken) block in modular model converter. Tested on a few modular conversions, as long as we don't use `return super().<...method...>` it will not cause issues. 



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39255). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Request to add Doge
Author: LoserCheems
Pull request: no
Labels: name: New model

### Model description

Doge is an architecture that combines the advantages of state-space and self-attention. It solves the problem of self-attention getting lost in long sequences by computing **dynamic mask** from cached value states using zeroth-order holding. It can also use `wsd_scheduler` on top of dense weight checkpoints to **additionally train** a sparsely activated feedforward network expansion layer.

paper: https://arxiv.org/abs/2412.11834

### Open source status

- [x] The model implementation is available
- [x] The model weights are available

### Provide useful links for the implementation

Repository: https://github.com/LoserCheems/WonderfulMatrices
Weights: https://huggingface.co/collections/JingzeShi/doge-slm-677fd879f8c4fd0f43e05458

Comments:
Any plans to add AIMv2 in the model?
Author: nahidalam
Pull request: no
Labels: name: New model

### Model description

Is there a plan to add AIMv2 https://huggingface.co/collections/apple/aimv2-6720fe1558d94c7805f7688c as part of Huggingface Model? AIMv2 showed better performance than SigLIP. I think it will be helpful for the community to have AIMv2 in Huggingface Model.



### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

Model implementation: https://github.com/apple/ml-aim
Model weights: https://huggingface.co/collections/apple/aimv2-6720fe1558d94c7805f7688c

Comments:
I think we could accept a `modular` PR to add this, but we probably can't do it internally and will need someone from the community to handle it! cc @arthurzucker to see if he agrees

@Rocketknight1 @ArthurZucker  I can work on this New Model integration :hugs: 


@yaswanth19 if you are starting, happy to help

Sure! Feel free to tag us once the PR is ready, or if you run into any problems

Yep! All good as long as it's added with modular! 🤗 
Make sur to isolate the differences  to make everyone's life easier! 

@Rocketknight1 
@ArthurZucker 
Opened a pull request #35550
fix recompiles due to instance key, and deepcopy issues
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Deep copy and recompiles should be fixed

Comments:
![image](https://github.com/user-attachments/assets/1c02e4e1-f6dc-46f9-b8b7-4d681af8f082)
I don't know why but it works locally!

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

>tests/models/paligemma/test_modeling_paligemma.py::PaliGemmaForConditionalGenerationModelTest::test_generate_compile_model_forward

It's probably another issue but related. In the same python process, and if different model classes are used with compile, the decorator function `check_model_inputs` is still called multiple times, and causing the recompile issues ...
[CI] fix docs
Author: gante
Pull request: yes

# What does this PR do?

Fixes docs, causing red CI
- aimv2 bad return docstring (from #36625)
- `glossary` missing from the Korean table of contents (from #38804)

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

run-slow: aimv2

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39273). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[smollm3] add tokenizer mapping for `smollm3`
Author: gante
Pull request: yes
Labels: name: for patch

# What does this PR do?

Adds a tokenizer mapping for `smollm3`, which fixes the following script

```py
from transformers import pipeline

# tokenizer is infered from the model, through the tokenizer mapping
pipe = pipeline("text-generation", model="HuggingFaceTB/SmolLM3-3B-Base")
pipe("Once upon a time,")
```

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

run-slow: auto

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_39271). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Refactor `PretrainedConfig.__init__` method to make it more explicit
Author: qubvel
Pull request: yes

# What does this PR do?

Make the `__init__` method more explicit to highlight common arguments while creating a specific model config, so it's easier to understand if the argument should be passed to `super().__init__` or created in inherited config

cc @Cyrilvallez wdyt?


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

Feel free to merge when conflict is fixed and tests are green!