Dataset Viewer
Auto-converted to Parquet Duplicate
repo
string
github_id
int64
github_node_id
string
number
int64
html_url
string
api_url
string
title
string
body
string
state
string
state_reason
string
locked
bool
comments_count
int64
labels
list
assignees
list
created_at
string
updated_at
string
closed_at
string
author_association
string
milestone_title
string
snapshot_id
string
extracted_at
string
author_login
string
author_id
int64
author_node_id
string
author_type
string
author_site_admin
bool
huggingface/transformers
1,050,733,132
I_kwDOCUB6oc4-oOpM
14,368
https://github.com/huggingface/transformers/issues/14368
https://api.github.com/repos/huggingface/transformers/issues/14368
Export LayoutLMv2 to onnx
I am trying to export LayoutLMv2 model to onnx but there is no support for that available in transformers library. I have tried to follow the method available for layoutLM but that is not working. Here is config class for LayoutLMv2 ``` class LayoutLMv2OnnxConfig(OnnxConfig): def __init__( self, config: PretrainedConfig, task: str = "default", patching_specs: List[PatchingSpec] = None, ): super().__init__(config, task=task, patching_specs=patching_specs) self.max_2d_positions = config.max_2d_position_embeddings - 1 @property def inputs(self) -> Mapping[str, Mapping[int, str]]: return OrderedDict( [ ("input_ids", {0: "batch", 1: "sequence"}), ("bbox", {0: "batch", 1: "sequence"}), ("image", {0: "batch", 1: "sequence"}), ("attention_mask", {0: "batch", 1: "sequence"}), ("token_type_ids", {0: "batch", 1: "sequence"}), ] ) def generate_dummy_inputs( self, tokenizer: PreTrainedTokenizer, batch_size: int = -1, seq_length: int = -1, is_pair: bool = False, framework: Optional[TensorType] = None, ) -> Mapping[str, Any]: """ Generate inputs to provide to the ONNX exporter for the specific framework Args: tokenizer: The tokenizer associated with this model configuration batch_size: The batch size (int) to export the model for (-1 means dynamic axis) seq_length: The sequence length (int) to export the model for (-1 means dynamic axis) is_pair: Indicate if the input is a pair (sentence 1, sentence 2) framework: The framework (optional) the tokenizer will generate tensor for Returns: Mapping[str, Tensor] holding the kwargs to provide to the model's forward function """ input_dict = super().generate_dummy_inputs(tokenizer, batch_size, seq_length, is_pair, framework) # Generate a dummy bbox box = [48, 84, 73, 128] if not framework == TensorType.PYTORCH: raise NotImplementedError("Exporting LayoutLM to ONNX is currently only supported for PyTorch.") if not is_torch_available(): raise ValueError("Cannot generate dummy inputs without PyTorch installed.") import torch batch_size, seq_length = input_dict["input_ids"].shape input_dict["bbox"] = torch.tensor([*[box] * seq_length]).tile(batch_size, 1, 1) return input_dict onnx_config = LayoutLMv2OnnxConfig(model.config) export(tokenizer=tokenizer, model=model, config=onnx_config, opset=12, output=Path('onnx/layoutlmv2.onnx')) ``` Running the export line is raising this error, ``` --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-25-99a1f167e396> in <module>() ----> 1 export(tokenizer=tokenizer, model=model, config=onnx_config, opset=12, output=Path('onnx/layoutlmv2.onnx')) 3 frames /usr/local/lib/python3.7/dist-packages/transformers/models/layoutlmv2/tokenization_layoutlmv2.py in __call__(self, text, text_pair, boxes, word_labels, add_special_tokens, padding, truncation, max_length, stride, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs) 449 450 words = text if text_pair is None else text_pair --> 451 assert boxes is not None, "You must provide corresponding bounding boxes" 452 if is_batched: 453 assert len(words) == len(boxes), "You must provide words and boxes for an equal amount of examples" AssertionError: You must provide corresponding bounding boxes ```
closed
completed
false
28
[ "Good First Issue" ]
[]
2021-11-11T08:54:39Z
2026-03-20T08:32:38Z
2026-03-20T08:32:16Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
fadi212
37,739,280
MDQ6VXNlcjM3NzM5Mjgw
User
false
huggingface/transformers
2,363,874,975
I_kwDOCUB6oc6M5d6f
31,515
https://github.com/huggingface/transformers/issues/31515
https://api.github.com/repos/huggingface/transformers/issues/31515
from_pretrained 加载checkpoint过慢的问题
### System Info latest python3.9.8 ### 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 我用ollama加载模型明显比上述方法快,有没有办法可以提高加载速度 ### Expected behavior 1
closed
completed
false
3
[]
[]
2024-06-20T08:41:06Z
2026-03-20T03:44:30Z
2024-07-29T08:04:21Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
zhaoyuchen1128
167,266,669
U_kgDOCfhJbQ
User
false
huggingface/transformers
2,418,835,728
I_kwDOCUB6oc6QLIEQ
32,090
https://github.com/huggingface/transformers/issues/32090
https://api.github.com/repos/huggingface/transformers/issues/32090
[Error] with Trainer: TypeError: Unsupported types (<class 'NoneType'>) passed to `_gpu_broadcast_one`.
### System Info - `transformers` version: 4.42.4 - Platform: Linux-5.15.0-101-generic-x86_64-with-glibc2.35 - Python version: 3.10.13 - Huggingface_hub version: 0.24.0 - Safetensors version: 0.4.2 - Accelerate version: 0.32.0 - Accelerate config: not found - PyTorch version (GPU?): 2.3.1+cu121 (False) - Tensorflow version (GPU?): not installed (NA) - Flax version (CPU?/GPU?/TPU?): not installed (NA) - Jax version: not installed - JaxLib version: not installed - Using distributed or parallel set-up in script?: <fill in> ### Who can help? @muellerzr @SunMarc @ArthurZucker ### 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 https://gist.github.com/halixness/eadd6d1d89ae48597f70cb09f2b44139 ### Expected behavior Hello, I have written a simple training script to train from scratch a gpt2-like model with a large dataset of strings (molecules in SMILES format). After around ~2k steps (`batch_size=128`, `#samples = ~1.5M`), I encounter the following error: ``` TypeError: Unsupported types (<class 'NoneType'>) passed to `_gpu_broadcast_one`. Only nested list/tuple/dicts of objects that are valid for `is_torch_tensor` should be passed. ``` I tried already: - to use the `default_data_collator` instead and to manually group samples as in [in the official example](https://github.com/huggingface/transformers/blob/89575b567e061fd87bdd655ba188b6c7a922d54a/examples/pytorch/language-modeling/run_clm.py#L513). - to check manually for the value of the batch that makes the script crash apparently: no NaN values, it all seems to make sense. - to check whether the dataset initially contains any empty or None strings, which is not the case. I'm not sure about what could case this error. Any suggestion is much appreciated!
closed
completed
false
3
[ "trainer", "bug" ]
[]
2024-07-19T13:01:37Z
2026-03-20T06:22:10Z
2024-09-22T08:06:59Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
halixness
20,798,848
MDQ6VXNlcjIwNzk4ODQ4
User
false
huggingface/transformers
2,914,781,972
I_kwDOCUB6oc6tvAsU
36,683
https://github.com/huggingface/transformers/issues/36683
https://api.github.com/repos/huggingface/transformers/issues/36683
AttributeError: 'Gemma3Config' object has no attribute 'vocab_size'
### System Info v4.50.0.dev0 ### Who can help? @ArthurZucker @LysandreJik @xenova ### 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 I am trying to run the new Gemma3 model, using version '4.50.0.dev0'. When loading the model I get the error: 'Gemma3Config' object has no attribute 'vocab_size'. Looking into this it seems Gemma3Config has `vocab_size` nested in a "text_config" attribute. I try to load the model as AutoModelForCausalLM, running it with Gemma3ForConditionalGeneration does not raise this issue. Am I wrong in assuming I can run Gemma 3 as AutoModelForCausalLM? ### Expected behavior Loading the model as AutoModelForCausalLM.from_pretrained without issue.
open
reopened
false
39
[ "bug" ]
[]
2025-03-12T18:11:39Z
2026-03-23T13:36:49Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
jumelet
9,407,977
MDQ6VXNlcjk0MDc5Nzc=
User
false
huggingface/transformers
3,229,815,847
I_kwDOCUB6oc7AgxQn
39,404
https://github.com/huggingface/transformers/issues/39404
https://api.github.com/repos/huggingface/transformers/issues/39404
Whisper `return_language` with pipeline no longer working
### System Info Platform: Initially discovered on Nvidia. Can be reproduced on CPU and in Google Colab (see attached gist). - `transformers` version: 4.53.2 - Platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39 - Python version: 3.12.3 - Huggingface_hub version: 0.33.4 - Safetensors version: 0.5.3 - Accelerate version: 1.8.1 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.7.1+cu126 (CUDA) - Tensorflow version (GPU?): not installed (NA) - Flax version (CPU?/GPU?/TPU?): not installed (NA) - Jax version: not installed - JaxLib version: not installed - Using distributed or parallel set-up in script?: No - Using GPU in script?: Yes and No. - GPU type: NVIDIA GeForce RTX 3090 ### Who can help? @eustlb @ArthurZucker ### 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 <s>Sometime between `transformers==4.46.3` and `transfomers==4.53.2 (latest as of now)`,</s> At #34135, the `return_language` argument for pipeline stopped working. The ending timestamp for the last word is also missing. Example (exported from Google Colab): https://gist.github.com/Metric-Void/ce2b9fe2faed0cdf6e5fd328599fd4c7 Code for testing: ``` import torch from transformers import pipeline from transformers.configuration_utils import PretrainedConfig pipeline = pipeline( task="automatic-speech-recognition", model="openai/whisper-tiny", torch_dtype=torch.float16, config=PretrainedConfig( attn_implementation="flash_attention_2" ) ) result = pipeline("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac", return_language=True, return_timestamps='word') result["chunks"] ``` Before (`transformers==4.46.3`): ``` [{'text': ' I', 'timestamp': (1.04, 1.36), 'language': 'english'}, {'text': ' have', 'timestamp': (1.36, 1.68), 'language': 'english'}, {'text': ' a', 'timestamp': (1.68, 1.94), 'language': 'english'}, {'text': ' dream.', 'timestamp': (1.94, 3.82), 'language': 'english'}, {'text': ' Good', 'timestamp': (3.82, 3.98), 'language': 'english'}, {'text': ' one', 'timestamp': (3.98, 4.16), 'language': 'english'}, {'text': ' day.', 'timestamp': (4.16, 6.4), 'language': 'english'}, {'text': ' This', 'timestamp': (6.4, 6.58), 'language': 'english'}, {'text': ' nation', 'timestamp': (6.58, 7.24), 'language': 'english'}, {'text': ' will', 'timestamp': (7.24, 7.82), 'language': 'english'}, {'text': ' rise', 'timestamp': (7.82, 8.3), 'language': 'english'}, {'text': ' up.', 'timestamp': (8.3, 10.3), 'language': 'english'}, {'text': ' Live', 'timestamp': (10.3, 10.56), 'language': 'english'}, {'text': ' out', 'timestamp': (10.56, 10.98), 'language': 'english'}, {'text': ' the', 'timestamp': (10.98, 11.02), 'language': 'english'}, {'text': ' true', 'timestamp': (11.02, 11.3), 'language': 'english'}, {'text': ' meaning', 'timestamp': (11.3, 11.6), 'language': 'english'}, {'text': ' of', 'timestamp': (11.6, 11.86), 'language': 'english'}, {'text': ' its', 'timestamp': (11.86, 12.08), 'language': 'english'}, {'text': ' dream.', 'timestamp': (12.08, 12.98), 'language': 'english'}] ``` After (`transfomers==4.53.2`): ``` [{'text': ' I', 'timestamp': (1.04, 1.36), 'language': None}, {'text': ' have', 'timestamp': (1.36, 1.68), 'language': None}, {'text': ' a', 'timestamp': (1.68, 1.94), 'language': None}, {'text': ' dream.', 'timestamp': (1.94, 3.82), 'language': None}, {'text': ' But', 'timestamp': (3.82, 3.96), 'language': None}, {'text': ' one', 'timestamp': (3.96, 4.18), 'language': None}, {'text': ' day,', 'timestamp': (4.18, 6.22), 'language': None}, {'text': ' this', 'timestamp': (6.22, 6.58), 'language': None}, {'text': ' nation', 'timestamp': (6.58, 7.22), 'language': None}, {'text': ' will', 'timestamp': (7.22, 7.82), 'language': None}, {'text': ' rise', 'timestamp': (7.82, 8.3), 'language': None}, {'text': ' up,', 'timestamp': (8.3, 10.2), 'language': None}, {'text': ' live', 'timestamp': (10.2, 10.56), 'language': None}, {'text': ' out', 'timestamp': (10.56, 10.98), 'language': None}, {'text': ' the', 'timestamp': (10.98, 11.02), 'language': None}, {'text': ' true', 'timestamp': (11.02, 11.3), 'language': None}, {'text': ' meaning', 'timestamp': (11.3, 11.6), 'language': None}, {'text': ' of', 'timestamp': (11.6, 11.86), 'language': None}, {'text': ' its', 'timestamp': (11.86, 12.08), 'language': None}, {'text': ' dream.', 'timestamp': (12.08, None), 'language': None}] ``` ### Expected behavior The old behaviour was correct. Maybe related: #21311, #21427, #25138, #27604, #29520, #31572
open
reopened
false
12
[ "bug", "Audio" ]
[ "eustlb" ]
2025-07-14T19:36:46Z
2026-03-24T13:00:45Z
null
NONE
null
20260324T143453Z
2026-03-24T14:34:53Z
Metric-Void
21,335,640
MDQ6VXNlcjIxMzM1NjQw
User
false
huggingface/transformers
3,722,400,306
I_kwDOCUB6oc7d31Iy
42,832
https://github.com/huggingface/transformers/issues/42832
https://api.github.com/repos/huggingface/transformers/issues/42832
Question about tie_weights
Hi, I noticed that the logic of the tie_weights function has changed in the transformers 5.0.0rc. In v4.x, when tie_word_embeddings=True, weights between embed_tokens.weight and lm_head.weight were always tied, regardless of whether both tensors were present in the checkpoint. However, in v5.0.0rc, if both embed_tokens.weight and lm_head.weight are explicitly present in the checkpoint, the model no longer ties them, resulting in two independent copies of the weights. https://github.com/huggingface/transformers/blob/v5.0.0rc1/src/transformers/modeling_utils.py#L2362-L2369 This change affects training behavior: gradients will now be computed and applied separately to the two weight matrices, potentially leading to divergent updates and inconsistent model behavior compared to previous versions. I'm concerned this might introduce subtle training instabilities or break backward compatibility for users who expect tied embeddings and output layers by default (as was the case in v4.x). I’m wondering whether this change could lead to any unexpected problems?For example, although embed_tokens.weight and lm_head. weight exist in the checkpoint, I still want to tie these two weights. Thanks!
open
null
false
12
[]
[]
2025-12-12T07:52:43Z
2026-03-24T08:12:04Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
cjw-d
73,046,570
MDQ6VXNlcjczMDQ2NTcw
User
false
huggingface/transformers
3,843,302,597
I_kwDOCUB6oc7lFCTF
43,412
https://github.com/huggingface/transformers/issues/43412
https://api.github.com/repos/huggingface/transformers/issues/43412
gemma3n executorch export fails missing self training guard and erfinv not supported
system info - transformers 5.0.0rc1 - torch 2.9.1 - executorch 1.0.1 - python 3.11 - ubuntu 24.04 who can help @ArthurZucker @younesbelkada information - the official example scripts tasks - an officially supported task in the examples folder problem description when exporting gemma3n models to executorch pte format using torch export there are two bugs that prevent successful export issue 1 missing self training guard causes constant is mutated error file transformers/models/gemma3n/modeling_gemma3n.py line 1119 the altup_coef_clip clamp operation runs during inference causing torch export to fail with cannot mutate a constant error current code ```python if self.config.altup_coef_clip is not None: self.correction_coefs.weight.data.clamp_(...) ``` fix ```python if self.training and self.config.altup_coef_clip is not None: self.correction_coefs.weight.data.clamp_(...) ``` issue 2 dynamic erfinv not supported by executorch file transformers/models/gemma3n/modeling_gemma3n.py gemma3ntextmlp class the _gaussian_topk method calls torch distributions normal Normal icdf during forward pass which uses erfinv an operator not in the executorch core aten opset fix pre compute std_multiplier at init time instead of during forward ```python # in __init__ add after self.activation_sparsity = ... if self.activation_sparsity > 0.0: normal_dist = torch.distributions.normal.Normal(0, 1) std_multiplier = normal_dist.icdf(torch.tensor(self.activation_sparsity, dtype=torch.float32)) self.register_buffer("_std_multiplier", std_multiplier, persistent=False) # replace _gaussian_topk method def _gaussian_topk(self, inputs: torch.Tensor) -> torch.Tensor: std_multiplier = self._std_multiplier.to(inputs.dtype) inputs_mean = torch.mean(inputs, dim=-1, keepdim=True) inputs_std = torch.std(inputs, dim=-1, keepdim=True, unbiased=False) cutoff_x = inputs_mean + inputs_std * std_multiplier return nn.functional.relu(inputs - cutoff_x) ``` expected behavior gemma3n models should export to executorch pte format without requiring manual patches reproduction ```bash pip install torch transformers executorch ``` ```python from transformers import AutoModelForCausalLM import torch from executorch.exir import to_edge, EdgeCompileConfig model = AutoModelForCausalLM.from_pretrained('google/gemma-3n-E2B-it', torch_dtype=torch.float16) text_model = model.language_model text_model.lm_head = model.lm_head ep = torch.export.export(text_model, (torch.zeros(1, 32, dtype=torch.long),), strict=False) et = to_edge(ep, compile_config=EdgeCompileConfig(_check_ir_validity=False)) et.to_executorch() ``` additional context successfully exported both e2b 8.4gb and e4b 13.1gb text only models after applying these patches reproduction repo https://github.com/maceip/gemma3n-executorch exported models - https://huggingface.co/macmacmacmac/gemma-3n-E2B-it-pte - https://huggingface.co/macmacmacmac/gemma-3n-E4B-it-pte - https://huggingface.co/macmacmacmac/odml-bench
open
null
false
5
[]
[]
2026-01-22T14:51:37Z
2026-03-20T08:08:47Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
maceip
804,368
MDQ6VXNlcjgwNDM2OA==
User
false
huggingface/transformers
3,871,334,543
I_kwDOCUB6oc7mv-CP
43,604
https://github.com/huggingface/transformers/issues/43604
https://api.github.com/repos/huggingface/transformers/issues/43604
Revisit the condition for scaling the loss
Gradient accumulation requires scaled loss. Normally, loss scaling in the `Trainer` class depends on whether the model accepts loss-related kwargs. https://github.com/huggingface/transformers/blob/e7a2c0cc3471df9df0dd3ee739d1e1e034d549e0/src/transformers/trainer.py#L3827-L3930 In most custom trainers, we compute our own loss, but we still want to enable loss scaling in the parent class. The only way to do it a bit fragile: ```python # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set # self.model_accepts_loss_kwargs to False to enable scaling. self.model_accepts_loss_kwargs = False ``` check the TRL repo, there are many occurence like this: https://github.com/huggingface/trl/blob/7a530ba6d2ebf4101aaeb8002cd51c9bde4fb721/trl/experimental/kto/kto_trainer.py#L687 also related https://github.com/huggingface/trl/issues/2617
closed
completed
false
1
[]
[]
2026-01-29T15:42:54Z
2026-03-20T08:08:40Z
2026-03-20T08:08:40Z
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
qgallouedec
45,557,362
MDQ6VXNlcjQ1NTU3MzYy
User
false
huggingface/transformers
3,903,764,009
I_kwDOCUB6oc7orrYp
43,782
https://github.com/huggingface/transformers/issues/43782
https://api.github.com/repos/huggingface/transformers/issues/43782
Qwen3VLForConditionalGeneration.from_pretrained weight_only = True error
### System Info platform: ubuntu 24.04.03 python 3.10 transformers 5.0 torch 2.10 accelerate 1.12 docker image: FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04 https://huggingface.co/Qwen/Qwen3-VL-8B-Instruct ### Who can help? @yonigozlan @molbap ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction ` _pickle.UnpicklingError: Weights only load failed. In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. web-1 | Please file an issue with the following so that we can make `weights_only=True` compatible with your use case: WeightsUnpickler error: ` I get the error when i try to run the code below import logging import os import torch from typing import Optional, Dict from PIL import Image from transformers import Qwen3VLForConditionalGeneration, AutoProcessor from app.core.config import settings logger = logging.getLogger(__name__) class LocalQwenVisionService: _instance = None def __new__(cls, model_path: Optional[str] = None): if cls._instance is None: cls._instance = super().__new__(cls) cls._instance._initialized = False return cls._instance def __init__(self, model_path: Optional[str] = None): if self._initialized: return self.model_path = model_path or settings.QWEN_MODEL_PATH if not self.model_path or not os.path.exists(self.model_path): raise ValueError(f"Model path invalid: {self.model_path}") logger.info(f"🚀 Loading Qwen3-VL from: {self.model_path}") self.model = Qwen3VLForConditionalGeneration.from_pretrained( self.model_path, dtype=torch.float16, attn_implementation="sdpa", local_files_only=True, weights_only=False ) self.processor = AutoProcessor.from_pretrained( self.model_path, local_files_only=True ) logger.info(f"✅ Model loaded on: {next(self.model.parameters()).device}") self._initialized = True def analyze_image( self, image_path: str, prompt: Optional[str] = None ) -> Dict: """✅ Analyze image and return response""" if not os.path.exists(image_path): return {"status": "error", "error": f"Image not found: {image_path}"} if not prompt: prompt = ( "Analyze this image and provide:\n" "1. Description of content\n" "2. Main objects and locations\n" "3. Atmosphere and mood\n" "4. Tags/categories\n" "5. One-sentence summary" ) try: image = Image.open(image_path).convert("RGB") messages = [ { "role": "user", "content": [ {"type": "image", "url": image}, {"type": "text", "text": prompt} ] } ] inputs = self.processor( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors='pt' ) generated_ids = self.model.generate( **inputs, max_new_tokens=1024 ) generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) ] response_text = self.processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False )[0] return { "status": "success", "message": response_text } except Exception as e: logger.error(f"❌ Error: {e}") return {"status": "error", "error": str(e)} def close(self): """Clean up resources""" logger.info("🛑 Closing model") if hasattr(self, "model"): del self.model torch.cuda.empty_cache() What i tried ENV TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 - to docker file didnt help weights_only=False - inside Qwen3VLForConditionalGeneration.from_pretrained - didnt help import numpy import torch.serialization torch.serialization.add_safe_globals([ (numpy._core.multiarray.scalar, 'numpy.core.multiarray.scalar'), numpy.dtype, numpy.dtypes.Float64DType ]) - didnt help ### Expected behavior I have no clue where should i dig to fix the problem.
open
null
false
3
[ "bug" ]
[]
2026-02-05T21:52:13Z
2026-03-20T08:08:34Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
oscars17
57,970,391
MDQ6VXNlcjU3OTcwMzkx
User
false
huggingface/transformers
3,911,668,331
I_kwDOCUB6oc7pJ1Jr
43,824
https://github.com/huggingface/transformers/issues/43824
https://api.github.com/repos/huggingface/transformers/issues/43824
ImportError: cannot import name 'Qwen2_5_VLForConditionalGeneration' from 'transformers'
### System Info ``` Traceback (most recent call last): File "/home/wbrione/.conda/envs/watt_ai/bin/transformers", line 3, in <module> from transformers.cli.transformers import main File "/home/wbrione/.conda/envs/watt_ai/lib/python3.10/site-packages/transformers/cli/transformers.py", line 22, in <module> from transformers.cli.serve import Serve File "/home/wbrione/.conda/envs/watt_ai/lib/python3.10/site-packages/transformers/cli/serve.py", line 360, in <module> class Serve: File "/home/wbrione/.conda/envs/watt_ai/lib/python3.10/site-packages/transformers/cli/serve.py", line 588, in Serve validator: TypeAdapter, NameError: name 'TypeAdapter' is not defined ``` ### Who can help? @yonigozlan @molbap ### 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 ```python !pip install --upgrade --force-reinstall torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124 import os os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" import torch import os import json import time from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor from qwen_vl_utils import process_vision_info # Load AWQ quantized model # Note: Using "auto" for torch_dtype as recommended in the documentation model = Qwen2_5_VLForConditionalGeneration.from_pretrained( "Qwen/Qwen2.5-VL-72B-Instruct-AWQ", torch_dtype = "auto", device_map = "auto" ) ``` ### Expected behavior Import Qwen2 from transformers so I can run the rest of my code.
closed
completed
false
11
[ "bug" ]
[]
2026-02-08T00:48:13Z
2026-03-23T08:15:17Z
2026-03-23T08:15:17Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
waltwalt36
197,971,906
U_kgDOC8zPwg
User
false
huggingface/transformers
3,915,467,750
I_kwDOCUB6oc7pYUvm
43,856
https://github.com/huggingface/transformers/issues/43856
https://api.github.com/repos/huggingface/transformers/issues/43856
Inefficient memory usage during Qwen3 MoE training
### System Info - `transformers` version: 4.57.3 - Platform: Linux-6.8.0-90-generic-x86_64-with-glibc2.35 - Python version: 3.12.12 - Huggingface_hub version: 0.36.0 - Safetensors version: 0.7.0 - Accelerate version: 1.12.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.9.0+cu126 (CUDA) - Tensorflow version (GPU?): not installed (NA) - Flax version (CPU?/GPU?/TPU?): not installed (NA) - Jax version: not installed - JaxLib version: not installed - Using distributed or parallel set-up in script?: <fill in> - Using GPU in script?: <fill in> - GPU type: NVIDIA H100 80GB HBM3 ### Who can help? @ArthurZucker @Cyrilvallez ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction [train_qlora_memory.py](https://github.com/user-attachments/files/25179495/train_qlora_memory.py) [adapter_config.json](https://github.com/user-attachments/files/25179496/adapter_config.json) Run with: ``` CUDA_VISIBLE_DEVICES=0 PYTORCH_ALLOC_CONF=expandable_segments:True,garbage_collection_threshold:0.8,max_split_size_mb:128 python train_qlora_memory.py "Qwen3/Qwen3-30B-A3B-Instruct-2507" --max_seq_length 1024 --batch_size 1 --max_steps 5 --path_config adapter_config.json --use_liger --use_gc ``` Output: ``` torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 MiB. GPU 0 has a total capacity of 79.19 GiB of which 2.50 MiB is free. Process 2253701 has 79.18 GiB memory in use. Of the allocated memory 51.31 GiB is allocated by PyTorch, and 27.15 GiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables) ``` Output confirming memory inefficiency: `27.15 GiB is reserved by PyTorch but unallocated`! -- By the way, quantizing the model using **bitsandbytes** is also[ inefficient and leads to high memory consumption](https://github.com/bitsandbytes-foundation/bitsandbytes/issues/1849#issuecomment-3870385400): with **4-bit quantization** of the model **30B**, the actual memory consumption after loading the model is **46.75 GB** instead of the expected **16 GB**! ### Expected behavior ``` Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 16/16 [00:19<00:00, 1.24s/it] LoraConfig(task_type=None, peft_type=<PeftType.LORA: 'LORA'>, auto_mapping=None, peft_version='0.18.0', base_model_name_or_path=None, revision=None, inference_mode=False, r=64, target_modules={'q_proj', 'o_proj', 'k_proj', 'v_proj', 'down_proj'}, exclude_modules=None, lora_alpha=64, lora_dropout=0.0, fan_in_fan_out=False, bias='none', use_rslora=False, modules_to_save=None, init_lora_weights=True, layers_to_transform=None, layers_pattern=None, rank_pattern={}, alpha_pattern={}, megatron_config=None, megatron_core='megatron.core', trainable_token_indices=None, loftq_config={}, eva_config=None, corda_config=None, use_dora=False, alora_invocation_tokens=None, use_qalora=False, qalora_group_size=16, layer_replication=None, runtime_config=LoraRuntimeConfig(ephemeral_gpu_offload=False), lora_bias=False, target_parameters=None, arrow_config=None, ensure_weight_tying=False) trainable params: 1,160,773,632 || all params: 31,692,896,256 || trainable%: 3.6626 Gradient Checkpointing enabled step 0 seq_length 1024 loss 11.360670 time 18.22s step 1 seq_length 1024 loss 11.471191 time 14.65s step 2 seq_length 1024 loss 11.253231 time 13.13s step 3 seq_length 1024 loss 11.337120 time 11.62s step 4 seq_length 1024 loss 11.379625 time 11.16s cuda memory avg: 33269MB cuda memory max: 45740MB total time: 76.52s file size: 4429.8MB ```
closed
completed
false
6
[ "bug" ]
[]
2026-02-09T09:48:03Z
2026-03-23T08:15:13Z
2026-03-23T08:15:13Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
yurkoff-mv
82,467,993
MDQ6VXNlcjgyNDY3OTkz
User
false
huggingface/transformers
3,925,350,527
I_kwDOCUB6oc7p-Bh_
43,908
https://github.com/huggingface/transformers/issues/43908
https://api.github.com/repos/huggingface/transformers/issues/43908
What is the process of adding a new hardware backend for Trainer?
I work in Qualcomm and we have a hardware backend like cuda / mps. I want to add it in the Trainer so that we can use Trainer class to perform training on our stack. What is the process of adding it? We have a branch which currently adds the backend specific changes: https://github.com/quic-meetkuma/transformers/tree/qaic_support Please guide on this. Will it be fine to directly raise a PR or there will be subsequent steps that I should be taking care of?
closed
completed
false
5
[]
[]
2026-02-11T08:32:48Z
2026-03-23T08:15:11Z
2026-03-23T08:15:11Z
CONTRIBUTOR
null
20260324T120231Z
2026-03-24T12:02:31Z
quic-meetkuma
200,747,495
U_kgDOC_cp5w
User
false
huggingface/transformers
3,930,743,717
I_kwDOCUB6oc7qSmOl
43,939
https://github.com/huggingface/transformers/issues/43939
https://api.github.com/repos/huggingface/transformers/issues/43939
Better regex in `build_glob_alternation` method
I notice in the following code: https://github.com/huggingface/transformers/blob/4d5d49c34474be7cc2b6abd3179e7b317a17d8b1/src/transformers/core_model_loading.py#L67 https://github.com/huggingface/transformers/blob/4d5d49c34474be7cc2b6abd3179e7b317a17d8b1/src/transformers/core_model_loading.py#L75 The regex is formed by replace `*` with `.*`. I propose adding the escape character to signify the dot character `\.` and using the digit to better convey the message of looking for index in the model state dict keys `\d+` The changes would be ```diff -body = body.replace("*", r".*") +body = body.replace(".", r"\.") +body = body.replace("*", r"\d+") ``` I can add a PR to this if you think this would make more sense. CC: @ArthurZucker
closed
completed
false
2
[]
[]
2026-02-12T09:21:30Z
2026-03-23T08:15:08Z
2026-03-23T08:15:08Z
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
ariG23498
36,856,589
MDQ6VXNlcjM2ODU2NTg5
User
false
huggingface/transformers
3,944,737,576
I_kwDOCUB6oc7rH-so
44,016
https://github.com/huggingface/transformers/issues/44016
https://api.github.com/repos/huggingface/transformers/issues/44016
Syntax error in Transformer section 3 (Transformers, what can they do?) notebook
### System Info Build error due to syntax issue, -> from transformers import pipeline ner = pipeline("ner", grouped_entities=True)// remove parameter grouped_entities=True ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") Error log: Notes: - UNEXPECTED :can be ignored when loading from different task/architecture; not ok if you expect identical arch. --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipython-input-1735790534.py in <cell line: 0>() 1 from transformers import pipeline 2 ----> 3 ner = pipeline("ner", grouped_entities=True) 4 ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") 2 frames /usr/local/lib/python3.12/dist-packages/transformers/pipelines/base.py in __init__(self, model, tokenizer, feature_extractor, image_processor, processor, task, device, binary_output, **kwargs) 919 self._batch_size = kwargs.pop("batch_size", None) 920 self._num_workers = kwargs.pop("num_workers", None) --> 921 self._preprocess_params, self._forward_params, self._postprocess_params = self._sanitize_parameters(**kwargs) 922 923 # In processor only mode, we can get the modality processors from the processor TypeError: TokenClassificationPipeline._sanitize_parameters() got an unexpected keyword argument 'grouped_entities' ### Who can help? _No response_ ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction Just run the script and in the cell no 17 the build fails ### Expected behavior Updated cell: from transformers import pipeline ner = pipeline("ner") ner("My name is Sylvain and I work at Hugging Face in Brooklyn.")
closed
completed
false
7
[ "Good First Issue", "bug" ]
[]
2026-02-15T19:15:34Z
2026-03-23T17:00:09Z
2026-02-24T16:07:22Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
khyatimirani
29,675,392
MDQ6VXNlcjI5Njc1Mzky
User
false
huggingface/transformers
3,962,963,557
I_kwDOCUB6oc7sNgZl
44,155
https://github.com/huggingface/transformers/issues/44155
https://api.github.com/repos/huggingface/transformers/issues/44155
[AudioFlamingo3] Batched inference produces incorrect results due to embedding/token leak between tracks
### System Info - transformers version: 5.0.0 - Platform: Linux-5.14.0-284.30.1.el9_2.x86_64-x86_64-with-glibc2.39 - Python version: 3.12.3 - Huggingface_hub version: 1.4.1 - Safetensors version: 0.6.2 - Accelerate version: 1.11.0 - Accelerate config: not found - DeepSpeed version: 0.18.1 - PyTorch version (accelerator?): 2.8.0+cu128 (CUDA) - Using distributed or parallel set-up in script?: <fill in> - Using GPU in script?: <fill in> - GPU type: NVIDIA A100-SXM4-80GB ### Who can help? audio models: @eustlb @ebezzam @vasqu ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction Batched inference in `AudioFlamingo3ForConditionalGeneration` produces incorrect results. The same audio track receives completely different descriptions depending on other tracks in a batch. **Root cause:** The processor and model compute audio embedding counts differently: - Processor sums audio lengths across windows first, then applies downsampling formula - Model applies downsampling formula per window, then sums This causes a mismatch, and `masked_scatter` misaligns embeddings across items in a batch. ```python """ Reproduction script for AudioFlamingo3 batched inference bug. """ import torch import numpy as np import soundfile as sf from transformers import AudioFlamingo3ForConditionalGeneration, AutoProcessor # ============================================================ # Create TWO very different audio tracks # ============================================================ def create_aggressive_audio(duration_sec, filepath): """Aggressive, noisy, distorted audio.""" sr = 16000 n_samples = int(sr * duration_sec) t = np.linspace(0, duration_sec, n_samples, dtype=np.float32) # Heavy distorted bass bass = np.sin(2 * np.pi * 60 * t) bass = np.clip(bass * 3, -1, 1) # Noise noise = np.random.randn(n_samples).astype(np.float32) * 0.3 # Fast harsh percussion percussion = np.zeros(n_samples, dtype=np.float32) for i in range(0, n_samples, int(sr * 0.125)): decay = np.exp(-np.linspace(0, 10, min(int(sr*0.125), n_samples - i))) percussion[i:i+len(decay)] += decay * 0.5 # Harsh high frequencies harsh = np.sin(2 * np.pi * 3000 * t) * 0.2 audio = np.clip(0.4*bass + 0.3*noise + 0.2*percussion + 0.1*harsh, -0.95, 0.95) sf.write(filepath, audio.astype(np.float32), sr) return filepath def create_upbeat_audio(duration_sec, filepath): """Upbeat, cheerful, melodic audio.""" sr = 16000 n_samples = int(sr * duration_sec) t = np.linspace(0, duration_sec, n_samples, dtype=np.float32) # Cheerful melody (major scale) melody_freqs = [523, 587, 659, 784, 880] # C major pentatonic melody = np.zeros(n_samples, dtype=np.float32) note_len = int(sr * 0.25) for i in range(0, n_samples, note_len): freq = melody_freqs[(i // note_len) % len(melody_freqs)] end = min(i + note_len, n_samples) note_t = np.arange(end - i) / sr melody[i:end] += np.sin(2 * np.pi * freq * note_t) * np.exp(-note_t * 3) * 0.4 # Bouncy bass bass = np.sin(2 * np.pi * 150 * t) * 0.3 * (np.sin(2 * np.pi * 2 * t) > 0) # Light beat beat = np.zeros(n_samples, dtype=np.float32) for i in range(0, n_samples, int(sr * 0.5)): decay_len = min(int(sr * 0.05), n_samples - i) beat[i:i+decay_len] += np.exp(-np.linspace(0, 20, decay_len)) * 0.3 audio = np.clip(melody + bass + beat, -0.95, 0.95) sf.write(filepath, audio.astype(np.float32), sr) return filepath print("Creating test audio files...") track_a = create_aggressive_audio(259.0, "/tmp/track_aggressive.wav") track_b = create_upbeat_audio(239.0, "/tmp/track_upbeat.wav") print("\nLoading model...") processor = AutoProcessor.from_pretrained("nvidia/music-flamingo-hf") model = AudioFlamingo3ForConditionalGeneration.from_pretrained( "nvidia/music-flamingo-hf", device_map="auto", ) # ============================================================ # Helper function # ============================================================ def run_batch(paths): conversations = [ [{"role": "user", "content": [ {"type": "audio", "path": p}, {"type": "text", "text": "Describe this audio in detail. What mood and style does it have?"} ]}] for p in paths ] inputs = processor.apply_chat_template( conversations, tokenize=True, add_generation_prompt=True, return_dict=True, ).to(model.device) inputs["input_features"] = inputs["input_features"].to(dtype=model.dtype) with torch.no_grad(): outputs = model.generate(**inputs, max_new_tokens=100) return processor.batch_decode( outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True ) def run_single(path): """Run inference on a single track (no batching = no contamination).""" return run_batch([path])[0] # ============================================================ # Test 1: Single track inference (CORRECT - no contamination) # ============================================================ print("\n" + "=" * 70) print("TEST 1: SINGLE TRACK INFERENCE (no batching)") print("=" * 70) result_a_single = run_single(track_a) result_b_single = run_single(track_b) print(f"\nTrack A alone:") print(f" {result_a_single[:200]}...") print(f"\nTrack B alone:") print(f" {result_b_single[:200]}...") # ============================================================ # Test 2: Batched inference (BUGGY - contamination occurs) # ============================================================ print("\n" + "=" * 70) print("TEST 2: BATCHED INFERENCE (both tracks together)") print("=" * 70) results_batched = run_batch([track_a, track_b]) print(f"\nTrack A in batch:") print(f" {results_batched[0][:200]}...") print(f"\nTrack B in batch:") print(f" {results_batched[1][:200]}...") # ============================================================ # Comparison # ============================================================ print("\n" + "=" * 70) print("COMPARISON: Track B ") print("=" * 70) print(f"\nWhen processed ALONE (correct):") print(f" {result_b_single[:250]}...") print(f"\nWhen processed in BATCH:") print(f" {results_batched[1][:250]}...") ``` My output is: ``` ====================================================================== COMPARISON: Track B ====================================================================== When processed ALONE (correct): This track is a minimalist electronic piece that blends ambient and experimental styles. It features a steady, repetitive synth melody with a clean, digital timbre, set in a moderate tempo of 120 BPM and a 4/4 time signature. The production is sparse... When processed in BATCH: This track is a minimalist electronic piece that blends ambient and experimental styles, creating a calm, introspective atmosphere. It features a steady 4/4 beat at 120 BPM and is set in C major. The harmonic content is sparse, alternating between mo... ``` 1. As we can see, there is a difference in the result. 2. The difference even more severe if we infer real music tracks from completely different genres like soft music and heavy. For the batch of two of them, the last one can be completely mislead by previous. ### Expected behavior The outputs should be identical in all cases and not affected by other elements in a batch. ## Suggested Fix The model's `get_audio_features` should group embeddings by sample and use the same formula as the processor: ```python def get_audio_features(self, input_features, input_features_mask, windows_per_sample, **kwargs): audio_output = self.audio_tower(input_features, input_features_mask=input_features_mask, return_dict=True, **kwargs) audio_embeds = self.multi_modal_projector(audio_output.last_hidden_state) post_lengths = (input_features_mask.sum(-1) - 2) // 2 + 1 all_sample_embeds = [] window_idx = 0 for n_windows in windows_per_sample: sample_mask = input_features_mask[window_idx:window_idx + n_windows] total_mask_sum = sample_mask.sum() # Use processor's formula conv_length = (total_mask_sum - 1) // 2 + 1 token_count = int(((conv_length - 2) // 2 + 1).item()) sample_embeds = audio_embeds[window_idx:window_idx + n_windows] sample_post_lengths = post_lengths[window_idx:window_idx + n_windows] max_len = sample_embeds.shape[1] valid_mask = torch.arange(max_len, device=sample_post_lengths.device)[None, :] < sample_post_lengths[:, None] sample_flat = sample_embeds[valid_mask][:token_count] all_sample_embeds.append(sample_flat) window_idx += n_windows return torch.cat(all_sample_embeds, dim=0) ``` This requires passing `windows_per_sample` from the processor to the model, which may need API changes. ```python # Constants from processor SAMPLING_RATE = 16000 CHUNK_LENGTH = 30.0 MAX_AUDIO_LEN = 600 WINDOW_SIZE = int(SAMPLING_RATE * CHUNK_LENGTH) MAX_WINDOWS = int(MAX_AUDIO_LEN // CHUNK_LENGTH) def get_windows_per_sample(batch_paths): """Calculate number of windows for each audio file.""" windows_per_sample = [] for path in batch_paths: audio, sr = librosa.load(path, sr=SAMPLING_RATE) n_samples = len(audio) n_windows = max(1, (n_samples + WINDOW_SIZE - 1) // WINDOW_SIZE) if n_windows > MAX_WINDOWS: n_windows = MAX_WINDOWS windows_per_sample.append(n_windows) return windows_per_sample ```
open
null
false
2
[ "bug", "Audio" ]
[]
2026-02-19T13:20:07Z
2026-03-22T08:04:17Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
IvanBarabanau
34,709,713
MDQ6VXNlcjM0NzA5NzEz
User
false
huggingface/transformers
3,967,173,673
I_kwDOCUB6oc7sdkQp
44,169
https://github.com/huggingface/transformers/issues/44169
https://api.github.com/repos/huggingface/transformers/issues/44169
Need an example for FSDP + FP16 training
In my setup, I am trying to run FSDP with FP16 precision. Is there any limitation that I can not use FSDP with FP16 precision? How can I convert my existing code to FSDP for FP16 precision? I believe there is ShardedGradScaler from FSDP should be used. How is it different than normal GradScaler in terms of implementation? It will be great if someone share a concise example for this.
open
null
false
2
[]
[]
2026-02-20T08:04:37Z
2026-03-23T08:15:04Z
null
CONTRIBUTOR
null
20260324T120231Z
2026-03-24T12:02:31Z
quic-meetkuma
200,747,495
U_kgDOC_cp5w
User
false
huggingface/transformers
3,970,357,222
I_kwDOCUB6oc7sptfm
44,188
https://github.com/huggingface/transformers/issues/44188
https://api.github.com/repos/huggingface/transformers/issues/44188
Diverging attention kernels due to `allow_is_bidirectional_skip` branching on torch.compile
### System Info Hi, while we were updating the PyTorch transformers pin to v5.2.0, our regression tests caught a numerics issue between eager and compiled, the difference is very substantial (3.3 vs the typical e-4 accepted difference). Digging into it: https://github.com/pytorch/pytorch/pull/175274#issuecomment-3930952666, we found the cause to be in these lines (added in https://github.com/huggingface/transformers/pull/41265): https://github.com/huggingface/transformers/blob/147b7aa040812b079f467e777a2d2e1284167de0/src/transformers/masking_utils.py#L490-L491 We set `allow_is_bidirectional_skip=True` in a few places: https://github.com/huggingface/transformers/blob/147b7aa040812b079f467e777a2d2e1284167de0/src/transformers/masking_utils.py#L996-L997 And in `_ignore_bidirectional_mask_sdpa`, we branch logic on whether we compile or not: https://github.com/huggingface/transformers/blob/147b7aa040812b079f467e777a2d2e1284167de0/src/transformers/masking_utils.py#L324-L332 This issue was found on BERT but it seems like it would affect other models too. We've also verified that removing the branching fixes the numerical difference. I'm creating this issue to ask about the best way forward here. From the PR that added it, it looks like this was necessary specifically for executorch, but the algorithm difference is also affected all other APIs that fall under `is_tracing` . Can we restrict the check? ### Who can help? @vasqu @ArthurZucker @Cyrilvallez ### 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 I believe the description is enough, but I can provide a simpler repro on request ### Expected behavior transformers users probably shouldn't run into large numeric differences when compiling, at least not by default
open
null
false
8
[ "bug" ]
[]
2026-02-20T21:01:05Z
2026-03-23T08:15:02Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
xmfan
9,547,562
MDQ6VXNlcjk1NDc1NjI=
User
false
huggingface/transformers
3,973,467,921
I_kwDOCUB6oc7s1k8R
44,208
https://github.com/huggingface/transformers/issues/44208
https://api.github.com/repos/huggingface/transformers/issues/44208
request refund
I’m having a problem. I added my prepaid card, but the subscription was not accepted because the platform does not accept prepaid cards. However, the amount was deducted from my balance, and now I have neither the balance nor the Pro plan. I need a refund since I won’t be able to use the platform.
closed
completed
false
2
[]
[]
2026-02-22T03:42:03Z
2026-03-24T13:31:02Z
2026-03-24T13:31:02Z
NONE
null
20260324T143453Z
2026-03-24T14:34:53Z
storescienza-gif
263,101,692
U_kgDOD66c_A
User
false
huggingface/transformers
4,027,812,864
I_kwDOCUB6oc7wE4wA
44,462
https://github.com/huggingface/transformers/issues/44462
https://api.github.com/repos/huggingface/transformers/issues/44462
AutoTokenizer ignores tokenizer.json from the repository
### System Info - `transformers` version: 5.3.0 - Python version: 3.10.12 - Huggingface_hub version: 1.5.0 ### Who can help? @ArthurZucker and @itazap ### Information - [ ] 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 `AutoTokenizer` doesn't load tokenizer based on `tokenizer.json` from the repository. Saving this tokenizer produces different `tokenizer.json` file. ```python from transformers import AutoTokenizer hf_tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-instruct") hf_tokenizer.save_pretrained("hf_deepseek_tokenizer/") ``` [tokenizer_original.json](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-instruct/raw/main/tokenizer.json) [tokenizer_saved.json](https://github.com/user-attachments/files/25766810/tokenizer_saved.json) Original normalizer/pre-tokenizer: ```json "normalizer": { "type": "Sequence", "normalizers": [] }, "pre_tokenizer": { "type": "Sequence", "pretokenizers": [ { "type": "Split", "pattern": { "Regex": "[\r\n]" }, "behavior": "Isolated", "invert": false }, { "type": "Split", "pattern": { "Regex": "\\s?\\p{L}+" }, "behavior": "Isolated", "invert": false }, { "type": "Split", "pattern": { "Regex": "\\s?\\p{P}+" }, "behavior": "Isolated", "invert": false }, { "type": "Split", "pattern": { "Regex": "[一-龥ࠀ-一가-퟿]+" }, "behavior": "Isolated", "invert": false }, { "type": "Digits", "individual_digits": true }, { "type": "ByteLevel", "add_prefix_space": false, "trim_offsets": true, "use_regex": false } ] } ``` Saved normalizer/pre-tokenizer: ```json "normalizer": null, "pre_tokenizer": { "type": "Metaspace", "replacement": "▁", "prepend_scheme": "always", "split": false }, ``` ### Expected behavior Original `tokenizer.json` should be used to instantiate the tokenizer.
closed
completed
false
3
[ "bug" ]
[]
2026-03-05T12:04:31Z
2026-03-20T12:37:12Z
2026-03-20T12:37:12Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
apaniukov
51,917,466
MDQ6VXNlcjUxOTE3NDY2
User
false
huggingface/transformers
4,032,973,273
I_kwDOCUB6oc7wYknZ
44,488
https://github.com/huggingface/transformers/issues/44488
https://api.github.com/repos/huggingface/transformers/issues/44488
Current version also does not load "cjvt/sleng-bert"
### System Info broken config: Python 3.13.5 tokenizers 0.22.2 transformers 5.2.0 torch 2.7.1+cu118 working config: Python 3.13.5 tokenizers 0.22.1 transformers 4.57.1 torch 2.8.0+cu129 ### Who can help? @ArthurZucker @Cyrilvallez ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction ``` >>> from transformers import AutoTokenizer >>> bert_tokenizer = AutoTokenizer.from_pretrained("cjvt/sleng-bert") Traceback (most recent call last): File "<python-input-2>", line 1, in <module> bert_tokenizer = AutoTokenizer.from_pretrained("cjvt/sleng-bert") File "/nlp/scr/horatio/miniconda3/lib/python3.13/site-packages/transformers/models/auto/tokenization_auto.py", line 749, in from_pretrained return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nlp/scr/horatio/miniconda3/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1721, in from_pretrained return cls._from_pretrained( ~~~~~~~~~~~~~~~~~~~~^ resolved_vocab_files, ^^^^^^^^^^^^^^^^^^^^^ ...<9 lines>... **kwargs, ^^^^^^^^^ ) ^ File "/nlp/scr/horatio/miniconda3/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1910, in _from_pretrained tokenizer = cls(*init_inputs, **init_kwargs) File "/nlp/scr/horatio/miniconda3/lib/python3.13/site-packages/transformers/models/camembert/tokenization_camembert.py", line 118, in __init__ unk_index = next((i for i, (tok, _) in enumerate(self._vocab) if tok == str(unk_token)), 0) File "/nlp/scr/horatio/miniconda3/lib/python3.13/site-packages/transformers/models/camembert/tokenization_camembert.py", line 118, in <genexpr> unk_index = next((i for i, (tok, _) in enumerate(self._vocab) if tok == str(unk_token)), 0) ^^^^^^^^ ValueError: too many values to unpack (expected 2) ``` ### Expected behavior Loading the model would be great! The older version of transformers works fine.
closed
completed
false
14
[ "bug" ]
[]
2026-03-06T08:36:44Z
2026-03-24T10:05:50Z
2026-03-23T08:52:03Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
AngledLuffa
3,411,033
MDQ6VXNlcjM0MTEwMzM=
User
false
huggingface/transformers
4,040,512,605
I_kwDOCUB6oc7w1VRd
44,521
https://github.com/huggingface/transformers/issues/44521
https://api.github.com/repos/huggingface/transformers/issues/44521
apply_chat_template returns all-zero assistant_masks for multimodal inputs
### System Info transformers==5.3.0 ### Who can help? @ArthurZucker and @itazap ### 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 ```python from transformers import AutoProcessor messages = [ dict( role="user", content=[ dict(type="image", image="test.jpg"), dict(type="text", text="Describe the image above."), ], ), dict( role="assistant", content=[ dict(type="text", text="The image above shows a cat sitting on a table."), ], ), ] processor = AutoProcessor.from_pretrained("Qwen/Qwen3.5-0.8B") inputs = processor.apply_chat_template( messages, tokenize=True, return_dict=True, return_tensors="pt", return_assistant_tokens_mask=True, ) print(inputs["assistant_masks"]) ``` ### Actual behavior assistant_masks is all zeros. ### Expected behavior The tokens corresponding to the assistant response should be marked with 1 in assistant_masks. ### Suspected cause I think the issue comes from a mismatch between generation_indices and the final tokenized prompt in multimodal cases. In AutoProcessor.apply_chat_template, the assistant mask is computed roughly like this: ```python prompt, generation_indices = render_jinja_template( conversations=conversations, chat_template=chat_template, **template_kwargs, **special_tokens_map, ) ... out = self( text=prompt, images=batch_images if images_exist else None, videos=batch_videos if videos_exist else None, audio=batch_audios if batch_audios else None, **kwargs, ) ... offset_mapping = out.pop("offset_mapping") input_ids = out["input_ids"] for assistant_start_char, assistant_end_char in generation_indices[i]: start_pos = bisect.bisect_left(offset_starts, assistant_start_char) end_pos = bisect.bisect_left(offset_starts, assistant_end_char) ``` My understanding is: - generation_indices is computed from the rendered text prompt returned by render_jinja_template - but in multimodal processing, extra placeholder tokens such as <|image_pad|> are inserted later by the processor/tokenizer path - therefore offset_mapping corresponds to the expanded multimodal text, while generation_indices still refers to the pre-expanded text - this makes the character spans misaligned, so the assistant span lookup fails and assistant_masks ends up all zeros
open
null
false
7
[ "bug" ]
[]
2026-03-08T05:03:12Z
2026-03-24T14:46:59Z
null
NONE
null
20260324T145640Z
2026-03-24T14:56:40Z
renhouxing
36,196,749
MDQ6VXNlcjM2MTk2NzQ5
User
false
huggingface/transformers
4,044,495,369
I_kwDOCUB6oc7xEhoJ
44,541
https://github.com/huggingface/transformers/issues/44541
https://api.github.com/repos/huggingface/transformers/issues/44541
Can not deploy SFT Qwen3.5-9B model
### System Info I SFT Qwen3.5-9B model with transformers==5.2.0 ### Reproduction When I try to deploy my model with vllm==0.17.0, it reports: TypeError: Invalid type of HuggingFace config. Expected type: <class 'vllm.transformers_utils.configs.qwen3_5.Qwen3_5Config'>, but found type: <class 'transformers.models.qwen3_5.configuration_qwen3_5.Qwen3_5TextConfig'> I wonder how can I fix it. ### Expected behavior vllm==0.17.0 requires transformers<5, but transformers>5 is required to support Qwen3.5, kind of strange.
open
null
false
13
[ "bug" ]
[]
2026-03-09T09:39:19Z
2026-03-23T12:16:54Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
zouYC2021
66,997,535
MDQ6VXNlcjY2OTk3NTM1
User
false
huggingface/transformers
4,051,220,122
I_kwDOCUB6oc7xeLaa
44,568
https://github.com/huggingface/transformers/issues/44568
https://api.github.com/repos/huggingface/transformers/issues/44568
[BUG] add_special_tokens=True doesn't add BOS/EOS tokens for microsoft/mdeberta-v3-base tokenizer in transformers >=5.0
### System Info ## Version Details - Working version: transformers==4.48.0 - Broken versions: transformers==5.0.0, 5.1.0, 5.2.0, 5.3.0 ## Environment - transformers: 5.2.0 - tokenizers: 0.22.2 - Python: 3.12 - Platform: Linux ### Who can help? @ArthurZucker and @itazap ### 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 ## Description In transformers >=5.0, `add_special_tokens=True` doesn't add special tokens for `microsoft/mdeberta-v3-base` tokenizer. This is a regression from v4.x. ## Reproduction ```python from transformers import AutoTokenizer models = [ "microsoft/mdeberta-v3-base", "FacebookAI/roberta-base", "bert-base-uncased" ] for model_name in models: tokenizer = AutoTokenizer.from_pretrained(model_name) result = tokenizer("hello", add_special_tokens=True) print(f"{model_name}: input_ids={result['input_ids']}") ``` ## Additional Notes - The issue is MODEL-SPECIFIC, not general to all tokenizers - Only microsoft/mdeberta-v3-base is affected - The tokenizer has correct bos_token_id=1 and eos_token_id=2 values - This appears to be related to DeBERTa v3's SentencePiece-based tokenizer and the v5 tokenizer redesign ## Expected Behavior The behavior should be consistent across v4.x and v5.x for backward compatibility. ### Expected behavior ``` Expected (v4.48.0 - Working correctly) - microsoft/mdeberta-v3-base: [1, 124394, 2] (CLS, hello, SEP) - FacebookAI/roberta-base: [0, 42891, 2] (<s>, hello, </s>) - bert-base-uncased: [101, 7592, 102] (CLS, hello, SEP) Actual (v5.2.0 - Broken for mdeberta only) - microsoft/mdeberta-v3-base: [124394] ← NO special tokens! - FacebookAI/roberta-base: [0, 42891, 2] ← Works - bert-base-uncased: [101, 7592, 102] ← Works ```
closed
completed
false
0
[ "bug" ]
[]
2026-03-10T11:43:59Z
2026-03-24T09:40:46Z
2026-03-24T09:40:46Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
Abdullahaml1
25,988,048
MDQ6VXNlcjI1OTg4MDQ4
User
false
huggingface/transformers
4,055,271,864
I_kwDOCUB6oc7xtom4
44,589
https://github.com/huggingface/transformers/issues/44589
https://api.github.com/repos/huggingface/transformers/issues/44589
TypeError: couldn't find storage object Float8_e4m3fnStorage
### System Info - `transformers` version: 5.3.0.dev0 - Platform: Linux-6.8.0-101-generic-x86_64-with-glibc2.35 - Python version: 3.12.13 - Huggingface_hub version: 1.6.0 - Safetensors version: 0.7.0 - Accelerate version: 1.13.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.10.0+cu128 (CUDA) - Using distributed or parallel set-up in script?: <fill in> - Using GPU in script?: <fill in> - GPU type: NVIDIA A100-SXM4-80GB ### Who can help? @CyrilVallez ### Information - [x] The official example scripts - [ ] 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 transformers serve --force-model Qwen/Qwen3.5-35B-A3B-FP8 --port 8000 --continuous-batching ``` File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/cli/serve.py", line 474, in __init__ self.load_model_and_processor(model_id_and_revision) File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/cli/serve.py", line 1876, in load_model_and_processor model, processor = self._load_model_and_data_processor(model_id_and_revision) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/cli/serve.py", line 1850, in _load_model_and_data_processor model = architecture.from_pretrained(model_id, **model_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 4096, in from_pretrained with ContextManagers(model_init_context): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/utils/generic.py", line 532, in __enter__ self.stack.enter_context(context_manager) File "/home/xinhe/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/contextlib.py", line 526, in enter_context result = _enter(cm) ^^^^^^^^^^ File "/home/xinhe/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 240, in local_torch_dtype torch.set_default_dtype(dtype) File "/home/xinhe/auto-round/.venv/lib/python3.12/site-packages/torch/__init__.py", line 1358, in set_default_dtype _C._set_default_dtype(d) TypeError: couldn't find storage object Float8_e4m3fnStorage ``` ### Expected behavior The FP8 model should be loaded correctly.
closed
completed
false
6
[ "bug" ]
[]
2026-03-11T02:16:53Z
2026-03-20T13:12:32Z
2026-03-20T13:12:32Z
CONTRIBUTOR
null
20260324T120231Z
2026-03-24T12:02:31Z
xin3he
83,260,933
MDQ6VXNlcjgzMjYwOTMz
User
false
huggingface/transformers
4,062,402,313
I_kwDOCUB6oc7yI1cJ
44,619
https://github.com/huggingface/transformers/issues/44619
https://api.github.com/repos/huggingface/transformers/issues/44619
Plug model rule in development flow and extend it
This is a follow-up from https://github.com/huggingface/transformers/pull/44174 We're now plugging the tool into developer flow: - add an opt-in github hook for checking the model - automatically run `make check-model-rules` on PRs to generate reports - add a ref to the CLI in the AI agents files - fix models that are in allow lists and can be fixed - modularize the code (add a `mlinter` sub package in `utils`)
open
null
false
0
[]
[ "tarekziade" ]
2026-03-12T06:00:58Z
2026-03-20T15:45:01Z
null
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
tarekziade
250,019
MDQ6VXNlcjI1MDAxOQ==
User
false
huggingface/transformers
4,071,819,790
I_kwDOCUB6oc7yswoO
44,671
https://github.com/huggingface/transformers/issues/44671
https://api.github.com/repos/huggingface/transformers/issues/44671
CamemBERT produces incorrect masked LM predictions in v5
### System Info - `transformers` version: 5.3.0 - Platform: Linux-6.6.113+-x86_64-with-glibc2.35 - Python version: 3.12.12 - Huggingface_hub version: 1.6.0 - Safetensors version: 0.7.0 - Accelerate version: 1.13.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.10.0+cpu (NA) - Using distributed or parallel set-up in script?: distributed ### Who can help? @ArthurZucker @Cyrilvallez ### Information - [x] 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 ## Running the example from the documentation https://huggingface.co/docs/transformers/model_doc/camembert?usage=Pipeline#camembert ```python import torch from transformers import pipeline pipeline = pipeline("fill-mask", model="camembert-base", dtype=torch.float16, device=0) pipeline("Le camembert est un délicieux fromage <mask>.") ``` v4 ```text [{'score': 0.181884765625, 'token': 4364, 'token_str': 'suisse', 'sequence': 'Le camembert est un délicieux fromage suisse .'}, {'score': 0.0943603515625, 'token': 430, 'token_str': 'français', 'sequence': 'Le camembert est un délicieux fromage français .'}, {'score': 0.049713134765625, 'token': 5941, 'token_str': 'italien', 'sequence': 'Le camembert est un délicieux fromage italien .'}, {'score': 0.036956787109375, 'token': 875, 'token_str': 'blanc', 'sequence': 'Le camembert est un délicieux fromage blanc .'}, {'score': 0.028778076171875, 'token': 18278, 'token_str': 'fondant', 'sequence': 'Le camembert est un délicieux fromage fondant .'}] ``` v5 ```text [{'score': 0.0001423358917236328, 'token': 14477, 'token_str': 'politique', 'sequence': 'Le camembert est un délicieux fromagepolitique .'}, {'score': 0.00013720989227294922, 'token': 16949, 'token_str': 'hâ', 'sequence': 'Le camembert est un délicieux fromagehâ .'}, {'score': 0.00011497735977172852, 'token': 7666, 'token_str': '<', 'sequence': 'Le camembert est un délicieux fromage< .'}, {'score': 0.00011020898818969727, 'token': 10494, 'token_str': 'entraîné', 'sequence': 'Le camembert est un délicieux fromage entraîné .'}, {'score': 0.00010907649993896484, 'token': 14341, 'token_str': 'améliore', 'sequence': 'Le camembert est un délicieux fromage améliore .'}] ``` ## Simple masked token prediction test ```python import random import torch from datasets import load_dataset from tqdm import tqdm from transformers import AutoTokenizer, AutoModelForMaskedLM, set_seed set_seed(42) tokenizer = AutoTokenizer.from_pretrained("camembert-base") model = AutoModelForMaskedLM.from_pretrained("camembert-base", dtype="auto", device_map="auto", attn_implementation="sdpa") dataset = load_dataset("allocine", split="test") dataset = dataset.shuffle(seed=42)[:100] num_correct = 0 num_total = 0 for text in tqdm(dataset["review"]): input_ids = tokenizer(text, truncation=True, max_length=128)["input_ids"] candidates = [ i for i, input_id in enumerate(input_ids) if input_id not in tokenizer.all_special_ids ] masked_pos = random.choice(candidates) gold_id = input_ids[masked_pos] masked_ids = input_ids[:] masked_ids[masked_pos] = tokenizer.mask_token_id with torch.no_grad(): output = model(torch.tensor([masked_ids])) pred_id = output.logits[0, masked_pos].argmax(dim=-1) num_correct += pred_id == gold_id num_total += 1 print(f"\n\nnum_correct: {num_correct} / num_total: {num_total}") ``` v4 ```text num_correct: 43 / num_total: 100 ``` v5 ```text num_correct: 0 / num_total: 100 ``` ### Expected behavior CamemBERT masked language modeling should produce reasonable predictions as in transformers v4. However, in transformers v5, the model produces clearly incorrect predictions and the simple masked token task accuracy drops from ~43% to 0%.
closed
completed
false
5
[ "bug" ]
[]
2026-03-13T15:30:48Z
2026-03-23T10:47:50Z
2026-03-23T10:47:50Z
CONTRIBUTOR
null
20260324T120231Z
2026-03-24T12:02:31Z
math-hiyoko
56,009,584
MDQ6VXNlcjU2MDA5NTg0
User
false
huggingface/transformers
4,077,031,787
I_kwDOCUB6oc7zApFr
44,717
https://github.com/huggingface/transformers/issues/44717
https://api.github.com/repos/huggingface/transformers/issues/44717
Support packed sequences for linear attention models (i.e. Qwen3.5)
### Feature request Currently, packing does not seem supported for text-based datasets (https://github.com/unslothai/unsloth/issues/4160). It would be good to support this. ### Motivation Without packing, my training runs are approximately 3-5x more expensive with the dataset that I'd like to use, and also suffer from overhead on very short sequences. ### Your contribution I cannot help; I have no experience with deep learning.
open
null
false
9
[ "Feature request" ]
[]
2026-03-14T23:22:19Z
2026-03-23T16:21:08Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
kirawi
67,773,714
MDQ6VXNlcjY3NzczNzE0
User
false
huggingface/transformers
4,080,877,033
I_kwDOCUB6oc7zPT3p
44,740
https://github.com/huggingface/transformers/issues/44740
https://api.github.com/repos/huggingface/transformers/issues/44740
Run model linter on new models additions
- detect PRs with new models - add a `new model` label - run the linter and when failing comment the PR with errors
open
null
false
1
[]
[ "tarekziade" ]
2026-03-16T08:04:16Z
2026-03-23T09:07:09Z
null
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
tarekziade
250,019
MDQ6VXNlcjI1MDAxOQ==
User
false
huggingface/transformers
4,081,656,083
I_kwDOCUB6oc7zSSET
44,748
https://github.com/huggingface/transformers/issues/44748
https://api.github.com/repos/huggingface/transformers/issues/44748
[Neuron] Auto-select StaticCache when device is Neuron
## Context On Neuron devices, `StaticCache` is required for correct generation — dynamic tensor shapes trigger per-step recompilations. Currently, users must explicitly pass `past_key_values=StaticCache(...)` or `cache_implementation="static"` to `model.generate()`. Ideally, `model.generate()` should auto-select `StaticCache` when running on Neuron, providing zero-config DX. **Depends on:** #44742 (StaticCache-friendly `_sample` must exist first — otherwise auto-selecting StaticCache still hits the dynamic-shape `_sample` path) ## Proposed change In `_prepare_cache_for_generation` (around line 1879 of `src/transformers/generation/utils.py`), when no cache is specified: ```python if generation_config.cache_implementation is None and self.device.type == "neuron": generation_config.cache_implementation = "static" ``` **Precedent:** The generation code already has device-aware logic: - Line 2021: `self.device.type in ["cuda", "xpu"]` for compile criteria - Line 1870: Forces `"dynamic_full"` for assisted generation Device-aware cache selection fits the existing pattern. ## Expected behavior ```python # On Neuron — auto-selects StaticCache, uses static-shape _sample path: model.generate(input_ids) # On CUDA — unchanged, uses DynamicCache + standard _sample: model.generate(input_ids) # Explicit override still works on any device: model.generate(input_ids, cache_implementation="static") model.generate(input_ids, past_key_values=my_static_cache) ``` ## Related - Parent: #44741 - Depends on: #44742
open
null
false
1
[]
[]
2026-03-16T10:38:15Z
2026-03-21T18:19:03Z
null
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
dacorvo
1,910,518
MDQ6VXNlcjE5MTA1MTg=
User
false
huggingface/transformers
4,081,994,049
I_kwDOCUB6oc7zTklB
44,749
https://github.com/huggingface/transformers/issues/44749
https://api.github.com/repos/huggingface/transformers/issues/44749
Transformer 从4.57.3 升级到5.3.0 后过滤数据时长变慢十倍以上
### System Info H20 ### 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 过滤函数实现:对应链接 https://github.com/verl-project/verl/blob/main/verl/utils/dataset/rl_dataset.py#L241 ``` def doc2len(doc) -> int: try: apply_kwargs = dict(**self.apply_chat_template_kwargs) if self.tool_schemas is not None: apply_kwargs["tools"] = self.tool_schemas # Keep explicit tokenization to avoid transformers version default changes. apply_kwargs.pop("tokenize", None) apply_kwargs.pop("return_dict", None) apply_kwargs.pop("return_tensors", None) tokenized_prompt = tokenizer.apply_chat_template( doc[prompt_key], add_generation_prompt=True, tokenize=True, **apply_kwargs ) return len(normalize_token_ids(tokenized_prompt)) except Exception: print("Error processing one of the samples, skipping...") traceback.print_exc() return self.max_prompt_length + 1 dataframe = dataframe.filter( lambda doc: doc2len(doc) <= self.max_prompt_length, num_proc=self.num_workers, desc=f"Filtering prompts longer than {self.max_prompt_length} tokens", ) ``` 使用transformer 4.57.3 运行这段code大概十几分钟,如果升级到5.3.0 需要约两个小时;辛苦帮忙看看 模型=qwen3.5-35b-A22 数据集是aime-2024 4.57.3 结果 <img width="1818" height="300" alt="Image" src="https://github.com/user-attachments/assets/df875792-23ae-4efe-9f42-c11de9516e5a" /> 5.3.0 结果 <img width="1506" height="236" alt="Image" src="https://github.com/user-attachments/assets/d2b7f182-0337-4cb0-a32e-d34cfd78f43a" /> ### Expected behavior 希望transformer 升级后,其tokenizer 的速度没有变化
open
null
false
7
[ "bug" ]
[]
2026-03-16T11:48:25Z
2026-03-23T08:28:15Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
chenjiaoAngel
38,650,344
MDQ6VXNlcjM4NjUwMzQ0
User
false
huggingface/transformers
4,082,686,570
I_kwDOCUB6oc7zWNpq
44,754
https://github.com/huggingface/transformers/issues/44754
https://api.github.com/repos/huggingface/transformers/issues/44754
I really need help regarding to meta device issue
I installed TRELLIS 2 and getting the error for meta device, I followed the instructions here for installing this release of transformers, but when I launch TRELLIS 2 I still get the same error. Can someone please help me Fix this step by step because I spend 5 days trying without any solution
open
null
false
1
[]
[]
2026-03-16T14:03:28Z
2026-03-23T09:44:39Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
Hany138078
230,026,885
U_kgDODbXuhQ
User
false
huggingface/transformers
4,093,576,102
I_kwDOCUB6oc7z_wOm
44,811
https://github.com/huggingface/transformers/issues/44811
https://api.github.com/repos/huggingface/transformers/issues/44811
Whisper processor.batch_decode() function ignoring skip_special_tokens params
### System Info - `transformers` version: 4.57.6 - Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35 - Python version: 3.10.13 - Huggingface_hub version: 0.36.2 - Safetensors version: 0.7.0 - Accelerate version: 1.13.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.10.0+cu130 (CUDA) - Tensorflow version (GPU?): not installed (NA) - Flax version (CPU?/GPU?/TPU?): not installed (NA) - Jax version: not installed - JaxLib version: not installed - Using distributed or parallel set-up in script?: No - Using GPU in script?: Yes - GPU type: NVIDIA GeForce RTX 3080 Ti Laptop GPU ### Who can help? @ArthurZucker ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction Running the code provided [here](https://huggingface.co/openai/whisper-small), it seems that _skip_special_tokens_ param is being ignored. ``` from transformers import WhisperProcessor, WhisperForConditionalGeneration from datasets import load_dataset # load model and processor processor = WhisperProcessor.from_pretrained("openai/whisper-small") model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small") model.config.forced_decoder_ids = None # load dummy dataset and read audio files ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation") sample = ds[0]["audio"] input_features = processor(sample["array"], sampling_rate=sample["sampling_rate"], return_tensors="pt").input_features # generate token ids predicted_ids = model.generate(input_features) # decode token ids to text transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False) print("[Skip special tokens=False] ", transcription) transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True) print("[Skip special tokens=True] ", transcription) ``` The output is the following: _[Skip special tokens=False] [' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'] [Skip special tokens=True] [' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.']_ If however a dict output is required by running the following code: ``` # generate token ids predicted_ids = model.generate(input_features, return_dict_in_generate=True) # decode token ids to text transcription = processor.batch_decode(predicted_ids.sequences, skip_special_tokens=False) print("[Skip special tokens=False] ", transcription) transcription = processor.batch_decode(predicted_ids.sequences, skip_special_tokens=True) print("[Skip special tokens=True] ", transcription) ``` The output is (correctly) the following: _[Skip special tokens=False] ['<|startoftranscript|><|en|><|transcribe|><|notimestamps|> Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.<|endoftext|>'] [Skip special tokens=True] [' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.']_ ### Expected behavior The _processor.batch_decode()_ function should output also special tokens if _skip_special_tokens=False_ is passed.
closed
completed
false
5
[ "bug" ]
[]
2026-03-18T08:30:17Z
2026-03-20T10:59:59Z
2026-03-20T10:59:59Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
cfasana
143,723,410
U_kgDOCJELkg
User
false
huggingface/transformers
4,094,388,173
I_kwDOCUB6oc70C2fN
44,821
https://github.com/huggingface/transformers/issues/44821
https://api.github.com/repos/huggingface/transformers/issues/44821
Unable to load `AutoImageProcessor` from URL
### System Info <details><summary>Versions</summary> <p> - `transformers` version: 5.3.0 - Platform: Linux-6.8.0-106-generic-x86_64-with-glibc2.39 - Python version: 3.12.3 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.7.0 - Accelerate version: not installed - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.10.0+cu128 (NA) </p> </details> ### Bug I am trying to load a config from URL, to instatiate the AutoImageProcessor. This worked before, but not anymore with new versions of transformers. Bug starts occuring with `transformers>=5.3.0`. It worked with `transformers==4.57.6` To reproduce; ```py import transformers url = "https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json" transformers.AutoImageProcessor.from_pretrained(url) # fails on >=5.0, succeeds pre-5.0 local_file = "/path/to/config.json" # download the file from the URL above transformers.AutoImageProcessor.from_pretrained(local_file) # succeeds on v4 and v5 ``` <details><summary>traceback</summary> <p> ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 514, in from_pretrained raise initial_exception File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 501, in from_pretrained config_dict, _ = ImageProcessingMixin.get_image_processor_dict( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/image_processing_base.py", line 282, in get_image_processor_dict resolved_processor_file = cached_file( ^^^^^^^^^^^^ File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/utils/hub.py", line 277, in cached_file file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/utils/hub.py", line 469, in cached_files raise OSError(f"{e}") from e OSError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': 'https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json'. Use `repo_type` argument if needed. ``` </p> </details>
closed
completed
false
6
[ "bug" ]
[]
2026-03-18T11:08:09Z
2026-03-23T13:13:38Z
2026-03-23T13:10:59Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
BSchilperoort
12,114,825
MDQ6VXNlcjEyMTE0ODI1
User
false
huggingface/transformers
4,098,836,913
I_kwDOCUB6oc70T0mx
44,841
https://github.com/huggingface/transformers/issues/44841
https://api.github.com/repos/huggingface/transformers/issues/44841
Processor fails for mistralai/Voxtral-Mini-3B-2507
### System Info I am trying to run inference using `mistralai/Voxtral-Mini-3B-2507` on an audio (`np.ndarray`). On loading the processor using `processor = transformers.AutoProcessor.from_pretrained(MODEL, trust_remote_code=True)`, I am getting the following error: ``` /usr/local/lib/python3.12/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning: The secret `HF_TOKEN` does not exist in your Colab secrets. To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session. You will be able to reuse this secret in all of your notebooks. Please note that authentication is recommended but still optional to access public models or datasets. warnings.warn( Converting tekken.json to tokenizer.json: 100%|██████████| 150000/150000 [00:02<00:00, 69142.59it/s] --------------------------------------------------------------------------- Exception Traceback (most recent call last) [/tmp/ipykernel_7845/2744582412.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in <cell line: 0>() 12 # else: 13 # processor = MODEL_DICT[MODEL]['processor'].from_pretrained(MODEL, trust_remote_code=True) ---> 14 processor = MODEL_DICT[MODEL]['processor'].from_pretrained(MODEL, trust_remote_code=True) 13 frames[/usr/local/lib/python3.12/dist-packages/transformers/models/auto/processing_auto.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_pretrained(cls, pretrained_model_name_or_path, **kwargs) 409 ) 410 elif processor_class is not None: --> 411 return processor_class.from_pretrained( 412 pretrained_model_name_or_path, trust_remote_code=trust_remote_code, **kwargs 413 ) [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, **kwargs) 1402 processor_dict, instantiation_kwargs = cls.get_processor_dict(pretrained_model_name_or_path, **kwargs) 1403 args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, processor_dict, **kwargs) -> 1404 return cls.from_args_and_dict(args, processor_dict, **instantiation_kwargs) 1405 1406 @classmethod [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_args_and_dict(cls, args, processor_dict, **kwargs) 1171 processor = cls(*args, **valid_kwargs) 1172 -> 1173 logger.info(f"Processor {processor}") 1174 if return_unused_kwargs: 1175 return processor, unused_kwargs [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in __repr__(self) 777 attributes_repr = [f"- {name}: {repr(getattr(self, name))}" for name in self.get_attributes()] 778 attributes_repr = "\n".join(attributes_repr) --> 779 return f"{self.__class__.__name__}:\n{attributes_repr}\n\n{self.to_json_string()}" 780 781 def save_pretrained(self, save_directory, push_to_hub: bool = False, **kwargs): [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in to_json_string(self) 759 `str`: String containing all the attributes that make up this feature_extractor instance in JSON format. 760 """ --> 761 dictionary = self.to_dict() 762 763 return json.dumps(dictionary, indent=2, sort_keys=True) + "\n" [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in to_dict(self) 697 `dict[str, Any]`: Dictionary of all the attributes that make up this processor instance. 698 """ --> 699 output = copy.deepcopy(self.__dict__) 700 701 # Get the kwargs in `__init__`. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 134 copier = _deepcopy_dispatch.get(cls) 135 if copier is not None: --> 136 y = copier(x, memo) 137 else: 138 if issubclass(cls, type): [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _deepcopy_dict(x, memo, deepcopy) 219 memo[id(x)] = y 220 for key, value in x.items(): --> 221 y[deepcopy(key, memo)] = deepcopy(value, memo) 222 return y 223 d[dict] = _deepcopy_dict [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 160 y = x 161 else: --> 162 y = _reconstruct(x, memo, *rv) 163 164 # If is its own copy, don't memoize. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 257 if state is not None: 258 if deep: --> 259 state = deepcopy(state, memo) 260 if hasattr(y, '__setstate__'): 261 y.__setstate__(state) [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 134 copier = _deepcopy_dispatch.get(cls) 135 if copier is not None: --> 136 y = copier(x, memo) 137 else: 138 if issubclass(cls, type): [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _deepcopy_dict(x, memo, deepcopy) 219 memo[id(x)] = y 220 for key, value in x.items(): --> 221 y[deepcopy(key, memo)] = deepcopy(value, memo) 222 return y 223 d[dict] = _deepcopy_dict [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 160 y = x 161 else: --> 162 y = _reconstruct(x, memo, *rv) 163 164 # If is its own copy, don't memoize. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 259 state = deepcopy(state, memo) 260 if hasattr(y, '__setstate__'): --> 261 y.__setstate__(state) 262 else: 263 if isinstance(state, tuple) and len(state) == 2: Exception: Error while attempting to unpickle Tokenizer: Token `Ġ<SPECIAL_116>` out of vocabulary at line 1 column 9601910 ``` I tested out the following standalone code provided in the model card of `mistralai/Voxtral-Mini-3B-2507` but it too does not work: ``` from transformers import VoxtralForConditionalGeneration, AutoProcessor import torch device = "cuda" repo_id = "mistralai/Voxtral-Mini-3B-2507" processor = AutoProcessor.from_pretrained(repo_id) model = VoxtralForConditionalGeneration.from_pretrained(repo_id, torch_dtype=torch.bfloat16, device_map=device) conversation = [ { "role": "user", "content": [ { "type": "audio", "path": "https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/winning_call.mp3", }, ], } ] inputs = processor.apply_chat_template(conversation) inputs = inputs.to(device, dtype=torch.bfloat16) outputs = model.generate(**inputs, max_new_tokens=500) decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True) print("\nGenerated response:") print("=" * 80) print(decoded_outputs[0]) print("=" * 80) ``` Error given by above script: ``` Converting tekken.json to tokenizer.json: 100%|██████████| 150000/150000 [00:01<00:00, 116597.64it/s] --------------------------------------------------------------------------- Exception Traceback (most recent call last) [/tmp/ipykernel_7845/3351359521.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in <cell line: 0>() 5 repo_id = "mistralai/Voxtral-Mini-3B-2507" 6 ----> 7 processor = AutoProcessor.from_pretrained(repo_id) 8 model = VoxtralForConditionalGeneration.from_pretrained(repo_id, torch_dtype=torch.bfloat16, device_map=device) 9 13 frames[/usr/local/lib/python3.12/dist-packages/transformers/models/auto/processing_auto.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_pretrained(cls, pretrained_model_name_or_path, **kwargs) 409 ) 410 elif processor_class is not None: --> 411 return processor_class.from_pretrained( 412 pretrained_model_name_or_path, trust_remote_code=trust_remote_code, **kwargs 413 ) [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, **kwargs) 1402 processor_dict, instantiation_kwargs = cls.get_processor_dict(pretrained_model_name_or_path, **kwargs) 1403 args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, processor_dict, **kwargs) -> 1404 return cls.from_args_and_dict(args, processor_dict, **instantiation_kwargs) 1405 1406 @classmethod [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in from_args_and_dict(cls, args, processor_dict, **kwargs) 1171 processor = cls(*args, **valid_kwargs) 1172 -> 1173 logger.info(f"Processor {processor}") 1174 if return_unused_kwargs: 1175 return processor, unused_kwargs [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in __repr__(self) 777 attributes_repr = [f"- {name}: {repr(getattr(self, name))}" for name in self.get_attributes()] 778 attributes_repr = "\n".join(attributes_repr) --> 779 return f"{self.__class__.__name__}:\n{attributes_repr}\n\n{self.to_json_string()}" 780 781 def save_pretrained(self, save_directory, push_to_hub: bool = False, **kwargs): [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in to_json_string(self) 759 `str`: String containing all the attributes that make up this feature_extractor instance in JSON format. 760 """ --> 761 dictionary = self.to_dict() 762 763 return json.dumps(dictionary, indent=2, sort_keys=True) + "\n" [/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in to_dict(self) 697 `dict[str, Any]`: Dictionary of all the attributes that make up this processor instance. 698 """ --> 699 output = copy.deepcopy(self.__dict__) 700 701 # Get the kwargs in `__init__`. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 134 copier = _deepcopy_dispatch.get(cls) 135 if copier is not None: --> 136 y = copier(x, memo) 137 else: 138 if issubclass(cls, type): [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _deepcopy_dict(x, memo, deepcopy) 219 memo[id(x)] = y 220 for key, value in x.items(): --> 221 y[deepcopy(key, memo)] = deepcopy(value, memo) 222 return y 223 d[dict] = _deepcopy_dict [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 160 y = x 161 else: --> 162 y = _reconstruct(x, memo, *rv) 163 164 # If is its own copy, don't memoize. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 257 if state is not None: 258 if deep: --> 259 state = deepcopy(state, memo) 260 if hasattr(y, '__setstate__'): 261 y.__setstate__(state) [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 134 copier = _deepcopy_dispatch.get(cls) 135 if copier is not None: --> 136 y = copier(x, memo) 137 else: 138 if issubclass(cls, type): [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _deepcopy_dict(x, memo, deepcopy) 219 memo[id(x)] = y 220 for key, value in x.items(): --> 221 y[deepcopy(key, memo)] = deepcopy(value, memo) 222 return y 223 d[dict] = _deepcopy_dict [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in deepcopy(x, memo, _nil) 160 y = x 161 else: --> 162 y = _reconstruct(x, memo, *rv) 163 164 # If is its own copy, don't memoize. [/usr/lib/python3.12/copy.py](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD#) in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 259 state = deepcopy(state, memo) 260 if hasattr(y, '__setstate__'): --> 261 y.__setstate__(state) 262 else: 263 if isinstance(state, tuple) and len(state) == 2: Exception: Error while attempting to unpickle Tokenizer: Token `<SPECIAL_32><SPECIAL_32>` out of vocabulary at line 1 column 9847997 ``` There are many issues with a lot of other APIs in `transformers==5.3.0`. Please resolve these issues ASAP. ### Who can help? @eustlb @ebezzam @vasqu @Cyrilvallez ### Information - [x] The official example scripts - [x] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [x] My own task or dataset (give details below) ### Reproduction Steps to reproduce the issue: 1. Connect to the correct GPU runtime (I tried on T4 GPU). 2. Upload a valid audio file with extension `.WAV`. 3. Ensure `MODEL = "mistralai/Voxtral-Mini-3B-2507"` and `AUDIO_PATH = "<valid audio path>.WAV"`. 4. Run the notebook at [https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD?usp=sharing](https://colab.research.google.com/drive/18tlO4aFg0RxV7hcBf04abb1wKW-B3zbD?usp=sharing). [EMSCall (1).ipynb](https://github.com/user-attachments/files/26104503/EMSCall.1.ipynb) ### Expected behavior Error on loading of `processor` for `mistralai/Voxtral-Mini-3B-2507` model.
closed
completed
false
3
[ "bug" ]
[]
2026-03-19T02:26:39Z
2026-03-24T10:07:36Z
2026-03-24T10:07:36Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
BhavyaShah1234
62,424,200
MDQ6VXNlcjYyNDI0MjAw
User
false
huggingface/transformers
4,099,433,723
I_kwDOCUB6oc70WGT7
44,843
https://github.com/huggingface/transformers/issues/44843
https://api.github.com/repos/huggingface/transformers/issues/44843
AutoTokenizer.from_pretrained calls model_info() unconditionally in _patch_mistral_regex, breaks HF_HUB_OFFLINE mode
### System Info - `transformers` version: 4.57.3 - `huggingface_hub` version: 0.36.2 - Python: 3.12 - OS: Linux (Ubuntu 24.04, inside NVIDIA container) ### Who can help? @ArthurZucker @itazap ### Regression introduced in PR #42389 (`[Mistral Tokenizers] Fix tokenizer detection`), included in v4.57.2 → v4.57.3. ### Information - [x] The official example scripts - [x] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder - [ ] My own task or dataset (give details below) ### Reproduction ```python import os from huggingface_hub import snapshot_download # Step 1: Pre-download a non-Mistral model snapshot_download("Qwen/Qwen3-0.6B") # Step 2: Enable offline mode os.environ["HF_HUB_OFFLINE"] = "1" # Step 3: Load tokenizer — crashes even though model is fully cached from transformers import AutoTokenizer tok = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B") ``` This raises: ``` huggingface_hub.errors.OfflineModeIsEnabled: Cannot reach https://huggingface.co/api/models/Qwen/Qwen3-0.6B: offline mode is enabled. ``` Full traceback: ``` transformers/models/auto/tokenization_auto.py:1156, in from_pretrained transformers/tokenization_utils_base.py:2113, in from_pretrained transformers/tokenization_utils_base.py:2395, in _from_pretrained transformers/tokenization_utils_base.py:2438, in _patch_mistral_regex transformers/tokenization_utils_base.py:2432, in is_base_mistral huggingface_hub/hf_api.py:2660, in model_info → OfflineModeIsEnabled ``` ### Expected behavior `AutoTokenizer.from_pretrained()` should work in offline mode (`HF_HUB_OFFLINE=1`) when the model is already cached locally. This worked in transformers 4.57.1. ### Root cause In `tokenization_utils_base.py`, `_patch_mistral_regex` defines `is_base_mistral()` which calls `huggingface_hub.model_info()` — an API call — for **every** model, not just Mistral models. The call happens before any cache check or `local_files_only` guard: ```python # tokenization_utils_base.py, _patch_mistral_regex def is_base_mistral(model_id: str) -> bool: model = model_info(model_id) # <-- unconditional API call ... if _is_local or is_base_mistral(pretrained_model_name_or_path): # <-- called for ALL non-local models ``` The `local_files_only` parameter is passed to `_patch_mistral_regex` but is never used to guard the `is_base_mistral()` call. ### Suggested fix The `is_base_mistral()` call should either: 1. Be wrapped in a try/except that catches `OfflineModeIsEnabled` and returns `False` (safe default — if we can't reach the API, assume it's not a Mistral model), or 2. Be skipped when `local_files_only=True` or `HF_HUB_OFFLINE=1` is set ### Impact This breaks any CI/CD pipeline or air-gapped environment that: 1. Pre-downloads models with `snapshot_download()` 2. Sets `HF_HUB_OFFLINE=1` to prevent network access during test execution 3. Loads tokenizers via `AutoTokenizer.from_pretrained()` This pattern is common in ML CI pipelines (we hit this in NVIDIA Dynamo's CI with TensorRT-LLM).
open
null
false
3
[]
[]
2026-03-19T05:36:56Z
2026-03-23T11:15:07Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
nv-yna
248,773,860
U_kgDODtP85A
User
false
huggingface/transformers
4,100,120,851
I_kwDOCUB6oc70YuET
44,849
https://github.com/huggingface/transformers/issues/44849
https://api.github.com/repos/huggingface/transformers/issues/44849
Transformers Qwen3.5 had a bug when set output_hidden_states=True
### System Info Version: 5.2.0 in qwen3.5 outputs = model_wrapper.generate(**inputs, output_hidden_states=True) outpus something like this: ``` ><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|image_pad|><|vision_end|>请详细描述这张图片的内容。<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n这张!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'] ``` ignore the `output_hideen_states` params, normal ``` on_end|>请详细描述这张图片的内容。<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n这张图片是一张包含表格的截图,内容是一份关于不同模型在多个任务上表现的数据对比表。\n\n**整体布局:**\n图片的主体是一个表格,表格的标题为“Model”,列出了多个模型名称,以及它们在不同任务上的平均长度(Avg. Length)、任务1、任务2、任务3、任务4和任务5的得分百分比。表格下方还有一行说明文字。\n\n**表格内容详情:**\n表格共有8行数据,对应8个不同的模型。\n\n- **第一行:**\n - **Model:** `PI0*`\n - **Avg. Length:** 2.954\n - **Task 1:** 84.8%\n - **Task 2:** 70.4%\n - **Task 3:** 55.9%\n - **Task 4:** 46.6%\n - **Task 5:** 37.7%\n\n- **第二行:**\n - **Model:** `PI0.5*`\n - **Avg. Length:** 3.885\n - **Task 1:** 92.5%\n - **Task 2:** 84.0%\n - **Task 3:** 76.6%\n - **Task 4:** 71.0%\n - **Task 5:** 64.4%\n\n- **第三行:**\n - **Model:** `qwenpi (qwen2.5-vl-3B-instruct-action)`\n - **Avg. Length:** 3.5'] ``` ### Who can help? w ### Information - [x] The official example scripts - [x] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [x] My own task or dataset (give details below) ### Reproduction f ### Expected behavior rg
open
null
false
4
[ "bug" ]
[]
2026-03-19T08:27:35Z
2026-03-20T01:27:23Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
lucasjinreal
21,303,438
MDQ6VXNlcjIxMzAzNDM4
User
false
huggingface/transformers
4,100,959,949
I_kwDOCUB6oc70b67N
44,855
https://github.com/huggingface/transformers/issues/44855
https://api.github.com/repos/huggingface/transformers/issues/44855
IndentationError when importing DebertaV2Model on Python 3.13 - @torch.jit.script fails to parse function with comment between decorator and def
## Description Importing `DebertaV2Model` from `transformers` (or any library that depends on it, such as `gliner`) raises an `IndentationError` on Python 3.13. The error originates in `torch.jit.script` when it attempts to re-parse the source of a JIT-scripted function that has a comment placed between the `@torch.jit.script` decorator and the `def` statement. ## Root Cause In `modeling_deberta_v2.py`, several functions are decorated with `@torch.jit.script` with a comment in between: ```python @torch.jit.script # Copied from transformers.models.deberta.modeling_deberta.c2p_dynamic_expand def c2p_dynamic_expand(c2p_pos, query_layer, relative_pos): return c2p_pos.expand([...]) ``` When `@torch.jit.script` is applied, PyTorch's JIT frontend (`torch/_sources.py`) calls `inspect.getsource()` on the function, dedents the source, and passes it to `ast.parse()`. On Python 3.13, the comment between the decorator and `def` is included in the extracted snippet. After dedenting, the snippet becomes: ``` @torch.jit.script # Copied from ... def c2p_dynamic_expand(...): return ... ``` Python 3.13's `ast.parse` (backed by a stricter parser) then fails with `IndentationError: expected an indented block after function definition on line 3`, seemingly not associating the return statement as the function body when a comment precedes the `def` in this context. ## Affected Functions All in `transformers/models/deberta_v2/modeling_deberta_v2.py`: - `c2p_dynamic_expand` (line 104) - `p2c_dynamic_expand` (line 110) - `pos_dynamic_expand` (line 116) ## Workaround Remove the comments between `@torch.jit.script` and each `def`: ```python # Copied from transformers.models.deberta.modeling_deberta.c2p_dynamic_expand @torch.jit.script def c2p_dynamic_expand(c2p_pos, query_layer, relative_pos): return c2p_pos.expand([...]) ``` ## Related Issues - [pytorch/pytorch #165238](https://github.com/pytorch/pytorch/issues/165238) - [pytorch/pytorch #65452](https://github.com/pytorch/pytorch/issues/65452) - [pytorch/pytorch #25043](https://github.com/pytorch/pytorch/issues/25043) - [huggingface/transformers #35443](https://github.com/huggingface/transformers/issues/35443) - [huggingface/transformers #34190](https://github.com/huggingface/transformers/issues/34190) - [huggingface/trl #4239](https://github.com/huggingface/trl/issues/4239) ### 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 ## Environment | | | |---|---| | Python | 3.13.8 | | torch | 2.10.0+cu128 | | transformers | 5.3.0 | | gliner | 0.2.24 | | OS | Ubuntu 24.04.4 LTS (Noble Numbat), kernel 6.17.0-19-generic, x86_64| ## To Reproduce ```bash python -c "from gliner import GLiNER" ``` ### Expected behavior The import should pass.
open
null
false
4
[ "bug" ]
[]
2026-03-19T11:07:31Z
2026-03-20T13:34:32Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
MNIKIEMA
64,019,294
MDQ6VXNlcjY0MDE5Mjk0
User
false
huggingface/transformers
4,101,508,603
I_kwDOCUB6oc70eA37
44,857
https://github.com/huggingface/transformers/issues/44857
https://api.github.com/repos/huggingface/transformers/issues/44857
LwDetrImageLoss crashes when using float16 AMP and Cuda
### System Info - `transformers` version: 5.3.0.dev0 - Platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39 - Python version: 3.12.3 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.7.0 - Accelerate version: 1.13.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.8.0+cu128 (CUDA) - Using distributed or parallel set-up in script?: no - Using GPU in script?: yes - GPU type: NVIDIA RTX 500 Ada Generation Laptop GPU ### Who can help? @yonigozlan @molbap @sbucaille ### 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 ``` import torch from transformers import LwDetrForObjectDetection model = LwDetrForObjectDetection.from_pretrained("AnnaZhang/lwdetr_small_60e_coco") model.train() model.cuda() inputs = { "pixel_values": torch.rand((1, 3, 640, 640), device="cuda"), "pixel_mask": torch.ones((1, 640, 640), device="cuda"), "labels": [ { "class_labels": torch.tensor([1], device="cuda"), "boxes": torch.tensor([[0.5, 0.5, 0.1, 0.1]], device="cuda"), } ], } with torch.autocast(device_type="cuda", dtype=torch.float16): outputs = model(**inputs) ``` This leads to the following error: ``` ".../transformers/loss/loss_lw_detr.py", line 139, in loss_labels pos_weights[pos_ind] = t ~~~~~~~~~~~^^^^^^^^^ RuntimeError: Index put requires the source and destination dtypes match, got Half for the destination and Float for the source. ``` It seems the reason for this is that the torch.pow operations inside loss_labels() cause an upcast to float32 on the GPU, leading to a type mismatch. ### Expected behavior Correct handling of float16 AMP on Cuda GPU, without crashing.
closed
completed
false
3
[ "bug" ]
[]
2026-03-19T12:56:22Z
2026-03-24T17:02:34Z
2026-03-24T17:02:34Z
CONTRIBUTOR
null
20260324T215331Z
2026-03-24T21:53:31Z
m-matthias
16,415,097
MDQ6VXNlcjE2NDE1MDk3
User
false
huggingface/transformers
4,102,371,828
I_kwDOCUB6oc70hTn0
44,861
https://github.com/huggingface/transformers/issues/44861
https://api.github.com/repos/huggingface/transformers/issues/44861
_get_tied_weight_keys crashes with AttributeError when _tied_weights_keys is a list
### System Info - `transformers` version: 5.3.0 - Platform: Linux - Python version: 3.13 ### Who can help? @Cyrilvallez ### Information - [ ] The official example scripts - [x] My own modified scripts ### Reproduction Full finetune of `NVIDIA-Nemotron-3-Nano-4B` crashes at checkpoint save with: File "transformers/modeling_utils.py", line 341, in _get_tied_weight_keys tied_weight_keys.extend([f"{name}.{k}" if name else k for k in tied.keys()]) AttributeError: 'list' object has no attribute 'keys' The Nemotron-H model defines `_tied_weights_keys` as a list, but `_get_tied_weight_keys` assumes it is always a dict and calls `.keys()` on it. ### Expected behavior `save_pretrained` should handle both list and dict types for `_tied_weights_keys` without crashing.
closed
completed
false
0
[]
[]
2026-03-19T15:13:12Z
2026-03-20T09:46:56Z
2026-03-20T09:46:56Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
gh-wf
111,619,017
U_kgDOBqcryQ
User
false
huggingface/transformers
4,102,382,384
I_kwDOCUB6oc70hWMw
44,863
https://github.com/huggingface/transformers/issues/44863
https://api.github.com/repos/huggingface/transformers/issues/44863
NemotronH implementation can't load NemotronH checkpoints!
### System Info ```console - `transformers` version: 5.3.0 - Platform: macOS-15.7.3-arm64-arm-64bit - Python version: 3.12.11 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.7.0 - Accelerate version: not installed - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.10.0 (NA) - Using distributed or parallel set-up in script?: NO ``` ### Who can help? @ArthurZucker @Cyrilvallez @liding-nv ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction either of: ```python tokenizer = AutoTokenizer.from_pretrained("nvidia/Nemotron-H-8B-Reasoning-128K") model = NemotronHForCausalLM.from_pretrained("nvidia/Nemotron-H-8B-Reasoning-128K", torch_dtype=torch.bfloat16) ``` or ```python tokenizer = AutoTokenizer.from_pretrained("nvidia/Nemotron-H-4B-Instruct-128K") model = NemotronHForCausalLM.from_pretrained("nvidia/Nemotron-H-4B-Instruct-128K", torch_dtype=torch.bfloat16) ``` fails. The first error appears to be that these functions: https://github.com/huggingface/transformers/blob/884333368ff329090c73bd00e57996727f301de3/src/transformers/models/nemotron_h/configuration_nemotron_h.py#L259-L269 do not correctly handle the `-` character in layer type patterns, but the saved models on the hub use them. If I add a check to ignore the `-` character I instead see something like this: ```console num_hidden_layers (52) is deprecated and doesn't match layers_block_type length (28). Using layers_block_type length. Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads. num_hidden_layers (52) is deprecated and doesn't match layers_block_type length (28). Using layers_block_type length. Fetching 4 files: 100%|██████████| 4/4 [05:01<00:00, 75.32s/it] The fast path is not available because one of `(selective_state_update, causal_conv1d_fn, causal_conv1d_update)` is None. Falling back to the naive implementation. To install follow https://github.com/state-spaces/mamba/#installation and https://github.com/Dao-AILab/causal-conv1d Loading weights: 100%|██████████| 119/119 [00:00<00:00, 26544.82it/s] NemotronHForCausalLM LOAD REPORT from: nvidia/Nemotron-H-8B-Reasoning-128K Key                                              | Status     | -------------------------------------------------+------------+- model.layers.{4...50}.mixer.A_log                | UNEXPECTED | model.layers.{1...51}.mixer.down_proj.weight     | UNEXPECTED | model.layers.{4...50}.mixer.norm.weight          | UNEXPECTED | model.layers.{7, 18, 29, 40}.mixer.v_proj.weight | UNEXPECTED | model.layers.{4...50}.mixer.out_proj.weight      | UNEXPECTED | model.layers.{4...50}.mixer.in_proj.weight       | UNEXPECTED | model.layers.{28...51}.norm.weight               | UNEXPECTED | model.layers.{7, 18, 29, 40}.mixer.o_proj.weight | UNEXPECTED | model.layers.{4...50}.mixer.dt_bias              | UNEXPECTED | model.layers.{1...51}.mixer.up_proj.weight       | UNEXPECTED | model.layers.{7, 18, 29, 40}.mixer.k_proj.weight | UNEXPECTED | model.layers.{4...50}.mixer.D                    | UNEXPECTED | model.layers.{4...50}.mixer.conv1d.bias          | UNEXPECTED | model.layers.{7, 18, 29, 40}.mixer.q_proj.weight | UNEXPECTED | model.layers.{4...50}.mixer.conv1d.weight        | UNEXPECTED | model.layers.{1...27}.mixer.out_proj.weight      | MISSING    | model.layers.{1...27}.mixer.norm.weight          | MISSING    | model.layers.{1...27}.mixer.A_log                | MISSING    | model.layers.{1...27}.mixer.dt_bias              | MISSING    | model.layers.{4, 10, 16, 22}.mixer.o_proj.weight | MISSING    | model.layers.{1...27}.mixer.conv1d.bias          | MISSING    | model.layers.{4, 10, 16, 22}.mixer.k_proj.weight | MISSING    | model.layers.{1...27}.mixer.in_proj.weight       | MISSING    | model.layers.{1...27}.mixer.D                    | MISSING    | model.layers.{1...27}.mixer.conv1d.weight        | MISSING    | model.layers.{4, 10, 16, 22}.mixer.q_proj.weight | MISSING    | model.layers.{4, 10, 16, 22}.mixer.v_proj.weight | MISSING    | Notes: - UNEXPECTED    :can be ignored when loading from different task/architecture; not ok if you expect identical arch. - MISSING    :those params were newly initialized because missing from the checkpoint. Consider training on your downstream task. ``` and the model then crashes when calling `model.generate`: ```console Traceback (most recent call last): File "/Users/thomas/Documents/GitHub/local-lm/.venv/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 275, in __getattr__ return self.data[item] ~~~~~~~~~^^^^^^ KeyError: 'shape' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/path/main.py", line 17, in <module> outputs = model.generate(tokenized_chat) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/path/.venv/lib/python3.12/site-packages/transformers/generation/utils.py", line 2390, in generate batch_size = inputs_tensor.shape[0] ^^^^^^^^^^^^^^^^^^^ File "/path/.venv/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 277, in __getattr__ raise AttributeError AttributeError ``` ### Expected behavior The model should output a prediction instead of crashing.
open
null
false
4
[ "bug" ]
[]
2026-03-19T15:15:06Z
2026-03-23T08:25:41Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
elfprince13
2,703,145
MDQ6VXNlcjI3MDMxNDU=
User
false
huggingface/transformers
4,105,125,767
I_kwDOCUB6oc70rz-H
44,869
https://github.com/huggingface/transformers/issues/44869
https://api.github.com/repos/huggingface/transformers/issues/44869
Whisper word timestamp decode crashes on trailing replacement character at end of decoded token stream
### System Info ### System Info - OS: macOS - `transformers`: `5.3.0.dev0` - Model: `openai/whisper-medium.en` ### Reproduction I hit an `IndexError: string index out of range` in Whisper word-timestamp decoding and traced it to `src/transformers/models/whisper/tokenization_whisper.py`. The failing code path is in `_split_tokens_on_unicode()`: ```py decoded_full[unicode_offset + decoded.index(replacement_char)] ``` The bug happens when the decoded token stream ends with a dangling Unicode replacement character (`�`, `U+FFFD`). In that case, the computed index can equal `len(decoded_full)`, so the code reads one past the end of the string and crashes. For the failing case I traced locally, the values were: - `unicode_offset = 298` - `decoded.index(replacement_char) = 0` - `target_index = 298` - `len(decoded_full) = 298` So the effective access becomes: ```py decoded_full[298] ``` but the last valid index is `297`. The underlying ASR output for the bad chunk decoded to a long run of musical note symbols followed by a dangling final replacement character (...🎵 🎵 🎵 🎵 🎵 �). Segment-level decoding succeeded, but word-level timestamp collation crashed in `_split_tokens_on_unicode()`. ### Error ```text IndexError: string index out of range ``` ### Expected behavior - trailing incomplete Unicode fragments at EOF should be ignored or handled safely - Whisper word timestamp decoding should not crash with `IndexError` ### Additional context I have a local fix prepared for this EOF bounds case and can open a PR if this approach looks reasonable. ### Who can help? @ArthurZucker @itazap ### 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 Full end to end reproduction would involve the original audio file (2m 14s of music with some vocals), but the underlying problem is simpler and can be reproduced by calling the `_split_tokens_on_unicode` method with data that could reasonably be outputted. ```python from collections import defaultdict from transformers.models.whisper.tokenization_whisper import _split_tokens_on_unicode class DummyTokenizer: def __init__(self): self.responses = defaultdict(list) def decode(self, tokens, decode_with_timestamps=False): key = tuple(tokens) if self.responses[key]: return self.responses[key].pop(0) tokenizer = DummyTokenizer() tokenizer.responses[(1, 2)] = ["ab"] # decoded_full tokenizer.responses[(1,)] = ["ab"] # first token decodes cleanly tokenizer.responses[(2,)] = ["�"] # trailing replacement char at EOF print(_split_tokens_on_unicode(tokenizer, [1, 2])) ``` Before the fix, this raises: ```text IndexError: string index out of range ``` Because it tries to read `decoded_full[2]` when `len(decoded_full) == 2`. ### Expected behavior Whisper word-timestamp decoding should safely ignore or stop on a trailing incomplete Unicode fragment at end-of-string, instead of crashing with `IndexError: string index out of range`.
open
null
false
1
[ "bug" ]
[]
2026-03-20T01:25:49Z
2026-03-20T13:04:50Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
chromatic-descension
98,860,570
U_kgDOBeR-Gg
User
false
huggingface/transformers
4,105,674,824
I_kwDOCUB6oc70t6BI
44,871
https://github.com/huggingface/transformers/issues/44871
https://api.github.com/repos/huggingface/transformers/issues/44871
[Gemma-3] Inconsistent eos_token_id configuration: tokenizer has single value (1) but model.config has list [1, 106]
### System Info - `transformers` version: 5.3.0 - Platform: Windows-11-10.0.26100-SP0 - Python version: 3.12.11 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.7.0 - Accelerate version: not installed - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.7.1+cu118 (CUDA) - Using distributed or parallel set-up in script?: <fill in> - Using GPU in script?: <fill in> - GPU type: NVIDIA GeForce RTX 4060 Laptop GPU ### 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 ```python from transformers import AutoTokenizer, AutoModelForCausalLM MODEL = "google/gemma-3-1b-it" tokenizer = AutoTokenizer.from_pretrained(MODEL) model = AutoModelForCausalLM.from_pretrained(MODEL) print(tokenizer.eos_token_id) # 1 print(model.config.eos_token_id) # [1, 106] ``` ### Expected behavior ## Expected Behavior Tokenizer and Model Config should be consistent on eos_token_id so that the following generation loop can work correctly: ```python for _ in range(max_new_tokens): ... if new_token_id.item() == tokenizer.eos_token_id: break # should break the loop ```
closed
completed
false
1
[ "bug" ]
[]
2026-03-20T04:29:57Z
2026-03-21T01:40:09Z
2026-03-21T01:40:09Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
IvanFan-Van
98,149,954
U_kgDOBdmmQg
User
false
huggingface/transformers
4,106,938,437
I_kwDOCUB6oc70yuhF
44,877
https://github.com/huggingface/transformers/issues/44877
https://api.github.com/repos/huggingface/transformers/issues/44877
Strict config prevents loading `granite_speech` config
### System Info - `transformers` version: 5.3.0.dev0 - Platform: Windows-10-10.0.26200-SP0 - Python version: 3.11.13 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.6.2 - Accelerate version: 1.11.0 - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.9.0+cu126 (CUDA) - Using distributed or parallel set-up in script?: No - Using GPU in script?: No - GPU type: NVIDIA GeForce RTX 3090 ### Who can help? @zucchini-nlp ### 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 from transformers import AutoConfig model_name = "ibm-granite/granite-4.0-1b-speech" config = AutoConfig.from_pretrained(model_name) ``` ``` Traceback (most recent call last): File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 148, in __strict_setattr__ validator(value) File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 607, in validator type_validator(field.name, value, field.type) File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 474, in type_validator _validate_simple_type(name, value, expected_type) File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 597, in _validate_simple_type raise TypeError( TypeError: Field 'embedding_multiplier' expected float, got int (value: 12) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "[sic]/demo_granite_4_1b_speech.py", line 4, in <module> config = AutoConfig.from_pretrained(model_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "[sic]/src/transformers/models/auto/configuration_auto.py", line 1486, in from_pretrained return config_class.from_dict(config_dict, **unused_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "[sic]/src/transformers/configuration_utils.py", line 757, in from_dict config = cls(**config_dict) ^^^^^^^^^^^^^^^^^^ File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 279, in init_with_validate initial_init(self, *args, **kwargs) # type: ignore [call-arg] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 194, in __init__ self.__post_init__(**additional_kwargs) File "[sic]/src/transformers/models/granite_speech/configuration_granite_speech.py", line 122, in __post_init__ self.text_config = CONFIG_MAPPING[self.text_config["model_type"]](**self.text_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 279, in init_with_validate initial_init(self, *args, **kwargs) # type: ignore [call-arg] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 179, in __init__ setattr(self, f.name, standard_kwargs[f.name]) File "[sic]/Lib/site-packages/huggingface_hub/dataclasses.py", line 150, in __strict_setattr__ raise StrictDataclassFieldValidationError(field=name, cause=e) from e huggingface_hub.errors.StrictDataclassFieldValidationError: Validation error for field 'embedding_multiplier': TypeError: Field 'embedding_multiplier' expected float, got int (value: 12) ``` ### Expected behavior For the config to load as normal. - Tom Aarsen
open
null
false
4
[ "bug" ]
[]
2026-03-20T09:57:02Z
2026-03-20T10:47:03Z
null
MEMBER
null
20260324T120231Z
2026-03-24T12:02:31Z
tomaarsen
37,621,491
MDQ6VXNlcjM3NjIxNDkx
User
false
huggingface/transformers
4,109,855,475
I_kwDOCUB6oc7092rz
44,898
https://github.com/huggingface/transformers/issues/44898
https://api.github.com/repos/huggingface/transformers/issues/44898
[BUG] Perceiver image classification (non-default res) fails even with interpolate_pos_encoding=True
### System Info * `transformers` version: `5.0.0.dev0` * Platform: `Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.39` * Python version: `3.12.3` * `huggingface_hub` version: `1.3.2` * `safetensors` version: `0.7.0` * `accelerate` version: `1.12.0` * Accelerate config: `not installed` * DeepSpeed version: `not installed` * PyTorch version (accelerator?): `2.9.1+cu128 (CUDA)` * GPU type: `NVIDIA L4` * NVIDIA driver version: `550.90.07` * CUDA version: `12.4` ### Information - [x] The official example scripts - [ ] My own modified scripts ### Tasks - [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below) ### Reproduction ```python import torch from transformers import PerceiverForImageClassificationLearned, PerceiverImageProcessorPil from PIL import Image import requests url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw) image_processor = PerceiverImageProcessorPil(size={"height": 384, "width": 384}) model = PerceiverForImageClassificationLearned.from_pretrained("deepmind/vision-perceiver-learned") model.eval() inputs = image_processor(image, return_tensors="pt").pixel_values try: with torch.no_grad(): outputs = model(inputs=inputs, interpolate_pos_encoding=True) print("Logits shape:", outputs.logits.shape) predicted_class = outputs.logits.argmax(-1).item() print("Predicted class:", predicted_class) except Exception as e: print(e) ``` → Trying to run image classification on a 384×384 image (pretrained default is 224×224) and even after setting `interpolate_pos_encoding=True` expecting the model to handle the resolution difference, the model crashes with a `RuntimeError`. → From the screenshot, 384×384 = 147456 and 224×224 = 50176 so it was never actually resized (see the reproduction output). **Current Repro Output:** <img width="500" height="500" alt="Image" src="https://github.com/user-attachments/assets/3f1ac00d-5f36-4d3b-be2a-21f46accd0bb" /> ### Expected behavior → Inference should complete successfully (torch.Size([1, 1000])) when `interpolate_pos_encoding=True` is passed with non-native input res.
open
null
false
0
[ "bug" ]
[]
2026-03-20T19:58:09Z
2026-03-20T19:58:24Z
null
CONTRIBUTOR
null
20260324T120231Z
2026-03-24T12:02:31Z
harshaljanjani
75,426,551
MDQ6VXNlcjc1NDI2NTUx
User
false
huggingface/transformers
4,111,564,283
I_kwDOCUB6oc71EX37
44,906
https://github.com/huggingface/transformers/issues/44906
https://api.github.com/repos/huggingface/transformers/issues/44906
Remove unnecessary `expand_as` in `get_placeholder_mask` across VLMs
### Feature request ## Problem The `get_placeholder_mask` function (and equivalent inline patterns) across ~70 multimodal model files expands a boolean placeholder mask from shape `(B, S, 1)` to `(B, S, H)` via `.expand_as(inputs_embeds)` before passing it to `masked_scatter`. This expansion is unnecessary because `masked_scatter` natively supports broadcasting. For example, in `modeling_llava.py`: ```python special_image_mask = special_image_mask.unsqueeze(-1).expand_as(inputs_embeds).to(inputs_embeds.device) ``` The validation check also uses data-dependent boolean indexing: ```python inputs_embeds[special_image_mask].numel() == image_features.numel() ``` ### Motivation ## Motivation Mainly, Memory. While `expand_as` itself returns a stride-0 view (no copy), the subsequent `.to(device)` call materializes the full `(B, S, H)` boolean tensor when a device transfer is needed. Practically, I assume that the need for actual device transfer is quite rare; however, I believe this is still a safer implementation. ### Your contribution ## Proposed fix 1. Remove `.expand_as(inputs_embeds)`, keeping the mask as `(B, S, 1)`: ```python special_image_mask = special_image_mask.unsqueeze(-1).to(inputs_embeds.device) ``` 2. Replace the validation with equivalent arithmetic: ```python n_image_tokens * inputs_embeds.shape[-1] == image_features.numel() ``` ## Correctness `masked_scatter`, `torch.where`, and element-wise `*` all support broadcasting a `(B, S, 1)` mask to `(B, S, H)`. Verified with: ```python import torch B, S, H = 2, 10, 16 inputs_embeds = torch.randn(B, S, H) features = torch.randn(3, H) mask_2d = torch.zeros(B, S, dtype=torch.bool) mask_2d[0, 2], mask_2d[0, 5], mask_2d[1, 3] = True, True, True mask_old = mask_2d.unsqueeze(-1).expand_as(inputs_embeds) mask_new = mask_2d.unsqueeze(-1) result_old = inputs_embeds.clone().masked_scatter(mask_old, features) result_new = inputs_embeds.clone().masked_scatter(mask_new, features) assert torch.equal(result_old, result_new) # ✓ identical ``` Affects `get_placeholder_mask` and equivalent inline patterns in ~70 files across all VLM models (llava, qwen2_vl, paligemma, gemma3n, chameleon, video_llava, etc.), plus `tensor_parallel.py` and `ovis2`. I have a PR ready: https://github.com/syncdoth/transformers/tree/remove-expand-as-placeholder-mask
open
null
false
0
[ "Feature request" ]
[]
2026-03-21T06:05:36Z
2026-03-21T06:05:36Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
syncdoth
45,599,998
MDQ6VXNlcjQ1NTk5OTk4
User
false
huggingface/transformers
4,111,661,658
I_kwDOCUB6oc71Evpa
44,908
https://github.com/huggingface/transformers/issues/44908
https://api.github.com/repos/huggingface/transformers/issues/44908
inverse_sqrt scheduler ignores lr_scheduler_kwargs (timescale not passed)
### System Info Incomplete arguments passed for schedulers where name is explicitly checked. https://github.com/huggingface/transformers/blob/v5.3.0/src/transformers/optimization.py#L664 ### 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 Trigger a learning job with "inverse_sqrt" and set timesteps = 'random', it still works because the arguments are never passed. ### Expected behavior timesteps should take effect.
closed
completed
false
1
[ "bug" ]
[]
2026-03-21T06:53:50Z
2026-03-24T13:06:18Z
2026-03-24T13:06:18Z
NONE
null
20260324T143453Z
2026-03-24T14:34:53Z
magarwal0205
6,791,598
MDQ6VXNlcjY3OTE1OTg=
User
false
huggingface/transformers
4,112,866,232
I_kwDOCUB6oc71JVu4
44,910
https://github.com/huggingface/transformers/issues/44910
https://api.github.com/repos/huggingface/transformers/issues/44910
[Bug] Flash Attention crashes with illegal memory access on Qwen3.5 due to 3D position_ids being misinterpreted as packed sequence
### System Info # [Bug] Flash Attention crashes with `illegal memory access` on Qwen3.5 due to 3D `position_ids` being misinterpreted as packed sequence We fixed it in https://github.com/ouroborosscr/transformers/tree/fix/qwen35-flash-attn-3d-position-ids ## Description When using `attn_implementation="flash_attention_2"` with Qwen3.5 models, all forward passes crash with `CUDA error: an illegal memory access was encountered`. This affects both training and inference. **Root cause**: Qwen3.5 uses a hybrid architecture (GatedDeltaNet linear attention + standard attention) and passes **3D `position_ids`** with shape `[3, batch_size, seq_len]` (for multi-dimensional rotary embedding). The function `_is_packed_sequence()` in `modeling_flash_attention_utils.py` misinterprets this 3D tensor as a packed sequence indicator, causing `cu_seqlens` to be constructed with 3× the actual token count. Flash Attention then reads beyond the q/k/v tensor boundaries, resulting in an illegal memory access. ## Reproduction ```python import torch from transformers import AutoModelForCausalLM, BitsAndBytesConfig model = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen3.5-9B", # or any Qwen3.5 variant quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16, ), torch_dtype=torch.bfloat16, device_map={"": 0}, attn_implementation="flash_attention_2", ) # This crashes immediately input_ids = torch.randint(100, 5000, (1, 256), device="cuda") with torch.no_grad(): out = model(input_ids=input_ids, use_cache=False) ``` **Error**: ``` torch.AcceleratorError: CUDA error: an illegal memory access was encountered ``` **Traceback** (abbreviated): ``` File "transformers/modeling_flash_attention_utils.py", line 692, in _flash_attention_forward out = flash_varlen_fn( File "flash_attn/flash_attn_interface.py", line 1443, in flash_attn_varlen_func return FlashAttnVarlenFunc.apply( File "flash_attn/flash_attn_interface.py", line 165, in _flash_attn_varlen_forward out, softmax_lse, S_dmask, rng_state = flash_attn_gpu.varlen_fwd( torch.AcceleratorError: CUDA error: an illegal memory access was encountered ``` ## Root Cause Analysis ### Qwen3.5 hybrid architecture Qwen3.5 uses a **mixed attention architecture**: 24 layers of `Qwen3_5GatedDeltaNet` (linear attention) and 8 layers of `Qwen3_5Attention` (standard attention, at layers 3, 7, 11, 15, 19, 23, 27, 31). Only the standard attention layers use flash attention. Qwen3.5 passes **3D `position_ids`** with shape `[3, batch_size, seq_len]` for its multi-dimensional rotary embedding (3 sets of position indices). ### The bug In `modeling_flash_attention_utils.py`, the function `_is_packed_sequence()` (line 444) does not handle tensors with more than 2 dimensions: ```python def _is_packed_sequence(position_ids, batch_size): if position_ids is None: return False increasing_position_sequences = ( torch.arange(position_ids.shape[1], device=position_ids.device) + position_ids.min() ) return batch_size == 1 and (increasing_position_sequences - position_ids).abs().sum().bool() ``` When `position_ids` has shape `[3, 1, 256]`: - `position_ids.shape[1]` returns `1` (not `256` as expected for a 2D `[batch, seq_len]` tensor) - The function returns `True`, misidentifying this as a packed sequence This triggers the packed-sequence code path at line 677: ```python elif is_fa_with_varlen_kwargs or is_fa_with_position_ids: if cu_seq_lens_q is None or cu_seq_lens_k is None: q, k, v, (cu_seq_lens_q, cu_seq_lens_k), (max_length_q, max_length_k) = _prepare_from_posids( query_states, key_states, value_states, position_ids ) ``` Inside `prepare_fa_kwargs_from_position_ids()` (line 362): ```python position_ids = position_ids.reshape(-1) # [3, 1, 256] → [768] indices_q = (position_ids == 0).nonzero().view(-1) # Finds 3 zero positions ``` This constructs `cu_seqlens = [0, 256, 512, 768]`, claiming 3 sequences with 768 total tokens. But the actual q/k/v tensors only contain 256 tokens. Flash Attention reads up to index 768, causing the illegal memory access. ### Intercepted parameters confirming the mismatch ``` 🔍 varlen_fwd parameters: q: torch.Size([256, 16, 256]) ← 256 tokens cu_seqlens_q: tensor([0, 256, 512, 768]) ← claims 768 tokens q total=256 vs cu_seqlens_q[-1]=768 ← MISMATCH → crash ``` ## Fix Add a dimensionality check in `_is_packed_sequence()` to reject tensors with more than 2 dimensions, since packed sequences always use 2D position_ids `[batch, seq_len]`: ```python def _is_packed_sequence(position_ids, batch_size): if position_ids is None: return False if position_ids.dim() > 2: return False increasing_position_sequences = ( torch.arange(position_ids.shape[1], device=position_ids.device) + position_ids.min() ) return batch_size == 1 and (increasing_position_sequences - position_ids).abs().sum().bool() ``` This fix has been validated: all 8 standard attention layers in Qwen3.5-9B pass flash attention forward successfully after applying the patch. ## Environment - **Model**: Qwen3.5-9B (hybrid GatedDeltaNet + standard attention) - **GPU**: NVIDIA A100-SXM4-80GB - **PyTorch**: 2.9.0 / 2.10.0 (both affected) - **Transformers**: 5.3.0 - **flash-attn**: 2.8.3 - **CUDA**: 12.8 ## Impact - Affects **all Qwen3.5 variants** (and potentially any future model using >2D position_ids) - Blocks both training and inference when using `flash_attention_2` - No workaround other than falling back to `sdpa` or `eager` attention implementations ### Who can help? @vasqu @ArthurZucker (attention) ### 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 GRPO reinforcement learning training with Qwen3.5-9B using TRL GRPOTrainer When using `attn_implementation="flash_attention_2"` with Qwen3.5, all forward passes crash with CUDA illegal memory access. Minimal reproduction: ```python import torch from transformers import AutoModelForCausalLM, BitsAndBytesConfig model = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen3.5-9B", quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16, ), torch_dtype=torch.bfloat16, device_map={"": 0}, attn_implementation="flash_attention_2", ) input_ids = torch.randint(100, 5000, (1, 256), device="cuda") with torch.no_grad(): out = model(input_ids=input_ids, use_cache=False) # crashes here ``` **Error:** ``` torch.AcceleratorError: CUDA error: an illegal memory access was encountered ``` **Root cause:** Qwen3.5 is a hybrid architecture (24 GatedDeltaNet layers + 8 standard attention layers). It uses 3D `position_ids` with shape `[3, batch_size, seq_len]` for multi-dimensional rotary embedding. `_is_packed_sequence()` in `modeling_flash_attention_utils.py` (line 444) does not handle >2D tensors: ```python def _is_packed_sequence(position_ids, batch_size): if position_ids is None: return False increasing_position_sequences = ( torch.arange(position_ids.shape[1], device=position_ids.device) + position_ids.min() ) return batch_size == 1 and (increasing_position_sequences - position_ids).abs().sum().bool() ``` When `position_ids` has shape `[3, 1, 256]`, `position_ids.shape[1]` returns `1` instead of the sequence length, and the function returns `True`, misidentifying this as a packed sequence. This triggers `prepare_fa_kwargs_from_position_ids()` which does: ```python position_ids = position_ids.reshape(-1) # [3, 1, 256] → [768] indices_q = (position_ids == 0).nonzero() # finds 3 zero positions # constructs cu_seqlens = [0, 256, 512, 768] — claims 768 tokens ``` But q/k/v only contain 256 tokens. Flash attention reads up to index 768, causing the illegal memory access. **Intercepted evidence:** ``` q: torch.Size([256, 16, 256]) ← 256 tokens cu_seqlens_q: tensor([0, 256, 512, 768]) ← claims 768 tokens q total=256 vs cu_seqlens_q[-1]=768 ← MISMATCH → crash ``` **Environment:** - Model: Qwen3.5-9B - GPU: NVIDIA A100-SXM4-80GB - PyTorch: 2.9.0 and 2.10.0 (both affected) - transformers: 5.3.0 - flash-attn: 2.8.3 - CUDA: 12.8 **Fix:** Add `if position_ids.dim() > 2: return False` in `_is_packed_sequence()`. Packed sequences always use 2D `[batch, seq_len]` position_ids. ### Expected behavior Model forward pass with `attn_implementation="flash_attention_2"` should complete successfully without CUDA errors. After the fix (adding dimensionality check for >2D position_ids), all 8 standard attention layers in Qwen3.5-9B pass flash attention forward correctly.
closed
completed
false
5
[ "bug" ]
[]
2026-03-21T15:38:54Z
2026-03-24T14:36:36Z
2026-03-24T14:36:36Z
NONE
null
20260324T145640Z
2026-03-24T14:56:40Z
ouroborosscr
75,082,702
MDQ6VXNlcjc1MDgyNzAy
User
false
huggingface/transformers
4,113,147,717
I_kwDOCUB6oc71KadF
44,912
https://github.com/huggingface/transformers/issues/44912
https://api.github.com/repos/huggingface/transformers/issues/44912
git-oss-20b will not properly load with MXFP4 quantization and falls back to bf16
### System Info Hi, probably this is related to https://github.com/huggingface/transformers/issues/42723 I get: MXFP4 quantization requires Triton and kernels installed: CUDA requires Triton >= 3.4.0, XPU requires Triton >= 3.5.0, we will default to dequantizing the model to bf16 When executing the following code: pipeline = transformers.pipeline( "text-generation", model=model_id, token=HF_TOKEN, #model_kwargs={"dtype": torch.bfloat16}, device_map="auto", ) $ hf env Copy-and-paste the text below in your GitHub issue. - huggingface_hub version: 1.7.2 - Platform: Linux-6.8.0-106-generic-x86_64-with-glibc2.39 - Python version: 3.12.3 - Running in iPython ?: No - Running in notebook ?: No - Running in Google Colab ?: No - Running in Google Colab Enterprise ?: No - Token path ?: /scratch/work/ml_ki/llama/huggingface/token - Has saved token ?: True - Who am I ?: jottbe - Configured git credential helpers: - Installation method: unknown - httpx: 0.28.1 - hf_xet: 1.4.2 - gradio: N/A - tensorboard: N/A - ENDPOINT: https://huggingface.co - HF_HUB_CACHE: /scratch/work/ml_ki/llama/huggingface/hub - HF_ASSETS_CACHE: /scratch/work/ml_ki/llama/huggingface/assets - HF_TOKEN_PATH: /scratch/work/ml_ki/llama/huggingface/token - HF_STORED_TOKENS_PATH: /scratch/work/ml_ki/llama/huggingface/stored_tokens - HF_HUB_OFFLINE: False - HF_HUB_DISABLE_TELEMETRY: False - HF_HUB_DISABLE_PROGRESS_BARS: None - HF_HUB_DISABLE_SYMLINKS_WARNING: False - HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False - HF_HUB_DISABLE_IMPLICIT_TOKEN: False - HF_HUB_DISABLE_XET: False - HF_HUB_ETAG_TIMEOUT: 10 - HF_HUB_DOWNLOAD_TIMEOUT: 10 - HF_XET_HIGH_PERFORMANCE: False Package versions: transformers 5.3.0 triton 3.6.0 nvidia-cublas-cu12 12.8.4.1 nvidia-cuda-cupti-cu12 12.8.90 nvidia-cuda-nvrtc-cu12 12.8.93 nvidia-cuda-runtime-cu12 12.8.90 nvidia-cudnn-cu12 9.10.2.21 nvidia-cufft-cu12 11.3.3.83 nvidia-cufile-cu12 1.13.1.3 nvidia-curand-cu12 10.3.9.90 nvidia-cusolver-cu12 11.7.3.90 nvidia-cusparse-cu12 12.5.8.93 nvidia-cusparselt-cu12 0.7.1 nvidia-nccl-cu12 2.27.5 nvidia-nvjitlink-cu12 12.8.93 nvidia-nvshmem-cu12 3.4.5 nvidia-nvtx-cu12 12.8.90 torch 2.10.0 torchaudio 2.10.0 torchvision 0.25.0 $ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Fri_Jan__6_16:45:21_PST_2023 Cuda compilation tools, release 12.0, V12.0.140 Build cuda_12.0.r12.0/compiler.32267302_0 ### Who can help? @ArthurZucker @Cyrilvallez ### 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 pipeline = transformers.pipeline( "text-generation", model=model_id, token=HF_TOKEN, #model_kwargs={"dtype": torch.bfloat16}, device_map="auto", ) ### Expected behavior Should load with 4bit quantization.
closed
completed
false
5
[ "bug" ]
[]
2026-03-21T17:38:02Z
2026-03-24T15:33:17Z
2026-03-24T15:33:17Z
NONE
null
20260324T215331Z
2026-03-24T21:53:31Z
jottbecr
126,362,918
U_kgDOB4glJg
User
false
huggingface/transformers
4,113,212,978
I_kwDOCUB6oc71KqYy
44,913
https://github.com/huggingface/transformers/issues/44913
https://api.github.com/repos/huggingface/transformers/issues/44913
In GPTNeoXConfig, rotary_pct silently reverts to default on reload
### System Info - `transformers` version: 5.3.0 - Platform: Linux-6.17.0-19-generic-x86_64-with-glibc2.39 - Python version: 3.12.4 - Huggingface_hub version: 1.7.2 - Safetensors version: 0.4.5 - Accelerate version: not installed - Accelerate config: not found - DeepSpeed version: not installed - PyTorch version (accelerator?): 2.5.1 (NA) - Using distributed or parallel set-up in script?: No When creating a `GPTNeoXConfig` with non-default `rotary_pct`, value is lost after `save_pretrained` / `from_pretrained`. ## Cause https://github.com/huggingface/transformers/blob/3a3b59cb1a7c0238c8d1072e35d3879c5faff48e/src/transformers/models/gpt_neox/configuration_gpt_neox.py#L98 `save_pretrained` writes `partial_rotary_factor` inside `rope_parameters` but does not persist `rotary_pct` as a top-level key. On reload, `rotary_pct` is absent from kwargs, so this line unconditionally overwrites the correct value with `0.25`. ## Fix ```python rotary_pct = kwargs.pop("rotary_pct", None) if rotary_pct is not None: self.rope_parameters["partial_rotary_factor"] = rotary_pct else: self.rope_parameters.setdefault("partial_rotary_factor", 0.25) ``` Verified locally after applying this, the value survives the round-trip. Models using the default `rotary_pct=0.25` (gpt-neox-20b, Pythia, etc.) are unaffected since the overwrite produces the same value. ### Who can help? @ArthurZucker @Cyrilvallez ### 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 from transformers import GPTNeoXConfig config = GPTNeoXConfig(rotary_pct=1.0) print(config.rope_parameters["partial_rotary_factor"]) # 1.0 config.save_pretrained("/tmp/test") config2 = GPTNeoXConfig.from_pretrained("/tmp/test") print(config2.rope_parameters["partial_rotary_factor"]) # 0.25 ``` ### Expected behavior `partial_rotary_factor` value should be retained
open
null
false
1
[ "bug" ]
[]
2026-03-21T17:58:32Z
2026-03-23T10:09:34Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
ratishsp
3,006,607
MDQ6VXNlcjMwMDY2MDc=
User
false
huggingface/transformers
4,114,204,538
I_kwDOCUB6oc71Ocd6
44,918
https://github.com/huggingface/transformers/issues/44918
https://api.github.com/repos/huggingface/transformers/issues/44918
Unpacking Qwen3.5 input embeddings fails with trl SFT trainer
### System Info My environment: ``` datasets==4.6.1 faiss-cpu==1.13.2 numpy==2.4.2 pyserini==1.5.0 sentence-transformers==5.2.3 torch==2.10.0 torchvision==0.25.0 tqdm==4.67.3 trl==0.29.1 wandb==0.25.1 ``` ### Who can help? @zucchini-nlp ### 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 This is the code I am using: ```py config = SFTConfig( output_dir=checkpoints_path, max_steps=num_steps, dataset_text_field="text", max_length=2048, logging_strategy="steps", logging_steps=max(1, checkpoint_frequency // 5), disable_tqdm=False, save_strategy="steps", save_steps=checkpoint_frequency, eval_strategy="steps", eval_steps=checkpoint_frequency, load_best_model_at_end=True, metric_for_best_model="eval_loss", greater_is_better=False, report_to="wandb", run_name=run_name, ) trainer = SFTTrainer( model=lm.model, args=config, train_dataset=train_ds, eval_dataset=eval_ds, ) trainer.train() trainer.save_model() ``` ### Expected behavior Successful SFT. Instead I get the following error with a simple qwen3.5 SFT setup. Running inference only worked fine for me ``` Traceback (most recent call last): File "/workspace/writeable/open-ended-csp/tmp.py", line 41, in <module> train_sft( File "/workspace/writeable/open-ended-csp/utils/sft_trainer.py", line 52, in train_sft trainer.train() File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 1412, in train return inner_training_loop( ^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 1742, in _inner_training_loop tr_loss_step = self.training_step(model, inputs, num_items_in_batch) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/trl/trainer/sft_trainer.py", line 1338, in training_step return super().training_step(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 1951, in training_step loss = self.compute_loss(model, inputs, num_items_in_batch=num_items_in_batch) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/trl/trainer/sft_trainer.py", line 1234, in compute_loss (loss, outputs) = super().compute_loss( ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 2022, in compute_loss outputs = model(**inputs) ^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/accelerate/utils/operations.py", line 823, in forward return model_forward(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/accelerate/utils/operations.py", line 811, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/torch/amp/autocast_mode.py", line 44, in decorate_autocast return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/utils/generic.py", line 841, in wrapper output = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/models/qwen3_5/modeling_qwen3_5.py", line 1938, in forward outputs = self.model( ^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/utils/generic.py", line 841, in wrapper output = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/models/qwen3_5/modeling_qwen3_5.py", line 1685, in forward position_ids = self.compute_3d_position_ids( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/writeable/open-ended-csp/.venv/lib/python3.12/site-packages/transformers/models/qwen3_5/modeling_qwen3_5.py", line 1619, in compute_3d_position_ids batch_size, seq_length, _ = inputs_embeds.shape ^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: too many values to unpack (expected 3) wandb: wandb: 🚀 View run test-qwen3.5 at: https://wandb.ai/jj-uoe/open-ended-csp/runs/1sercncq wandb: Find logs at: wandb/run-20260321_232655-1sercncq/logs ```
closed
completed
false
3
[ "bug" ]
[]
2026-03-21T23:43:15Z
2026-03-23T15:20:11Z
2026-03-23T15:20:11Z
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
JakobJBauer
53,357,351
MDQ6VXNlcjUzMzU3MzUx
User
false
huggingface/transformers
4,116,497,241
I_kwDOCUB6oc71XMNZ
44,928
https://github.com/huggingface/transformers/issues/44928
https://api.github.com/repos/huggingface/transformers/issues/44928
[Bug] Catastrophic gradient explosion (NaN) in RLHF with Qwen3.5 due to 3D position_ids forcing SDPA Math fallback and BF16 collapse
### System Info Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points. - `transformers` version: 5.3.0 - Platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35 - Python version: 3.11.15 - Huggingface_hub version: 1.7.1 - Safetensors version: 0.7.0 - Accelerate version: 1.13.0 - Accelerate config: not found - DeepSpeed version: 0.18.8 - PyTorch version (accelerator?): 2.10.0+cu128 (CUDA) - Using distributed or parallel set-up in script?: <fill in> - Using GPU in script?: <fill in> - GPU type: NVIDIA A100-SXM4-80GB ### Who can help? @ArthurZucker @Cyrilvallez ### 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 We have fully isolated the issue and provided a reproducible repository here: 👉 https://github.com/ouroborosscr/Report-the-gradient-explosion-of-qwen3.5 1.Verify Dapo degradation ```python CUDA_LAUNCH_BLOCKING=1 CUDA_HOME=/usr/local/cuda-12.8 LD_PRELOAD=/opt/anaconda3/envs/scr_train2/lib/libstdc++.so.6 CUDA_VISIBLE_DEVICES=2 torchrun --nproc_per_node=1 audit_qwen_hf.py ``` Output: ``` ============================================================ 🔍 [源码级审计] Qwen3.5 (SDPA 模式) 到底传了什么给底层? ============================================================ ➡️ 模拟 DAPO 训练输入,序列长度: 8192 🚨 [劫持成功] Qwen3.5 正在调用 PyTorch SDPA! Query 形状: torch.Size([1, 8, 8192, 128]) ⚠️ Qwen 传来的 Mask 形状: torch.Size([1, 1, 8192, 8192]) ⚠️ Mask 的数据类型: torch.bool 💀 仅这个 Mask 矩阵就会占据显存: 0.125000 GB is_causal 参数: False ``` 2.Verify gradient explosion ```python CUDA_LAUNCH_BLOCKING=1 CUDA_HOME=/usr/local/cuda-12.8 LD_PRELOAD=/opt/anaconda3/envs/scr_train2/lib/libstdc++.so.6 CUDA_VISIBLE_DEVICES=2 torchrun --nproc_per_node=1 train_dapo_3_debug.py --use_lora --use_4bit ``` Output: ``` …… 💥 [爆点定位] 梯度在经过 【model.layers.30.linear_attn.norm】 的反向计算后瞬间爆炸! 传出梯度最大值: 26240.0 ⚠️ [数值爆炸预警] 层: model.layers.27.self_attn.v_proj | 梯度 Max: 17280.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.27.self_attn.k_norm | 梯度 Max: 135168.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.27.self_attn.k_proj | 梯度 Max: 111616.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.27.self_attn.q_norm | 梯度 Max: 126976.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.27.self_attn.q_proj | 梯度 Max: 97280.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn | 梯度 Max: 67072.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.o_proj | 梯度 Max: 67072.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.v_proj | 梯度 Max: 13172736.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.k_norm | 梯度 Max: 62390272.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.k_proj | 梯度 Max: 45613056.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.q_norm | 梯度 Max: 297795584.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.23.self_attn.q_proj | 梯度 Max: 242221056.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn | 梯度 Max: 132120576.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.o_proj | 梯度 Max: 132120576.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.v_proj | 梯度 Max: 48103633715200.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.k_norm | 梯度 Max: 68444598829056.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.k_proj | 梯度 Max: 54150947667968.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.q_norm | 梯度 Max: 141836999983104.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.19.self_attn.q_proj | 梯度 Max: 204509162766336.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn | 梯度 Max: 131391639519232.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.o_proj | 梯度 Max: 131391639519232.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.v_proj | 梯度 Max: 1549526502191602335744.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.k_norm | 梯度 Max: 1752440687002407403520.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.k_proj | 梯度 Max: 2822351843277561397248.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.q_norm | 梯度 Max: 2600990914393046777856.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.15.self_attn.q_proj | 梯度 Max: 5902958103587056517120.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn | 梯度 Max: 2951479051793528258560.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.o_proj | 梯度 Max: 2951479051793528258560.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.v_proj | 梯度 Max: 4584246707978673830485819392.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.k_norm | 梯度 Max: 7969239002899635519663112192.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.k_proj | 梯度 Max: 14932651723879899565970685952.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.q_norm | 梯度 Max: 40852021296417549071671099392.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.11.self_attn.q_proj | 梯度 Max: 41470991316060239209120661504.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn | 梯度 Max: 52612451669628661683212779520.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.o_proj | 梯度 Max: 52612451669628661683212779520.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.v_proj | 梯度 Max: 7382797095729208034316799468109824.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.k_norm | 梯度 Max: 29206669829258405410484041851863040.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.k_proj | 梯度 Max: 50949412924372996104955495230472192.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.q_norm | 梯度 Max: 55168154121932543553136523497963520.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.7.self_attn.q_proj | 梯度 Max: 113581493780449354374104607201689600.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.3.self_attn | 梯度 Max: 138893940965806639063190776806637568.00 | Dtype: torch.bfloat16 ⚠️ [数值爆炸预警] 层: model.layers.3.self_attn.o_proj | 梯度 Max: 138893940965806639063190776806637568.00 | Dtype: torch.bfloat16 …… ``` 3.Fix ``` CUDA_LAUNCH_BLOCKING=1 CUDA_HOME=/usr/local/cuda-12.8 LD_PRELOAD=/opt/anaconda3/envs/scr_train2/lib/libstdc++.so.6 CUDA_VISIBLE_DEVICES=2 torchrun --nproc_per_node=1 train_dapo_3_debug.py --use_lora --use_4bit --use_flash_attn ``` Output: ``` …… [🔍 22:47:55] ✅ Step 1 梯度全部正常 (最大 =0.003845 @ base_model.model.model.layers.3.self_attn.v_proj.lora_B.default.weight) …… ``` ### Expected behavior 1. **Avoid Silent Fallbacks to the Math Backend:** When training Qwen3.5 models (or any Qwen2 architecture handling 3D `position_ids`/mRoPE), the `transformers` implementation explicitly materializes a massive 4D Dense Mask (`[Batch, 1, SeqLen, SeqLen]`) and sets `is_causal=False`. This design explicitly violates PyTorch SDPA’s fused kernel constraints (`if (attn_mask.has_value()) { return false; }`), silently forcing a downgrade to the `Math` backend. **Expected behavior:** The implementation should decouple mRoPE coordinate handling from the attention mask generation, preserving the ability to rely on the implicit `is_causal=True` mechanism, which keeps the highly optimized FlashAttention kernel engaged. 2. **Prevent BF16 Precision Collapse in Long-Context RLHF:** The PyTorch `Math` backend is fundamentally unsafe for accumulating Softmax denominators over thousands of tokens (e.g., 8K - 100K) in `bfloat16`. Without the FP32 SRAM accumulators used by fusion kernels, the `Math` backend suffers from severe truncation errors (swamping). Under RLHF losses (like DPO/GRPO/DAPO) which contain exponential amplifiers (`exp(beta * log_probs)`), these errors invariably snowball into catastrophic $10^{28}$ or `NaN` gradients. **Expected behavior:** `transformers` should provide a native `varlen` (variable-length) or `NestedTensors` implementation for `sdpa` that physically truncates padded tokens rather than masking them with `-3.4e38` in a dense tensor, thereby bypassing the mathematically unstable `bfloat16` accumulations. 3. **Explicit Warning or Fallback to FA2:** Until a native SDPA `varlen` solution is implemented, `transformers` should aggressively warn users when `sdpa` is initialized alongside padding masks on models requiring dense mask materialization. Currently, explicitly setting `attn_implementation="flash_attention_2"` is the _only_ mathematically safe approach, as `Qwen2FlashAttention2` uses `cu_seqlens` to physically drop padding and leverages FP32 registers internally, perfectly stabilizing the RLHF gradients.
open
null
false
2
[ "bug" ]
[]
2026-03-22T16:46:05Z
2026-03-23T10:05:17Z
null
NONE
null
20260324T120231Z
2026-03-24T12:02:31Z
ouroborosscr
75,082,702
MDQ6VXNlcjc1MDgyNzAy
User
false
End of preview. Expand in Data Studio

Transformers PR Slop Dataset

Normalized snapshots of issues, pull requests, comments, reviews, and linkage data from huggingface/transformers.

Files:

  • issues.parquet
  • pull_requests.parquet
  • comments.parquet
  • issue_comments.parquet (derived view of issue discussion comments)
  • pr_comments.parquet (derived view of pull request discussion comments)
  • reviews.parquet
  • pr_files.parquet
  • pr_diffs.parquet
  • review_comments.parquet
  • links.parquet
  • events.parquet
  • new_contributors.parquet
  • new-contributors-report.json
  • new-contributors-report.md

Use:

  • duplicate PR and issue analysis
  • triage and ranking experiments
  • eval set creation

Notes:

  • updated daily
  • latest snapshot: 20260324T215331Z
  • raw data only; no labels or moderation decisions
  • PR metadata, file-level patch hunks, and full unified diffs are included
  • new contributor reviewer artifacts are included when generated for the snapshot
  • full file contents for changed files are not included
Downloads last month
23