Skip to content

[Bug] AttributeError: 'NoneType' object has no attribute 'absmax' when training llama-3.1-8b with GRPOTrainer #2910

Closed

Description

@simonusher
  1. Did you update? pip install --upgrade unsloth unsloth_zoo yes
  2. Colab or Kaggle or local / cloud cloud
  3. Number GPUs used, use nvidia-smi 1
  4. Which notebook? Please link! based on LLama 3.1 GRPO
  5. Which Unsloth version, TRL version, transformers version, PyTorch version?
    unsloth: 2025.7.1
    unsloth_zoo: 2025.7.1
    trl: 0.19.1
    triton: 3.3.0
    transformers: 4.53.1
    torch: 2.7.0
  6. Which trainer? SFTTrainer, GRPOTrainer etc GRPOTrainer

I'm facing the error as in the title when trying to fine tune llama-3.1 with GRPO based on one of the notebooks.
Trace:

[rank0]: Traceback (most recent call last):
[rank0]:   File "/workspace/data-science/ble.py", line 100, in <module>
[rank0]:     run()
[rank0]:   File "/workspace/data-science/ble.py", line 87, in run
[rank0]:     trainer.train(resume_from_checkpoint=False)
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/transformers/trainer.py", line 2206, in train
[rank0]:     return inner_training_loop(
[rank0]:            ^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "<string>", line 320, in _fast_inner_training_loop
[rank0]:   File "<string>", line 34, in _unsloth_training_step
[rank0]:   File "/workspace/data-science/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 2040, in compute_loss
[rank0]:     loss, completion_length, mean_kl = grpo_accumulated_loss(
[rank0]:                                        ^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 313, in grpo_accumulated_loss
[rank0]:     ref_hidden_states = trainer.model(
[rank0]:                         ^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
[rank0]:     return self._call_impl(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
[rank0]:     return forward_call(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/models/llama.py", line 1292, in PeftModel_fast_forward
[rank0]:     return self.base_model(
[rank0]:            ^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
[rank0]:     return self._call_impl(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
[rank0]:     return forward_call(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/peft/tuners/tuners_utils.py", line 216, in forward
[rank0]:     return self.model.forward(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/models/llama.py", line 1115, in _CausalLM_fast_forward
[rank0]:     outputs = self.model(
[rank0]:               ^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
[rank0]:     return self._call_impl(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
[rank0]:     return forward_call(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/models/llama.py", line 931, in LlamaModel_fast_forward
[rank0]:     layer_outputs = decoder_layer(
[rank0]:                     ^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/transformers/modeling_layers.py", line 82, in __call__
[rank0]:     return self._gradient_checkpointing_func(partial(super().__call__, **kwargs), *args)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/_compile.py", line 51, in inner
[rank0]:     return disable_fn(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 838, in _fn
[rank0]:     return fn(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/utils/checkpoint.py", line 488, in checkpoint
[rank0]:     return CheckpointFunction.apply(function, preserve, *args)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/autograd/function.py", line 575, in apply
[rank0]:     return super().apply(*args, **kwargs)  # type: ignore[misc]
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth_zoo/gradient_checkpointing.py", line 475, in forward
[rank0]:     outputs = run_function(*args)
[rank0]:               ^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
[rank0]:     return self._call_impl(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
[rank0]:     return forward_call(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/models/llama.py", line 604, in LlamaDecoderLayer_fast_forward
[rank0]:     hidden_states, self_attn_weights, present_key_value = self.self_attn(
[rank0]:                                                           ^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
[rank0]:     return self._call_impl(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
[rank0]:     return forward_call(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/models/llama.py", line 458, in LlamaAttention_fast_forward
[rank0]:     Q, K, V = self.apply_qkv(self, hidden_states)
[rank0]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/kernels/fast_lora.py", line 366, in apply_lora_qkv
[rank0]:     Q, K, V = LoRA_QKV.apply(X,
[rank0]:               ^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/autograd/function.py", line 575, in apply
[rank0]:     return super().apply(*args, **kwargs)  # type: ignore[misc]
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/amp/autocast_mode.py", line 510, in decorate_fwd
[rank0]:     return fwd(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/kernels/fast_lora.py", line 259, in forward
[rank0]:     Q = matmul_lora(X, QW, QW_quant, QA, QB, QS)
[rank0]:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/kernels/utils.py", line 693, in matmul_lora
[rank0]:     W = fast_dequantize(W.t(), W_quant, use_global_buffer = True)
[rank0]:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
[rank0]:     return func(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/workspace/data-science/env/lib/python3.12/site-packages/unsloth/kernels/utils.py", line 321, in fast_dequantize
[rank0]:     absmax2    = state2.absmax
[rank0]:                  ^^^^^^^^^^^^^
[rank0]: AttributeError: 'NoneType' object has no attribute 'absmax'

Full pip freeze output:

accelerate==1.8.1
aiohappyeyeballs==2.6.1
aiohttp==3.12.13
aiosignal==1.4.0
airportsdata==20250706
annotated-types==0.7.0
anyio==4.9.0
astor==0.8.1
attrs==25.3.0
bitsandbytes==0.46.1
blake3==1.0.5
cachetools==6.1.0
certifi==2025.7.9
charset-normalizer==3.4.2
click==8.2.1
cloudpickle==3.1.1
compressed-tensors==0.10.2
cupy-cuda12x==13.4.1
cut-cross-entropy==25.1.1
datasets==4.0.0
depyf==0.18.0
diffusers==0.34.0
dill==0.3.8
diskcache==5.6.3
distro==1.9.0
dnspython==2.7.0
docstring_parser==0.16
einops==0.8.1
email_validator==2.2.0
fastapi==0.116.0
fastapi-cli==0.0.8
fastapi-cloud-cli==0.1.2
fastrlock==0.8.3
filelock==3.18.0
frozenlist==1.7.0
fsspec==2025.3.0
gguf==0.17.1
h11==0.16.0
hf-xet==1.1.5
hf_transfer==0.1.9
httpcore==1.0.9
httptools==0.6.4
httpx==0.28.1
huggingface-hub==0.33.2
idna==3.10
importlib_metadata==8.7.0
interegular==0.3.3
Jinja2==3.1.6
jiter==0.10.0
jsonschema==4.24.0
jsonschema-specifications==2025.4.1
lark==1.2.2
llguidance==0.7.30
llvmlite==0.44.0
lm-format-enforcer==0.10.11
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
mistral_common==1.7.0
mpmath==1.3.0
msgpack==1.1.1
msgspec==0.19.0
multidict==6.6.3
multiprocess==0.70.16
nest-asyncio==1.6.0
networkx==3.5
ninja==1.11.1.4
numba==0.61.2
numpy==2.2.6
nvidia-cublas-cu12==12.6.4.1
nvidia-cuda-cupti-cu12==12.6.80
nvidia-cuda-nvrtc-cu12==12.6.77
nvidia-cuda-runtime-cu12==12.6.77
nvidia-cudnn-cu12==9.5.1.17
nvidia-cufft-cu12==11.3.0.4
nvidia-cufile-cu12==1.11.1.6
nvidia-curand-cu12==10.3.7.77
nvidia-cusolver-cu12==11.7.1.2
nvidia-cusparse-cu12==12.5.4.2
nvidia-cusparselt-cu12==0.6.3
nvidia-nccl-cu12==2.26.2
nvidia-nvjitlink-cu12==12.6.85
nvidia-nvtx-cu12==12.6.77
openai==1.90.0
opencv-python-headless==4.12.0.88
outlines==0.1.11
outlines_core==0.1.26
packaging==25.0
pandas==2.3.1
partial-json-parser==0.2.1.1.post6
peft==0.16.0
pillow==11.3.0
prometheus-fastapi-instrumentator==7.1.0
prometheus_client==0.22.1
propcache==0.3.2
protobuf==3.20.3
psutil==7.0.0
py-cpuinfo==9.0.0
pyarrow==20.0.0
pybase64==1.4.1
pycountry==24.6.1
pydantic==2.11.7
pydantic_core==2.33.2
Pygments==2.19.2
python-dateutil==2.9.0.post0
python-dotenv==1.1.1
python-json-logger==3.3.0
python-multipart==0.0.20
pytz==2025.2
PyYAML==6.0.2
pyzmq==27.0.0
ray==2.47.1
referencing==0.36.2
regex==2024.11.6
requests==2.32.4
rich==14.0.0
rich-toolkit==0.14.8
rignore==0.5.1
rpds-py==0.26.0
safetensors==0.5.3
scipy==1.16.0
sentencepiece==0.2.0
sentry-sdk==2.32.0
setuptools==79.0.1
shellingham==1.5.4
shtab==1.7.2
six==1.17.0
sniffio==1.3.1
starlette==0.46.2
sympy==1.14.0
tiktoken==0.9.0
tokenizers==0.21.2
torch==2.7.0
torchaudio==2.7.0
torchvision==0.22.0
tqdm==4.67.1
transformers==4.53.1
triton==3.3.0
trl==0.19.1
typeguard==4.4.4
typer==0.16.0
typing-inspection==0.4.1
typing_extensions==4.14.1
tyro==0.9.26
tzdata==2025.2
unsloth==2025.7.1
unsloth_zoo==2025.7.1
urllib3==2.5.0
uvicorn==0.35.0
uvloop==0.21.0
vllm==0.9.2
watchfiles==1.1.0
websockets==15.0.1
wheel==0.45.1
xformers==0.0.30
xgrammar==0.1.19
xxhash==3.5.0
yarl==1.20.1
zipp==3.23.0

nvcc --version - happened on multiple different ones 12.4, 12.6

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Fri_Feb_21_20:23:50_PST_2025
Cuda compilation tools, release 12.8, V12.8.93
Build cuda_12.8.r12.8/compiler.35583870_0
from unsloth import FastLanguageModel, is_bfloat16_supported
from datetime import datetime
import datasets
import random

max_seq_length = 9_000 # Can increase for longer reasoning traces
lora_rank = 64 # Larger rank = smarter, but slower

RANDOM_SEED = 1337

CURRENT_TIME = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

def format_prompt(n):
    return {
        "prompt": [
            {"role": "system", "content": "Write N words on any topic."},
            {"role": "user", "content": f"N: {n}"}
        ]    
    }

dataset_formatted = datasets.Dataset.from_list([format_prompt(random.randint(100, 200)) for _ in range(1000)])

def run():
    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.7, # Reduce if out of memory
    )

    model = FastLanguageModel.get_peft_model(
        model,
        r = lora_rank, # Choose any number > 0 ! Suggested 8, 16, 32, 64, 128
        target_modules = [
            "q_proj", "k_proj", "v_proj", "o_proj",
            "gate_proj", "up_proj", "down_proj",
        ], # Remove QKVO if out of memory
        lora_alpha = lora_rank,
        use_gradient_checkpointing = "unsloth", # Enable long context finetuning
        random_state = 3407,
    )

    def foo_reward_func(prompts, completions, **kwargs) -> list[float]:
        return [1.0] * len(completions)


    from trl import GRPOConfig, GRPOTrainer
    training_args = GRPOConfig(
        use_vllm = True, # use vLLM for fast inference!
        learning_rate = 5e-6,
        adam_beta1 = 0.9,
        adam_beta2 = 0.99,
        weight_decay = 0.1,
        warmup_ratio = 0.1,
        lr_scheduler_type = "cosine",
        optim = "paged_adamw_8bit",
        logging_steps = 1,
        bf16 = is_bfloat16_supported(),
        fp16 = not is_bfloat16_supported(),
        per_device_train_batch_size = 6,
        gradient_accumulation_steps = 6, # Increase to 4 for smoother training
        num_generations = 6, # Decrease if out of memory
        max_prompt_length = 4024,
        max_completion_length = 4024,
        # num_train_epochs = 1, # Set to 1 for a full training run
        max_steps = 1000,
        save_steps = 100,
        max_grad_norm = 0.1,
        output_dir = f"outputs_foo_model",
        report_to="none",
        temperature = 0.8,
    )

    try:
        trainer = GRPOTrainer(
            model = model,
            processing_class = tokenizer,
            reward_funcs = [
                foo_reward_func,
            ],
            args = training_args,
            train_dataset = dataset_formatted,
        )
        trainer.train(resume_from_checkpoint=False)
    except KeyboardInterrupt:
        print("Exiting gracefully!")

    MODEL_OUTPUT_DIR = f"foo_model_16b_{CURRENT_TIME}"

    model.save_pretrained_merged(
        MODEL_OUTPUT_DIR,
        tokenizer,
        save_method="merged_16bit",
    )

if __name__ == "__main__":
    run()

🦥 You can also ask via our Reddit page: https://www.reddit.com/r/unsloth/

Activity

  1. behroozazarkhalili commented on Jul 10, 2025

    @behroozazarkhalili

    I have the same issue with Qwen2.5-0.5B-Instruct.

  2. darshanmakwana412 commented on Jul 10, 2025

    @darshanmakwana412

    I am getting a similar error for Qwen/Qwen2.5-7B-Instruct

  3. rolandtannous commented on Jul 10, 2025

    @rolandtannous
    Contributor

    @behroozazarkhalili @darshanmakwana412 @simonusher

    we just made a new release that should solve this problem for you.
    If you're running the code on a local vm, make sure to upgrade your install of unsloth via

    pip install --force-reinstall --upgrade unsloth-zoo
    pip install --force-reinstall --upgrade unsloth
    

    On the other hand, If you're running the notebooks on colab no need to do introduce any changes to the install cells as the notebook will grab the newest version from pypi for you anyway.

    Make sure to leave a comment if this doesn't work out for you with the necessary details and code snippets that would allow us to reproduce the errors you're observing and we'll take it from there.

  4. behroozazarkhalili commented on Jul 10, 2025

    @behroozazarkhalili

    @simonusher, has the issue been resolved?

  5. simonusher commented on Jul 10, 2025

    @simonusher
    Author

    Hi! Thanks a lot for responding and for the release. I'm testing it out atm. I'm not sure I was able to get the most similar env I could to the one I got yesterday. Anyway I see a different error now:

    [rank0]:   File "/workspace/foo.py", line 99, in <module>
    [rank0]:     run()
    [rank0]:   File "/workspace/foo.py", line 86, in run
    [rank0]:     trainer.train(resume_from_checkpoint=False)
    [rank0]:   File "/workspace/env/lib/python3.12/site-packages/transformers/trainer.py", line 2206, in train
    [rank0]:     return inner_training_loop(
    [rank0]:            ^^^^^^^^^^^^^^^^^^^^
    [rank0]:   File "<string>", line 323, in _fast_inner_training_loop
    [rank0]:   File "<string>", line 34, in _unsloth_training_step
    [rank0]:   File "/workspace/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 1990, in compute_loss
    [rank0]:     per_token_logps = get_logps_func(model, input_ids, attention_mask, logits_to_keep)
    [rank0]:                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [rank0]:   File "/workspace/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 1988, in <lambda>
    [rank0]:     get_logps_func = lambda model, input_ids, attention_mask, logits_to_keep, batch_size=None, compute_entropy=False: self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep, batch_size) if hasattr(self, "_get_per_token_logps") else self._get_per_token_logps_and_entropies(model, input_ids, attention_mask, logits_to_keep, batch_size, compute_entropy)['logps']
    [rank0]:                                                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [rank0]: TypeError: _UnslothGRPOTrainer._get_per_token_logps() takes 5 positional arguments but 6 were given
      0%|                                                                                             | 0/1000 [00:28<?, ?it/s]
    [rank0]:[W710 16:58:46.254987943 ProcessGroupNCCL.cpp:1476] Warning: WARNING: destroy_process_group() was not called before program exit, which can leak resources. For more info, please see https://pytorch.org/docs/stable/distributed.html#shutdown (function operator())
    
  6. behroozazarkhalili commented on Jul 10, 2025

    @behroozazarkhalili

    Hi! Thanks a lot for responding and for the release. I'm testing it out atm. I'm not sure I was able to get the most similar env I could to the one I got yesterday. Anyway I see a different error now:

    [rank0]:   File "/workspace/foo.py", line 99, in <module>
    [rank0]:     run()
    [rank0]:   File "/workspace/foo.py", line 86, in run
    [rank0]:     trainer.train(resume_from_checkpoint=False)
    [rank0]:   File "/workspace/env/lib/python3.12/site-packages/transformers/trainer.py", line 2206, in train
    [rank0]:     return inner_training_loop(
    [rank0]:            ^^^^^^^^^^^^^^^^^^^^
    [rank0]:   File "<string>", line 323, in _fast_inner_training_loop
    [rank0]:   File "<string>", line 34, in _unsloth_training_step
    [rank0]:   File "/workspace/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 1990, in compute_loss
    [rank0]:     per_token_logps = get_logps_func(model, input_ids, attention_mask, logits_to_keep)
    [rank0]:                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [rank0]:   File "/workspace/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 1988, in <lambda>
    [rank0]:     get_logps_func = lambda model, input_ids, attention_mask, logits_to_keep, batch_size=None, compute_entropy=False: self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep, batch_size) if hasattr(self, "_get_per_token_logps") else self._get_per_token_logps_and_entropies(model, input_ids, attention_mask, logits_to_keep, batch_size, compute_entropy)['logps']
    [rank0]:                                                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [rank0]: TypeError: _UnslothGRPOTrainer._get_per_token_logps() takes 5 positional arguments but 6 were given
      0%|                                                                                             | 0/1000 [00:28<?, ?it/s]
    [rank0]:[W710 16:58:46.254987943 ProcessGroupNCCL.cpp:1476] Warning: WARNING: destroy_process_group() was not called before program exit, which can leak resources. For more info, please see https://pytorch.org/docs/stable/distributed.html#shutdown (function operator())
    

    You finally reached out to me. 👍 see #2916

  7. rolandtannous commented on Jul 10, 2025

    @rolandtannous
    Contributor

    @behroozazarkhalili @simonusher

    was able to reproduce the same error you are getting.
    We'll work on fixing it. Thank you for your patience

  8. behroozazarkhalili commented on Jul 11, 2025

    @behroozazarkhalili

    @rolandtannous It is still present, even after updating to the merged version. It should be related to bitsandbytes quantization, as mentioned in #863.

    Environment

    • Unsloth version: 2025.7.3
    • unsloth_zoo version: 2025.7.4
    • TRL version: 0.19.1
    • Transformers version: 4.53.1
    • PyTorch version: 2.7.1
    • bitsandbytes version: 0.46.1
    • peft: 0.16.0
    • Python version: 3.11
    • Operating System: Linux
    • GPU: CUDA-enabled
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    Cell In[6], line 1
    ----> 1 trainer.train()
    
    File ~/GRPO-Unsloth-Finetuning/GRPO-Qwen-Finetuning-Unsloth/grpo_qwen.py:399, in GRPOModelTrainer.train(self)
        385         trainer = GRPOTrainer(
        386                     model=self.model,
        387                     processing_class=self.tokenizer,
       (...)    396             train_dataset=dataset,
        397 )
        398         logger.info("Beginning GRPO training...")
    --> 399         trainer.train()
        400         logger.info("Training completed!")
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/transformers/trainer.py:2206, in Trainer.train(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)
       2204         hf_hub_utils.enable_progress_bars()
       2205 else:
    -> 2206     return inner_training_loop(
       2207         args=args,
       2208         resume_from_checkpoint=resume_from_checkpoint,
       2209         trial=trial,
       2210         ignore_keys_for_eval=ignore_keys_for_eval,
       2211     )
    
    File <string>:323, in _fast_inner_training_loop(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)
    
    File <string>:34, in _unsloth_training_step(self, model, inputs, num_items_in_batch)
    
    File ~/GRPO-Unsloth-Finetuning/GRPO-Qwen-Finetuning-Unsloth/unsloth_compiled_cache/UnslothGRPOTrainer.py:2046, in _UnslothGRPOTrainer.compute_loss(self, model, inputs, return_outputs, num_items_in_batch)
       2044 else:
       2045     if hasattr(self.args, "loss_type"):
    -> 2046         loss, completion_length, mean_kl = grpo_accumulated_loss(
       2047             trainer = self,
       2048             input_ids = _input_ids,
       2049             logits_to_keep = logits_to_keep,
       2050             completion_mask = completion_mask,
       2051             advantages = advantages,
       2052             old_hidden_states = old_hidden_states,
       2053             n_chunks = self.args.unsloth_num_chunks,
       2054             loss_type = self.args.loss_type,
       2055             epsilon_low = self.epsilon_low,
       2056             epsilon_high = self.epsilon_high,
       2057             max_completion_length = self.args.max_completion_length,
       2058             delta = self.args.delta,
       2059             temperature = self.args.temperature,
       2060             logit_softcapping = logit_softcapping,
       2061             logit_scale_multiply = logit_scale_multiply,
       2062             logit_scale_divide = logit_scale_divide,
       2063             attention_mask = attention_mask,
       2064         )
       2065     else:
       2066         # to ensure backwards compatibility with trl 0.15.2 and maybe even 0.17
       2067         loss, completion_length, mean_kl = grpo_accumulated_loss(
       2068             trainer = self,
       2069             input_ids = _input_ids,
       (...)   2079             attention_mask = attention_mask,
       2080         )
    
    File ~/GRPO-Unsloth-Finetuning/GRPO-Qwen-Finetuning-Unsloth/unsloth_compiled_cache/UnslothGRPOTrainer.py:313, in grpo_accumulated_loss(trainer, input_ids, attention_mask, logits_to_keep, completion_mask, advantages, old_hidden_states, n_chunks, **kwargs)
        311 with torch.amp.autocast(device_type = trainer.model.device.type, dtype = trainer._autocast_dtype):
        312     with torch.inference_mode(), trainer.accelerator.unwrap_model(trainer.model, keep_fp32_wrapper = False).disable_adapter():
    --> 313         ref_hidden_states = trainer.model(
        314             input_ids = input_ids,
        315             attention_mask = attention_mask,
        316             logits_to_keep = logits_to_keep + 1,
        317         ).logits
        318     pass
        319     new_hidden_states = trainer.model(
        320         input_ids = input_ids,
        321         attention_mask = attention_mask,
        322         logits_to_keep = logits_to_keep + 1,
        323     ).logits
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1751, in Module._wrapped_call_impl(self, *args, **kwargs)
       1749     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
       1750 else:
    -> 1751     return self._call_impl(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1762, in Module._call_impl(self, *args, **kwargs)
       1757 # If we don't have any hooks, we want to skip the rest of the logic in
       1758 # this function, and just call forward.
       1759 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
       1760         or _global_backward_pre_hooks or _global_backward_hooks
       1761         or _global_forward_hooks or _global_forward_pre_hooks):
    -> 1762     return forward_call(*args, **kwargs)
       1764 result = None
       1765 called_always_called_hooks = set()
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:1316, in PeftModel_fast_forward(self, input_ids, causal_mask, attention_mask, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict, task_ids, num_logits_to_keep, logits_to_keep, **kwargs)
       1305     return self.base_model(
       1306         input_ids = input_ids,
       1307         attention_mask = attention_mask,
       (...)   1313         **kwargs,
       1314     )
       1315 else:
    -> 1316     return self.base_model(
       1317         input_ids = input_ids,
       1318         causal_mask = causal_mask,
       1319         attention_mask = attention_mask,
       1320         inputs_embeds = inputs_embeds,
       1321         labels = labels,
       1322         output_attentions = output_attentions,
       1323         output_hidden_states = output_hidden_states,
       1324         return_dict = return_dict,
       1325         num_logits_to_keep = num_logits_to_keep,
       1326         logits_to_keep = logits_to_keep,
       1327         **kwargs,
       1328     )
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1751, in Module._wrapped_call_impl(self, *args, **kwargs)
       1749     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
       1750 else:
    -> 1751     return self._call_impl(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1762, in Module._call_impl(self, *args, **kwargs)
       1757 # If we don't have any hooks, we want to skip the rest of the logic in
       1758 # this function, and just call forward.
       1759 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
       1760         or _global_backward_pre_hooks or _global_backward_hooks
       1761         or _global_forward_hooks or _global_forward_pre_hooks):
    -> 1762     return forward_call(*args, **kwargs)
       1764 result = None
       1765 called_always_called_hooks = set()
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/peft/tuners/tuners_utils.py:216, in BaseTuner.forward(self, *args, **kwargs)
        215 def forward(self, *args: Any, **kwargs: Any):
    --> 216     return self.model.forward(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:1140, in CausalLM_fast_forward.<locals>._CausalLM_fast_forward(self, input_ids, causal_mask, attention_mask, position_ids, past_key_values, inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict, num_logits_to_keep, logits_to_keep, *args, **kwargs)
       1138     # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
       1139     self.model._has_no_labels = labels is None
    -> 1140     outputs = self.model(
       1141         input_ids = input_ids,
       1142         causal_mask = causal_mask,
       1143         attention_mask = attention_mask,
       1144         position_ids = position_ids,
       1145         past_key_values = past_key_values,
       1146         inputs_embeds = inputs_embeds,
       1147         use_cache = use_cache,
       1148         output_attentions = output_attentions,
       1149         output_hidden_states = output_hidden_states,
       1150         return_dict = return_dict,
       1151     )
       1152 pass
       1153 hidden_states = outputs[0]
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1751, in Module._wrapped_call_impl(self, *args, **kwargs)
       1749     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
       1750 else:
    -> 1751     return self._call_impl(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1762, in Module._call_impl(self, *args, **kwargs)
       1757 # If we don't have any hooks, we want to skip the rest of the logic in
       1758 # this function, and just call forward.
       1759 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
       1760         or _global_backward_pre_hooks or _global_backward_hooks
       1761         or _global_forward_hooks or _global_forward_pre_hooks):
    -> 1762     return forward_call(*args, **kwargs)
       1764 result = None
       1765 called_always_called_hooks = set()
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:952, in LlamaModel_fast_forward(self, input_ids, causal_mask, attention_mask, position_ids, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict, *args, **kwargs)
        949     hidden_states = layer_outputs[0]
        951 else:
    --> 952     layer_outputs = decoder_layer(
        953         hidden_states,
        954         causal_mask=mask,
        955         attention_mask      = attention_mask,
        956         position_ids        = position_ids,
        957         past_key_value      = past_key_value,
        958         output_attentions   = output_attentions,
        959         use_cache           = use_cache,
        960         padding_mask        = padding_mask,
        961         position_embeddings = position_embeddings,
        962     )
        963     hidden_states = layer_outputs[0]
        964 pass
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/transformers/modeling_layers.py:82, in GradientCheckpointingLayer.__call__(self, *args, **kwargs)
         79         message = message.rstrip(",") + "."
         80         logger.warning(message)
    ---> 82     return self._gradient_checkpointing_func(partial(super().__call__, **kwargs), *args)
         83 return super().__call__(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/_compile.py:51, in _disable_dynamo.<locals>.inner(*args, **kwargs)
         48     disable_fn = torch._dynamo.disable(fn, recursive)
         49     fn.__dynamo_disable = disable_fn  # type: ignore[attr-defined]
    ---> 51 return disable_fn(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py:838, in DisableContext.__call__.<locals>._fn(*args, **kwargs)
        836 _maybe_set_eval_frame(_callback_from_stance(self.callback))
        837 try:
    --> 838     return fn(*args, **kwargs)
        839 finally:
        840     set_eval_frame(None)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/utils/checkpoint.py:488, in checkpoint(function, use_reentrant, context_fn, determinism_check, debug, *args, **kwargs)
        483     if context_fn is not noop_context_fn or debug is not False:
        484         raise ValueError(
        485             "Passing `context_fn` or `debug` is only supported when "
        486             "use_reentrant=False."
        487         )
    --> 488     return CheckpointFunction.apply(function, preserve, *args)
        489 else:
        490     gen = _checkpoint_without_reentrant_generator(
        491         function, preserve, context_fn, determinism_check, debug, *args, **kwargs
        492     )
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/autograd/function.py:575, in Function.apply(cls, *args, **kwargs)
        572 if not torch._C._are_functorch_transforms_active():
        573     # See NOTE: [functorch vjp and autograd interaction]
        574     args = _functorch.utils.unwrap_dead_wrappers(args)
    --> 575     return super().apply(*args, **kwargs)  # type: ignore[misc]
        577 if not is_setup_ctx_defined:
        578     raise RuntimeError(
        579         "In order to use an autograd.Function with functorch transforms "
        580         "(vmap, grad, jvp, jacrev, ...), it must override the setup_context "
        581         "staticmethod. For more details, please see "
        582         "https://pytorch.org/docs/main/notes/extending.func.html"
        583     )
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth_zoo/gradient_checkpointing.py:475, in UnslothCheckpointFunction.forward(ctx, run_function, preserve_rng_state, *args)
        472 if ctx._requires_gradient: ctx.save_for_backward(*tensor_inputs)
        474 with torch.no_grad():
    --> 475     outputs = run_function(*args)
        477 if use_gpu_buffer: MAIN_STREAM.wait_stream(EXTRA_STREAM)
        478 return outputs
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1751, in Module._wrapped_call_impl(self, *args, **kwargs)
       1749     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
       1750 else:
    -> 1751     return self._call_impl(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1762, in Module._call_impl(self, *args, **kwargs)
       1757 # If we don't have any hooks, we want to skip the rest of the logic in
       1758 # this function, and just call forward.
       1759 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
       1760         or _global_backward_pre_hooks or _global_backward_hooks
       1761         or _global_forward_hooks or _global_forward_pre_hooks):
    -> 1762     return forward_call(*args, **kwargs)
       1764 result = None
       1765 called_always_called_hooks = set()
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:625, in LlamaDecoderLayer_fast_forward(self, hidden_states, causal_mask, attention_mask, position_ids, past_key_value, output_attentions, use_cache, padding_mask, position_embeddings, *args, **kwargs)
        623 residual = hidden_states
        624 hidden_states = fast_rms_layernorm(self.input_layernorm, hidden_states)
    --> 625 hidden_states, self_attn_weights, present_key_value = self.self_attn(
        626     hidden_states       = hidden_states,
        627     causal_mask         = causal_mask,
        628     attention_mask      = attention_mask,
        629     position_ids        = position_ids,
        630     past_key_value      = past_key_value,
        631     output_attentions   = output_attentions,
        632     use_cache           = use_cache,
        633     padding_mask        = padding_mask,
        634     position_embeddings = position_embeddings,
        635 )
        636 hidden_states = residual + hidden_states
        638 # Fully Connected
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1751, in Module._wrapped_call_impl(self, *args, **kwargs)
       1749     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
       1750 else:
    -> 1751     return self._call_impl(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/nn/modules/module.py:1762, in Module._call_impl(self, *args, **kwargs)
       1757 # If we don't have any hooks, we want to skip the rest of the logic in
       1758 # this function, and just call forward.
       1759 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
       1760         or _global_backward_pre_hooks or _global_backward_hooks
       1761         or _global_forward_hooks or _global_forward_pre_hooks):
    -> 1762     return forward_call(*args, **kwargs)
       1764 result = None
       1765 called_always_called_hooks = set()
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:568, in LlamaAttention_fast_forward(self, hidden_states, causal_mask, attention_mask, position_ids, past_key_value, output_attentions, use_cache, padding_mask, position_embeddings, *args, **kwargs)
        566 pass
        567 attn_output = A.reshape(bsz, q_len, n_heads*head_dim)
    --> 568 attn_output = self.apply_o(self, attn_output)
        569 attn_weights = None
        570 return attn_output, attn_weights, past_key_value
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/kernels/fast_lora.py:457, in apply_lora_o(self, X)
        455 def apply_lora_o(self, X):
        456     OW, OW_quant, OA, OB, OS = get_lora_parameters(self.o_proj)
    --> 457     O = LoRA_W.apply(X, OW, OW_quant, OA, OB, OS)
        458     return O
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/autograd/function.py:575, in Function.apply(cls, *args, **kwargs)
        572 if not torch._C._are_functorch_transforms_active():
        573     # See NOTE: [functorch vjp and autograd interaction]
        574     args = _functorch.utils.unwrap_dead_wrappers(args)
    --> 575     return super().apply(*args, **kwargs)  # type: ignore[misc]
        577 if not is_setup_ctx_defined:
        578     raise RuntimeError(
        579         "In order to use an autograd.Function with functorch transforms "
        580         "(vmap, grad, jvp, jacrev, ...), it must override the setup_context "
        581         "staticmethod. For more details, please see "
        582         "https://pytorch.org/docs/main/notes/extending.func.html"
        583     )
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/amp/autocast_mode.py:510, in custom_fwd.<locals>.decorate_fwd(*args, **kwargs)
        508 if cast_inputs is None:
        509     args[0]._fwd_used_autocast = torch.is_autocast_enabled(device_type)
    --> 510     return fwd(*args, **kwargs)
        511 else:
        512     autocast_context = torch.is_autocast_enabled(device_type)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/kernels/fast_lora.py:408, in LoRA_W.forward(ctx, X, W, W_quant, A, B, S)
        403 @staticmethod
        404 @torch_amp_custom_fwd
        405 def forward(ctx, X : torch.Tensor,
        406             W, W_quant, A, B, S):
        407     dtype = X.dtype
    --> 408     XW = matmul_lora(X, W, W_quant, A, B, S)
        409     ctx.custom_saved_tensors = (W, W_quant, S,)
        410     ctx.save_for_backward(A, B, X)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/kernels/utils.py:694, in matmul_lora(X, W, W_quant, A, B, s, out)
        692 def matmul_lora(X, W, W_quant, A, B, s, out = None):
        693     dtype = X.dtype
    --> 694     W = fast_dequantize(W.t(), W_quant, use_global_buffer = True)
        696     if X.dim() == 3:
        697         batch, seq_len, d = X.shape
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/torch/utils/_contextlib.py:116, in context_decorator.<locals>.decorate_context(*args, **kwargs)
        113 @functools.wraps(func)
        114 def decorate_context(*args, **kwargs):
        115     with ctx_factory():
    --> 116         return func(*args, **kwargs)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/kernels/utils.py:322, in fast_dequantize(W, quant_state, out, use_global_buffer)
        320 offset     = quant_state.offset
        321 state2     = quant_state.state2
    --> 322 absmax2    = state2.absmax
        323 code2      = state2.code
        324 blocksize2 = state2.blocksize
    
    AttributeError: 'NoneType' object has no attribute 'absmax'
  9. vincent-haoy commented on Jul 11, 2025

    @vincent-haoy

    @rolandtannous I was able to reproduce the same issue even after upgrading to the latest version (same as @behroozazarkhalili).

  10. lujiale621 commented on Jul 11, 2025

    @lujiale621

    me too

  11. darshanmakwana412 commented on Jul 11, 2025

    @darshanmakwana412

    I am also getting the same error after upgrading to latest version

  12. behroozazarkhalili commented on Jul 11, 2025

    @behroozazarkhalili

    @shimmyshimmer @rolandtannous any update on this?

  13. rolandtannous commented on Jul 11, 2025

    @rolandtannous
    Contributor

    @behroozazarkhalili as mentioned yesterday : was able to reproduce the same error you are getting.
    We'll work on fixing it. Thank you for your patience. Please don't constantly tag. if everyone tags constantly, it floods our notifications and we might miss the messages. we'll make sure to notify everyone once it's fixed.

  14. behroozazarkhalili commented on Jul 12, 2025

    @behroozazarkhalili

    @behroozazarkhalili as mentioned yesterday : was able to reproduce the same error you are getting. We'll work on fixing it. Thank you for your patience. Please don't constantly tag. if everyone tags constantly, it floods our notifications and we might miss the messages. we'll make sure to notify everyone once it's fixed.

    The reason to mention is that you said in another issue that the patch resolved the issues, which didn't. I only wanted to ensure you're in the loop.

  15. 4 remaining items

  16. darshanmakwana412 commented on Jul 14, 2025

    @darshanmakwana412

    For me going back to unsloth==2025.6.12,unsloth-zoo==2025.6.8, vllm==0.9.1 and transformers==4.50.3 resolved this for now

  17. behroozazarkhalili commented on Jul 14, 2025

    @behroozazarkhalili

    For me going back to unsloth==2025.6.12,unsloth-zoo==2025.6.8, vllm==0.9.1 and transformers==4.50.3 resolved this for now

    It's not the solution. It should work with the latest versions.

  18. rolandtannous commented on Jul 14, 2025

    @rolandtannous
    Contributor

    @simonusher @darshanmakwana412 @behroozazarkhalili @ai-nikolai @lujiale621 @vincent-haoy

    Hello!

    we just released a fix for this yesterday in the main repo.
    So if you use unsloth locally, make sure to update your local install of unsloth using the package's main repo, as follows:

    pip install --force-reinstall --no-deps git+https://github.com/unslothai/unsloth-zoo.git
    pip install --force-reinstall --no-deps git+https://github.com/unslothai/unsloth.git
    

    Note that the fix is not yet available via pypi (you won't currently get access to the fix if you install or update unsloth using pip install command so,
    if you're using the google colab environment , just add the following two commands at the bottom of the colab notebook install cells

    !pip install --force-reinstall --no-deps git+https://github.com/unslothai/unsloth-zoo.git
    !pip install --force-reinstall --no-deps git+https://github.com/unslothai/unsloth.git
    

    Thanks!

  19. behroozazarkhalili commented on Jul 15, 2025

    @behroozazarkhalili

    pip install --force-reinstall --no-deps git+https://github.com/unslothai/unsloth.git

    Issue: We are experiencing a new issue following the upgrade using the mentioned solution.

    Solution: return transformers to 4.51.3 using pip install transformers==4.51.3

    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    Cell In[1], line 1
    ----> 1 from grpo_qwen import ModelConfig, GRPOModelTrainer
    
    File ~/GRPO-Unsloth-Finetuning/GRPO-Qwen-Finetuning-Unsloth/grpo_qwen.py:11
          9 import torch
         10 from datasets import Dataset, load_dataset
    ---> 11 from unsloth import FastLanguageModel, is_bfloat16_supported
         12 from trl import GRPOConfig, GRPOTrainer
         13 from vllm import SamplingParams
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/__init__.py:243
        240     raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo`")
        241 pass
    --> 243 from .models import *
        244 from .models import __version__
        245 from .save import *
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/__init__.py:15
          1 # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
          2 #
          3 # Licensed under the Apache License, Version 2.0 (the "License");
       (...)
         12 # See the License for the specific language governing permissions and
         13 # limitations under the License.
    ---> 15 from .llama     import FastLlamaModel
         16 from .loader    import FastLanguageModel, FastVisionModel, FastTextModel, FastModel
         17 from .mistral   import FastMistralModel
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/llama.py:50
         48 if HAS_FLASH_ATTENTION:
         49     from flash_attn import flash_attn_func
    ---> 50 from .vision import FastBaseModel
         52 # Final patching code
         53 from transformers.models.llama.modeling_llama import (
         54     LlamaAttention,
         55     LlamaDecoderLayer,
         56     LlamaModel,
         57     LlamaForCausalLM,
         58 )
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth/models/vision.py:83
         76 _compile_config = CompileConfig(
         77     fullgraph = False,
         78     dynamic = None,
         79     mode = "reduce-overhead",
         80 )
         81 _compile_config.disable = True # Must set manually
    ---> 83 from unsloth_zoo.vllm_utils import (
         84     convert_lora_modules,
         85     return_lora_modules,
         86 )
         88 def unsloth_base_fast_generate(
         89     self,
         90     *args,
         91     **kwargs,
         92 ):
         93     if len(args) != 0:
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth_zoo/vllm_utils.py:266
        263 pass
        265 from .vllm_lora_request import LoRARequest as PatchedLoRARequest
    --> 266 from .vllm_lora_worker_manager import (
        267     WorkerLoRAManager as PatchedWorkerLoRAManager,
        268     LRUCacheWorkerLoRAManager as PatchedLRUCacheWorkerLoRAManager,
        269 )
        270 def patch_vllm_lora_load_tensors():
        271     import vllm.lora.request
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/unsloth_zoo/vllm_lora_worker_manager.py:12
          7 from vllm.adapter_commons.utils import (add_adapter_worker,
          8                                         apply_adapters_worker,
          9                                         list_adapters_worker,
         10                                         set_active_adapters_worker)
         11 from vllm.adapter_commons.worker_manager import AbstractWorkerManager
    ---> 12 from vllm.config import LoRAConfig
         13 from vllm.logger import init_logger
         14 from vllm.lora.models import (LoRAModel, LoRAModelManager,
         15                               LRUCacheLoRAModelManager, create_lora_manager)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/vllm/config.py:37
         35 from vllm.logger import init_logger
         36 from vllm.platforms import current_platform
    ---> 37 from vllm.transformers_utils.config import (
         38     ConfigFormat, get_config, get_hf_image_processor_config,
         39     get_hf_text_config, get_pooling_config,
         40     get_sentence_transformer_tokenizer_config, is_encoder_decoder,
         41     try_get_generation_config, try_get_safetensors_metadata,
         42     try_get_tokenizer_config, uses_mrope)
         43 from vllm.transformers_utils.s3_utils import S3Model
         44 from vllm.transformers_utils.utils import is_s3, maybe_model_redirect
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/vllm/transformers_utils/config.py:33
         30 from vllm.logger import init_logger
         31 # yapf conflicts with isort for this block
         32 # yapf: disable
    ---> 33 from vllm.transformers_utils.configs import (ChatGLMConfig, Cohere2Config,
         34                                              DbrxConfig, DeepseekVLV2Config,
         35                                              EAGLEConfig, ExaoneConfig,
         36                                              JAISConfig, KimiVLConfig,
         37                                              MedusaConfig, MiniMaxText01Config,
         38                                              MiniMaxVL01Config, MllamaConfig,
         39                                              MLPSpeculatorConfig, MPTConfig,
         40                                              NemotronConfig, NVLM_D_Config,
         41                                              OvisConfig, RWConfig,
         42                                              SkyworkR1VChatConfig, SolarConfig,
         43                                              Telechat2Config, UltravoxConfig)
         44 # yapf: enable
         45 from vllm.transformers_utils.utils import check_gguf_file
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/vllm/transformers_utils/configs/__init__.py:26
         24 from vllm.transformers_utils.configs.nemotron_h import NemotronHConfig
         25 from vllm.transformers_utils.configs.nvlm_d import NVLM_D_Config
    ---> 26 from vllm.transformers_utils.configs.ovis import OvisConfig
         27 from vllm.transformers_utils.configs.skyworkr1v import SkyworkR1VChatConfig
         28 from vllm.transformers_utils.configs.solar import SolarConfig
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/vllm/transformers_utils/configs/ovis.py:76
         73 IMAGE_ATOM_ID = -300
         74 IMAGE_INDICATOR_IDS = [-301, -302, -303, -304, -305]
    ---> 76 AutoConfig.register("aimv2", AIMv2Config)
         79 # ----------------------------------------------------------------------
         80 #                     Visual Tokenizer Configuration
         81 # ----------------------------------------------------------------------
         82 class BaseVisualTokenizerConfig(PretrainedConfig):
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/transformers/models/auto/configuration_auto.py:1281, in AutoConfig.register(model_type, config, exist_ok)
       1275 if issubclass(config, PretrainedConfig) and config.model_type != model_type:
       1276     raise ValueError(
       1277         "The config you are passing has a `model_type` attribute that is not consistent with the model type "
       1278         f"you passed (config has {config.model_type} and you passed {model_type}. Fix one of those so they "
       1279         "match!"
       1280     )
    -> 1281 CONFIG_MAPPING.register(model_type, config, exist_ok=exist_ok)
    
    File ~/.conda/envs/behrooz/lib/python3.11/site-packages/transformers/models/auto/configuration_auto.py:968, in _LazyConfigMapping.register(self, key, value, exist_ok)
        964 """
        965 Register a new configuration in this mapping.
        966 """
        967 if key in self._mapping.keys() and not exist_ok:
    --> 968     raise ValueError(f"'{key}' is already used by a Transformers config, pick another name.")
        969 self._extra_content[key] = value
    
    ValueError: 'aimv2' is already used by a Transformers config, pick another name.
  20. rolandtannous commented on Jul 15, 2025

    @rolandtannous
    Contributor

    transformers is supposed to be at 4.51.3 . do you know which version is getting installed. and are you running a colab notebook?
    in local environments, its preferable if you setup a persistent environment that you continuously use.

  21. behroozazarkhalili commented on Jul 15, 2025

    @behroozazarkhalili

    transformers is supposed to be at 4.51.3 . do you know which version is getting installed. and are you running a colab notebook? in local environments, its preferable if you setup a persistent environment that you continuously use.

    I used a notebook on the server, not colab. I used the persistent conda environment there.
    No, I think that's not correct. It was 4.54.0-dev or something similar. Please kindly check it again. It also requires the numpy version to be lower than 2.3 (not 2.3).

    Let's update the requirements.txt file or any other dependency handler for the installation. I can give you the versions of the package that work now.

    Image
  22. rolandtannous commented on Jul 15, 2025

    @rolandtannous
    Contributor

    What I meant is that it shouldn't install the dev version. If it did, then the dependency wasn't pinned while I think that it should be .
    I'll communicate this to the appropriate person.

  23. behroozazarkhalili commented on Jul 15, 2025

    @behroozazarkhalili

    What I meant is that it shouldn't install the dev version. If it did, then the dependency wasn't pinned while I think that it should be . I'll communicate this to the appropriate person.

    Uhum. These are the versions that are working for me right now.

    transformers: 4.51.3
    unsloth: 2025.7.3
    numpy: 1.26.4
    bitsandbytes: 0.46.1
    peft: 0.15.2
    vllm: 0.9.2
    
  24. vincent-haoy commented on Jul 15, 2025

    @vincent-haoy

    What I meant is that it shouldn't install the dev version. If it did, then the dependency wasn't pinned while I think that it should be . I'll communicate this to the appropriate person.

    Uhum. These are the versions that are working for me right now.

    transformers: 4.51.3
    unsloth: 2025.7.3
    numpy: 1.26.4
    bitsandbytes: 0.46.1
    peft: 0.15.2
    vllm: 0.9.2
    

    Hi, would you mind sharing a full requirements.txt file? I'm still encountering the NoneType issue even after upgrading to the latest version.... it might be related to an incompatible dependency? @behroozazarkhalili

  25. behroozazarkhalili commented on Jul 15, 2025

    @behroozazarkhalili

    What I meant is that it shouldn't install the dev version. If it did, then the dependency wasn't pinned while I think that it should be . I'll communicate this to the appropriate person.

    Now, I get the new error: #2974

  26. simonusher commented on Jul 15, 2025

    @simonusher
    Author

    Hey, it looks like it's been fixed for me with the latest version. Thanks a lot for help

  27. vincent-haoy commented on Jul 16, 2025

    @vincent-haoy

    @behroozazarkhalili I changed protobuf to version 3.20.3, and that resolved all the issues for me. I think it was the root cause. Try running pip check to see if you have any incompatible dependencies.

  28. rolandtannous commented on Jul 16, 2025

    @rolandtannous
    Contributor

    @vincent-haoy we usually sort of force protobuf 3.20.3 anyway when you install unsloth as unsloth-zoo forces "protobuf<4.0.0". You have something else that forced protobuf to another version but users were experiencing that error even when protobuf 3.20.3 was already installed so it was maybe both about installing the fix and having the right protobuf version.

  29. rolandtannous commented on Jul 16, 2025

    @rolandtannous
    Contributor

    We just checked, If you install unsloth in a fresh python environment, it installs transformers 4.53.2 as a dependency , not transformers 4.54.0-dev . if you have transformers 4.54.0-dev in your environment , it's probably because of running the Gemma3N notebook install cells int he same environment.
    This line is the culprit

    !pip install --no-deps git+https://github.com/huggingface/transformers.git
    

    This installs 4.54.0-dev .
    It's not needed since transformers 4.53.2 supports Gemma3N so we are going to remove it from the notebook.
    In case your env already has that issue , please manually downgrade your trasnformers version

    pip install --upgrade transformers==4.53.2
    

    Thanks

  30. behroozazarkhalili commented on Jul 16, 2025

    @behroozazarkhalili

    We just checked, If you install unsloth in a fresh python environment, it installs transformers 4.53.2 as a dependency , not transformers 4.54.0-dev . if you have transformers 4.54.0-dev in your environment , it's probably because of running the Gemma3N notebook install cells int he same environment. This line is the culprit

    !pip install --no-deps git+https://github.com/huggingface/transformers.git
    

    This installs 4.54.0-dev . It's not needed since transformers 4.53.2 supports Gemma3N so we are going to remove it from the notebook. In case your env already has that issue , please manually downgrade your trasnformers version

    pip install --upgrade transformers==4.53.2
    

    Thanks

    Great. Thank you for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfixed - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions