Repository navigation
Closed
Labels
Description
Hi all! I'm having issues with finetuning Devstral2 after updating unsloth and transformers packages. GPT_OSS also returns similar error. Any help would be appreciated!
unsloth = 2025.12.9
unsloth_zoo = 2025.12.7
transformers = 5.0.0.dev0
torch = 2.9.1
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = MODEL_DIR,
max_seq_length = MAX_SEQ_LENGTH,
full_finetuning = False,
local_files_only = True,
load_in_4bit = False,
device_map = "balanced",
max_memory = {0:"78GiB", 1:"78GiB", 2:"78GiB", 3:"78GiB", "cpu":"256GiB"},
offload_folder = offload_dir,
trust_remote_code = True,
config = config,
)
model = FastLanguageModel.get_peft_model(
model,
r = 4,
finetune_language_layers = True,
finetune_attention_modules = True,
finetune_mlp_modules = True,
lora_alpha = 8,
lora_dropout = 0.0,
bias = "none",
use_gradient_checkpointing = "unsloth",
random_state = 3407,
use_rslora = False,
loftq_config = None,
)trainer = SFTTrainer(
model = model,
tokenizer = tokenizer,
train_dataset = dataset,
eval_dataset = None,
args = SFTConfig(
dataset_text_field = "text",
per_device_train_batch_size = 2,
gradient_accumulation_steps = 2,
warmup_steps = 5,
max_steps = 15,
learning_rate = 2e-4,
logging_steps = 1,
optim = "adamw_8bit",
weight_decay = 0.001,
lr_scheduler_type = "linear",
seed = 3407,
report_to = "none",
),
)Full log:
File "/root/oss_aws/devstral_test.py", line 273, in <module>
_ = trainer.model(input_ids=x, attention_mask=torch.ones_like(x))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal
l_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/peft/peft_model.py", line 1850, in forward
return self.base_model(
^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal
l_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/peft/tuners/tuners_utils.py", line 222, in forward
return self.model.forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/accelerate/hooks.py", line 175, in new_forward
output = module._old_forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/transformers/src/transformers/utils/generic.py", line 810, in wrapper
output = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/transformers/src/transformers/models/ministral3/modeling_ministral3.py", line 473, in fo
rward
outputs: BaseModelOutputWithPast = self.model(
^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal
l_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/transformers/src/transformers/utils/generic.py", line 965, in wrapper
outputs = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/transformers/src/transformers/models/ministral3/modeling_ministral3.py", line 409, in fo
rward
hidden_states = decoder_layer(
^^^^^^^^^^^^^^
File "/root/transformers/src/transformers/modeling_layers.py", line 94, in __call__
return super().__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal
l_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/uns/lib/python3.12/site-packages/accelerate/hooks.py", line 175, in new_forward |
output = module._old_forward(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/transformers/src/transformers/models/ministral3/modeling_ministral3.py", line 242, in fo|
rward |
hidden_states, _ = self.self_attn( |
^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal|
l_impl |
return self._call_impl(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl |
return forward_call(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/accelerate/hooks.py", line 175, in new_forward |
output = module._old_forward(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/transformers/src/transformers/models/ministral3/modeling_ministral3.py", line 144, in fo|
rward |
query_states = self.q_proj(hidden_states).view(hidden_shape).transpose(1, 2) |
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal|
l_impl |
return self._call_impl(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl |
return forward_call(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/peft/tuners/lora/layer.py", line 757, in forward |
result = self.base_layer(x, *args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_cal|
l_impl |
return self._call_impl(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl |
return forward_call(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/accelerate/hooks.py", line 175, in new_forward |
output = module._old_forward(*args, **kwargs) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/unsloth/kernels/fp8.py", line 590, in patched_forward |
return forward_function(X, self.weight, getattr(self, scale_attr)) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/unsloth/kernels/fp8.py", line 392, in fp8_torch_block_q|
uant_forward |
return FP8BlockQuantLinear.apply(X, weight, weight_scale) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/torch/autograd/function.py", line 581, in apply |
return super().apply(*args, **kwargs) # type: ignore[misc] |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
File "/root/uns/lib/python3.12/site-packages/unsloth/kernels/fp8.py", line 347, in forward |
p, q = weight_scale.shape |
^^^^ |
ValueError: not enough values to unpack (expected 2, got 0)
Activity
shimmyshimmer commentedon Jan 8, 2026
Have you tried using an old version of transformers and see if it works? Currently transformers v5 is still a bit buggy
Klepackp commentedon Jan 8, 2026
Transformers v5 is needed for ministral3 architecture support
Datta0 commentedon Jan 9, 2026
Hey @Klepackp i see that you're possibly running an FP8 model. Do you mind sharing the model URL or so that I can inspect the model and possibly try reproducing the issue?
Klepackp commentedon Jan 9, 2026
Of course, it's unsloth/Devstral-2-123B-Instruct-2512
Datta0 commentedon Jan 9, 2026
Hey @Klepackp the model seems to be FP8 with per tensor quantization which we didn't explicitly have support for so far. We do support block quantized FP8 and row/channel quantized FP8 supported.
I'm working on adding it. Please give us some time for the same. Will update you once that is taken care of :)
Klepackp commentedon Jan 9, 2026
Thanks for the heads up :)
Datta0 commentedon Jan 9, 2026
Hey @Klepackp I managed to push a fix for this, it'd be of great help if you can confirm whether this works for you.
For installing this you can do
Then you can proceed with your finetuning as usual
PS: I'm reopening this issue till you confirm that this fix works for you :)
Klepackp commentedon Jan 9, 2026
Hi, thanks for the great work! While your fix helped partially, we encountered another problem with loss calculations. Currently investigating if the issues are related or separate.
Datta0 commentedon Jan 9, 2026
This is perhaps a mutli GPU thing
definitely unrelated to devstral 2
Can you try replacing devstral 2 with another model and see if this error persists?
If yes, can you open another issue for that ? :)
Datta0 commentedon Jan 12, 2026
Hey @Klepackp I see you closed the issue. Did your multi GPU fail case start working or do you still need help with that ?
Klepackp commentedon Jan 13, 2026
Hi, running the script with
os.environ["TOKENIZERS_PARALLELISM"] = "false"fixed the issue and fine-tuning works fine now.Datta0 commentedon Jan 13, 2026
Cool, great if it worked for you. Now if someone else faces the issue, the might find help from this :)