-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
What happened?
Below is my code
#!/usr/bin/env python3
"""
QLoRA fine-tune Mistral-Small-3.2-24B-Instruct-2506
with MistralTokenizer (mistral-common) + TRL SFTTrainer
"""
from datetime import datetime, timedelta
from mistral_common.protocol.instruct.request import ChatCompletionRequest
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from huggingface_hub import hf_hub_download
from transformers import Mistral3ForConditionalGeneration
import torch, json
from datasets import Dataset
from transformers import (
Mistral3ForConditionalGeneration, TrainingArguments
)
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
from trl import SFTTrainer
------------------------------------------------------------------
1️⃣ Model & tokenizer (mistral-common)
------------------------------------------------------------------
model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
tokenizer = MistralTokenizer.from_hf_hub(model_id)
4-bit QLoRA
lora_config = LoraConfig(
r=64, lora_alpha=128, lora_dropout=0.0,
target_modules=[
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj",
],
bias="none", task_type="CAUSAL_LM"
)
model = Mistral3ForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model = prepare_model_for_kbit_training(model)
model = get_peft_model(model, lora_config)
Here is the error:
RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py in getattr(self, name)
2291 try:
-> 2292 module = self._get_module(self._class_to_module[name])
2293 value = getattr(module, name)
22 frames
RuntimeError: operator torchvision::nms does not exist
The above exception was the direct cause of the following exception:
ModuleNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py in getattr(self, name)
2293 value = getattr(module, name)
2294 except (ModuleNotFoundError, RuntimeError) as e:
-> 2295 raise ModuleNotFoundError(
2296 f"Could not import module '{name}'. Are this object's requirements defined correctly?"
2297 ) from e
ModuleNotFoundError: Could not import module 'Mistral3ForConditionalGeneration'. Are this object's requirements defined correctly?
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
Steps to reproduce
Relevant API REQUEST output
Provider/Model
"mistralai/Mistral-Small-3.2-24B-Instruct-2506"
System Information
Colab Pro +
Cline Version
NA