Repository navigation
Closed
Description
from unsloth import FastLanguageModel
import torch
max_seq_length = 1024 # Can increase for longer reasoning traces
lora_rank = 32 # Larger rank = smarter, but slower
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "meta-llama/meta-Llama-3.1-8B-Instruct",
max_seq_length = max_seq_length,
load_in_4bit = True, # False for LoRA 16bit
fast_inference = True, # Enable vLLM fast inference
max_lora_rank = lora_rank,
gpu_memory_utilization = 0.6, # Reduce if out of memory
)
This gives the following error:
cju@linux-ml:~/aigc/unsloth$ cd /home/cju/aigc/unsloth ; /usr/bin/env /home/cju/aigc/unsloth/.venv/bin/python /home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 51581 -- /home/cju/aigc/unsloth/cju_grpo.py
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
INFO 03-11 18:44:43 __init__.py:207] Automatically detected platform cuda.
==((====))== Unsloth 2025.3.8: Fast Llama patching. Transformers: 4.49.0. vLLM: 0.7.3.
\\ /| NVIDIA GeForce RTX 4090. Num GPUs = 1. Max memory: 23.527 GB. Platform: Linux.
O^O/ \_/ \ Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0
\ / Bfloat16 = TRUE. FA [Xformers = 0.0.28.post3. FA2 = False]
"-____-" Free license: http://github.com/unslothai/unsloth
Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
Unsloth: vLLM loading unsloth/meta-llama-3.1-8b-instruct-unsloth-bnb-4bit with actual GPU utilization = 57.88%
Unsloth: Your GPU has CUDA compute capability 8.9 with VRAM = 23.53 GB.
Unsloth: Using conservativeness = 1.0. Chunked prefill tokens = 1024. Num Sequences = 192.
Unsloth: vLLM's KV Cache can use up to 7.44 GB. Also swap space = 1 GB.
INFO 03-11 18:45:25 config.py:549] This model supports multiple tasks: {'embed', 'generate', 'score', 'classify', 'reward'}. Defaulting to 'generate'.
INFO 03-11 18:45:26 config.py:1555] Chunked prefill is enabled with max_num_batched_tokens=1024.
WARNING 03-11 18:45:26 config.py:2224] LoRA with chunked prefill is still experimental and may be unstable.
Unsloth: vLLM Bitsandbytes config using kwargs = {'load_in_8bit': False, 'load_in_4bit': True, 'bnb_4bit_compute_dtype': 'bfloat16', 'bnb_4bit_quant_storage': 'uint8', 'bnb_4bit_quant_type': 'nf4', 'bnb_4bit_use_double_quant': True, 'llm_int8_enable_fp32_cpu_offload': False, 'llm_int8_has_fp16_weight': False, 'llm_int8_skip_modules': ['lm_head', 'multi_modal_projector', 'merger', 'modality_projection', 'model.layers.1.mlp'], 'llm_int8_threshold': 6.0}
WARNING 03-11 18:45:27 utils.py:2128] CUDA was previously initialized. We must use the `spawn` multiprocessing start method. Setting VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. See https://docs.vllm.ai/en/latest/getting_started/troubleshooting.html#python-multiprocessing for more information.
Traceback (most recent call last):
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/unsloth_zoo/vllm_utils.py", line 998, in load_vllm
llm = LLM(**engine_args)
^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/utils.py", line 1022, in inner
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/entrypoints/llm.py", line 242, in __init__
self.llm_engine = self.engine_class.from_engine_args(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 98, in from_engine_args
return cls(vllm_config=vllm_config,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 71, in __init__
self.engine_core = EngineCoreClient.make_client(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 64, in make_client
return SyncMPClient(vllm_config, executor_class, log_stats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 256, in __init__
super().__init__(
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 220, in __init__
self.proc_handle = BackgroundProcHandle(
^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/vllm/v1/utils.py", line 118, in __init__
self.proc.start()
File "/usr/lib/python3.12/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/context.py", line 289, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/usr/lib/python3.12/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/usr/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 47, in _launch
reduction.dump(process_obj, fp)
File "/usr/lib/python3.12/multiprocessing/reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't get local object 'patch_vllm_compute_dtype.<locals>.BitsAndBytesConfig'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.12/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
cli.main()
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
run()
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
runpy.run_path(target, run_name="__main__")
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
File "/home/cju/.vscode-server/extensions/ms-python.debugpy-2025.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
File "/home/cju/aigc/unsloth/cju_grpo.py", line 10, in <module>
model, tokenizer = FastLanguageModel.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/unsloth/models/loader.py", line 308, in from_pretrained
model, tokenizer = dispatch_model.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/unsloth/models/llama.py", line 1805, in from_pretrained
llm = load_vllm(**load_vllm_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cju/aigc/unsloth/.venv/lib/python3.12/site-packages/unsloth_zoo/vllm_utils.py", line 1020, in load_vllm
raise RuntimeError(error)
RuntimeError: Can't get local object 'patch_vllm_compute_dtype.<locals>.BitsAndBytesConfig'
Metadata
Metadata
Assignees
Labels
No labels
Activity
Dielianss commentedon Mar 27, 2025
Try disable VLLM V1 Core by unset VLLM_USE_V1=1
CharlesJu1 commentedon Apr 1, 2025
Disable VLLM V1 Core works.
Taimin commentedon Apr 22, 2025
I encountered the same problem and I tried to disable VLLM v1 core by
import os os.environ["VLLM_USE_V1"] = "0".But this is unsuccessful because new error will pop up:
RuntimeError: Using V1 LLMEngine, but envs.VLLM_USE_V1=False. This should not happen. As a workaround, try using LLMEngine.from_vllm_config(...) or explicitly set VLLM_USE_V1=0 or 1 and report this issue on Github.How did you disable the VLLM v1 core?
Taimin commentedon Apr 22, 2025
Now it is fine. I restart the jupyter lab and use
import os os.environ["VLLM_USE_V1"] = "0"and the error disappeared.R-3566 commentedon May 13, 2025
I encountered a similar problem.How can I fix it
mmathew23 commentedon May 13, 2025
Did you try
before importing unsloth?
danielhanchen commentedon Jul 14, 2026
This should be fixed now - sorry on the delay - please update with
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir- if it's not fixed yet, it'll be in the next pip / PyPI release - if it's still not working after that, please open another issue - appreciate it again!The patched BitsAndBytesConfig is now module-level, so spawn/pickle of the vLLM worker no longer fails.