You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unsloth/Mistral-Small-24B-Instruct-2501 RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3 #1600
Hi there!
I am trying to infer the new Mistral3 24B, getting a Runtime error related to dimension sizes: RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3
Steps to reproduce:
fromunslothimportFastLanguageModelmodel, tokenizer=FastLanguageModel.from_pretrained(
model_name="unsloth/Mistral-Small-24B-Instruct-2501",
load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
messages= [
{"role": "user", "content": "Describe the tallest tower in the world."},
]
inputs=tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
_=model.generate(input_ids=inputs, max_new_tokens=1024, use_cache=True)
Has anyone encountered something similar?
Reacted by Iskander Safiulin, Dmitriy, Ilya Chernikov, Bartłomiej Różański, Weilu Jia and Narendra Patwardhan
changed the title [-]Mistral Small 2501 RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3[/-][+]unsloth/Mistral-Small-24B-Instruct-2501 RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3[/+]on Feb 1, 2025
hmm. weird, I still get the same error.
I tried clearing the model cache and reinstalling unsloth
~/.local/lib/python3.10/site-packages/unsloth/kernels/rope_embedding.py in forward(ctx, Q, cos, sin, position_ids)
171 half = Q.shape[-1]//2
172 RH_Q = torch.cat((-Q[..., half:], Q[..., :half]), dim = -1)
--> 173 Q *= cos
174 Q.addcmul_(RH_Q, sin)
175 # RH_Q *= sin
RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3
upd: also tried to use original mistralai/Mistral-Small-24B-Instruct-2501 with AutoModelForCausalLM by transformers. Seems to work correctly:
fromtransformersimportAutoModelForCausalLM, AutoTokenizermodel=AutoModelForCausalLM.from_pretrained("mistralai/Mistral-Small-24B-Instruct-2501", device_map="auto")
tokenizer=AutoTokenizer.from_pretrained("mistralai/Mistral-Small-24B-Instruct-2501")
messages= [
{"role": "system", "content": "You are DeepSeek4."},
{"role": "user", "content": "What is your name?"}
]
model_inputs=tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
generated_ids=model.generate(model_inputs, max_new_tokens=100, do_sample=True)
tokenizer.batch_decode(generated_ids)[0]
Activity
[-]Mistral Small 2501 RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3[/-][+]unsloth/Mistral-Small-24B-Instruct-2501 RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 3[/+]mkturkcan commentedon Feb 1, 2025
Seconding this; I am getting the same error.
danielhanchen commentedon Feb 2, 2025
It should work now hopefully! Apologies! Also better to do:
ichrnkv commentedon Feb 2, 2025
hmm. weird, I still get the same error.
I tried clearing the model cache and reinstalling unsloth
upd: also tried to use original
mistralai/Mistral-Small-24B-Instruct-2501with AutoModelForCausalLM by transformers. Seems to work correctly:macksin commentedon Feb 3, 2025
@ichrnkv got the exact same error for the:
unsloth/Llama-3.2-1B-Instructmodel.Also got a correct inference using the
AutoModelForCausalLM.#851 seems related.
ichrnkv commentedon Feb 3, 2025
@macksin downgrading to
unsloth==2025.1.5andtransformers==4.47.1fixed my problem with Mistral3@danielhanchen FYI
sunghyunkwon1992 commentedon Feb 3, 2025
For Mistal-Small-24B, downgrading to 2025.1.5 prevented loading the model, but !pip install -U transformers==4.47.1 worked like a charm.
macksin commentedon Feb 4, 2025
Worked, THANKS
rolandtannous commentedon Jun 29, 2025
Hello ,
This should now work with the latest version of Unsloth.
Please make sure to upgrade your installation to the latest version using
Will close this for now.
Please feel free to comment back if you are still facing the same issue after trying the above.
Thank you for using Unsloth