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
[Bug] NameError: name 'slice_indices' is not defined - qwen 2 kaggle. #3450
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Jun__6_02:18:23_PDT_2024
Cuda compilation tools, release 12.5, V12.5.82
Build cuda_12.5.r12.5/compiler.34385749_0
transformers version 4.56.2
Just a few hours ago, this message began to appear. How to solve the problem?
changed the title [-][Bug] Please fill in your issue title here.[/-][+][Bug] NameError: name 'slice_indices' is not defined - qwen 2 kaggle.[/+]on Oct 14, 2025
import os
os.environ["UNSLOTH_RETURN_LOGITS"] = "0"
os.environ.pop("UNSLOTH_RETURN_LOGITS", None)
path = "/content/unsloth_compiled_cache/unsloth_compiled_module_qwen2_vl.py"
s = open(path, "r", encoding="utf-8").read()
s = s.replace("hidden_states[:, slice_indices, :]", "hidden_states")
open(path, "w", encoding="utf-8").write(s)
unsloth_compiled_module_qwen2_vl.py
I don't know where this file is located, and I'm guessing it's rewritten each time the library is loaded.
So I can't modify it to achieve my goal.
Where is its source file? What generates it?
Additionally, it's worth clarifying the differences between the Qwen2, Qwen2.5, and Qwen3 models and their corresponding ipynb files.
I compared the two files and found no difference, aside from the library version.
I suspect this is related to the model. Different models use different files in the unsloth_compiled_cache, which can sometimes cause errors and sometimes not.
Thus, the ultimate cause of the problem may lie with the files in the unsloth_compiled_cache, rather than the model.
😭 Not for me. I had to use a smaller model like the Qwen2-VL-2B; the Qwen3-VL-4B was too large.
My main issue was inference on devices without a GPU.
Oh I see, is it for an edge device? Because it is fine if not. You can use a smaller Qwen3 model. Before that, have you saved the weights of the Qwen2.5vl model? You can run it without unsloth if you think that will solve your problem.
😭 Not for me. I had to use a smaller model like the Qwen2-VL-2B; the Qwen3-VL-4B was too large.
My main issue was inference on devices without a GPU.
Oh I see, is it for an edge device? Because it is fine if not. You can use a smaller Qwen3 model. Before that, have you saved the weights of the Qwen2.5vl model? You can run it without unsloth if you think that will solve your problem.
I tried training, and it seems to work fine.
So, I can try saving the weights. If that works, I can save them first and then use some other inference method!
I'm not sure about compatibility; it's said to be slow, but it's better than not working at all.
Ultimately, I need a gguf. As long as the gguf works, I can use unsloth inference or some other method for inference during the testing phase before packaging it as a gguf. Speed doesn't matter.
That's a great idea! Worth trying.
However, I'm going to bed now. I'll wake up in a few hours and try it out.
I'll leave a comment if I get any news.
At the very least, it's a viable alternative.
Thank you, you seem to be an experienced engineer!
Hello. I have the same error but im using Qwen2.5 vl 7b and i dont want to change my model. I tried to run a notebook that some weeks ago was executed correclty and now i have this error.
Hi, I still face this issue with Qwen 2 VL every versions. I want to stick to this model for evaluation. Is there a workaround apart from changing the model ?
Heyy @Deng-Xian-Sheng , unsloth_compiled_module_qwen2_vl.py file you are looking for is inside unsloth_compiled_cache folder in the working directory. I tried updating the code, but still its not useful.
Hi @andreasspap, Were you able to find any solutions ?
Hi @unslothai, Please fix this issue.
It seems the qwen3-vl series already includes all model sizes from the qwen2.5-vl series. I haven't looked into it closely, but models of various sizes are available.
If you must use qwen2.5-vl for some other reason, you may need to investigate further.
For Colab, Kaggle, please disconnect and delete runtime and try again. For local installs, please update Unsloth via pip install --upgrade --no-cache-dir --no-deps --force-reinstall unsloth unsloth_zoo
Fixed! The fused lm_head rewrite only emits the slice_indices indexing when the model's forward actually defines it, which Qwen2-VL's doesn't.
Please update Unsloth: uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir (if it's not in the current release yet it'll be in the next one). Reopen if it still happens!
Activity
[-][Bug] Please fill in your issue title here.[/-][+][Bug] NameError: name 'slice_indices' is not defined - qwen 2 kaggle.[/+]codejoetheduke commentedon Oct 14, 2025
Same here also got this problem:
bao231 commentedon Oct 21, 2025
bao231 commentedon Oct 21, 2025
same problem
codejoetheduke commentedon Oct 21, 2025
I think you should use Qwen3, there's a notebook provided by Unsloth. I stopped getting those errors after using that notebook
Deng-Xian-Sheng commentedon Oct 21, 2025
Same error
codejoetheduke commentedon Oct 21, 2025
Yes might be.
codejoetheduke commentedon Oct 21, 2025
Did you use Qwen3?
Deng-Xian-Sheng commentedon Oct 21, 2025
I tried some methods, but it doesn't work
unsloth_compiled_module_qwen2_vl.py
I don't know where this file is located, and I'm guessing it's rewritten each time the library is loaded.
So I can't modify it to achieve my goal.
Where is its source file? What generates it?
Deng-Xian-Sheng commentedon Oct 21, 2025
If you can modify the code of this file, you may be able to solve the problem
codejoetheduke commentedon Oct 21, 2025
https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_VL_(8B)-Vision.ipynb
Try this
Deng-Xian-Sheng commentedon Oct 21, 2025
Additionally, it's worth clarifying the differences between the Qwen2, Qwen2.5, and Qwen3 models and their corresponding ipynb files.
I compared the two files and found no difference, aside from the library version.
transformers
Deng-Xian-Sheng commentedon Oct 21, 2025
I suspect this is related to the model. Different models use different files in the unsloth_compiled_cache, which can sometimes cause errors and sometimes not.
Thus, the ultimate cause of the problem may lie with the files in the unsloth_compiled_cache, rather than the model.
codejoetheduke commentedon Oct 21, 2025
So use Qwen3 to avoid all those errors. Let's hope unsloth fixes that error in the previous versions
3 remaining items
codejoetheduke commentedon Oct 21, 2025
Relax, try a smaller model then. Maybe not the 8B model. I was also try to rack my brain around it but couldn't find an answer
codejoetheduke commentedon Oct 21, 2025
Oh I see, is it for an edge device? Because it is fine if not. You can use a smaller Qwen3 model. Before that, have you saved the weights of the Qwen2.5vl model? You can run it without unsloth if you think that will solve your problem.
Deng-Xian-Sheng commentedon Oct 21, 2025
Wow, you are a genius!
codejoetheduke commentedon Oct 21, 2025
I am glad that helped!
Deng-Xian-Sheng commentedon Oct 21, 2025
I tried training, and it seems to work fine.
So, I can try saving the weights. If that works, I can save them first and then use some other inference method!
I'm not sure about compatibility; it's said to be slow, but it's better than not working at all.
Ultimately, I need a gguf. As long as the gguf works, I can use unsloth inference or some other method for inference during the testing phase before packaging it as a gguf. Speed doesn't matter.
That's a great idea! Worth trying.
However, I'm going to bed now. I'll wake up in a few hours and try it out.
I'll leave a comment if I get any news.
At the very least, it's a viable alternative.
Thank you, you seem to be an experienced engineer!
codejoetheduke commentedon Oct 21, 2025
You are welcome! Good night then
andreasspap commentedon Oct 23, 2025
Hello. I have the same error but im using Qwen2.5 vl 7b and i dont want to change my model. I tried to run a notebook that some weeks ago was executed correclty and now i have this error.
rahulismyname commentedon Nov 3, 2025
Hi, I still face this issue with Qwen 2 VL every versions. I want to stick to this model for evaluation. Is there a workaround apart from changing the model ?
Heyy @Deng-Xian-Sheng , unsloth_compiled_module_qwen2_vl.py file you are looking for is inside unsloth_compiled_cache folder in the working directory. I tried updating the code, but still its not useful.
Hi @andreasspap, Were you able to find any solutions ?
Hi @unslothai, Please fix this issue.
Deng-Xian-Sheng commentedon Nov 3, 2025
qwen3-vl-2B has been released: https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct. I haven't had time to test the "using alternative reasoning methods" approach due to some work commitments.
You can try it if you have time.
Updating the code in that folder is ineffective, likely because the library overwrites those files every time it runs.
Unless you can find the source files.
Deng-Xian-Sheng commentedon Nov 3, 2025
It seems the qwen3-vl series already includes all model sizes from the qwen2.5-vl series. I haven't looked into it closely, but models of various sizes are available.
If you must use qwen2.5-vl for some other reason, you may need to investigate further.
Deng-Xian-Sheng commentedon Nov 3, 2025
https://huggingface.co/collections/Qwen/qwen3-vl
It has an 8B model, which is likely close to the 7B you're using.
Alternatively, you could use the slightly smaller 4B.
For benchmarking purposes, you could use a library like vllm for inference.
danielhanchen commentedon Nov 3, 2025
Extreme apologies on the delay @bao231 @rahulismyname @Deng-Xian-Sheng @ProBuro @codejoetheduke - we just fixed Qwen 2 VL - so sorry again!
For Colab, Kaggle, please disconnect and delete runtime and try again. For local installs, please update Unsloth via
pip install --upgrade --no-cache-dir --no-deps --force-reinstall unsloth unsloth_zoodanielhanchen commentedon Sep 9, 2026
Fixed! The fused lm_head rewrite only emits the slice_indices indexing when the model's forward actually defines it, which Qwen2-VL's doesn't.
Please update Unsloth:
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir(if it's not in the current release yet it'll be in the next one). Reopen if it still happens!