Skip to content

[Bug] RuntimeError: Direct module loading failed for unsloth_compiled_module_qwen3: positional argument follows keyword argumentPlease fill in your issue title here. #2814

Closed
unslothai/unsloth-zoo
#182

Description

@HeavyNotFat
  1. Did you update? pip install --upgrade unsloth unsloth_zoo\

yes

  1. Colab or Kaggle or local / cloud

local

  1. Number GPUs used, use nvidia-smi

RTX 3090

  1. Which notebook? Please link!
  2. Which Unsloth version, TRL version, transformers version, PyTorch version?

PyTorch

  1. Which trainer? SFTTrainer, GRPOTrainer etc```pythonPut Minimal code to reproduce error here ###Remove

SFTTRainer

  1. Hugging Face token###

Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 432, in create_new_function
    new_module, old_path = import_module(compile_folder, name)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 427, in import_module
    new_module = importlib.import_module(name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 991, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1129, in get_code
  File "<frozen importlib._bootstrap_external>", line 1059, in source_to_code
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/root/Qwen3_8B/unsloth_compiled_cache/unsloth_compiled_module_qwen3.py", line 441
    loss = self.loss_function(logits=logits, labels=labels.to(self.lm_head.weight.device), self.config.vocab_size, **kwargs)
                                                                                                                           ^
SyntaxError: positional argument follows keyword argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 457, in create_new_function
    spec.loader.exec_module(new_module)
  File "<frozen importlib._bootstrap_external>", line 991, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1129, in get_code
  File "<frozen importlib._bootstrap_external>", line 1059, in source_to_code
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/tmp/unsloth_compiled_cache/unsloth_compiled_module_qwen3.py", line 441
    loss = self.loss_function(logits=logits, labels=labels.to(self.lm_head.weight.device), self.config.vocab_size, **kwargs)
                                                                                                                           ^
SyntaxError: positional argument follows keyword argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 2156, in unsloth_compile_transformers
    combined_module = create_new_function(
                      ^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 459, in create_new_function
    raise RuntimeError(f"Direct module loading failed for {name}: {e}")
RuntimeError: Direct module loading failed for unsloth_compiled_module_qwen3: positional argument follows keyword argument (unsloth_compiled_module_qwen3.py, line 441)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/Qwen3_8B/finetunning.py", line 13, in <module>
    model, tokenizer = FastLanguageModel.from_pretrained(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/loader.py", line 109, in from_pretrained
    return FastModel.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/loader.py", line 701, in from_pretrained
    model_types, supports_sdpa = unsloth_compile_transformers(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/_utils.py", line 1239, in unsloth_compile_transformers
    _unsloth_compile_transformers(
  File "/root/miniconda3/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 2168, in unsloth_compile_transformers
    raise RuntimeError(exception)
RuntimeError: Direct module loading failed for unsloth_compiled_module_qwen3: positional argument follows keyword argument

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

Activity

  1. joshuakelleyds commented on Jun 27, 2025

    @joshuakelleyds

    Think it's a problem with the transformers release yesterday, try pip install -U transformers==4.52.4, you might also need to pip install -U unsloth==2025.06.04 unsloth-zoo==2025.06.04 as this worked for me!

  2. icsy7867 commented on Jun 27, 2025

    @icsy7867

    This worked for me, thank you!

  3. davebulaval commented on Jul 3, 2025

    @davebulaval

    You will also need triton-3.3.0 otherwise it still fails.

  4. kldzj commented on Jul 4, 2025

    @kldzj

    You will also need triton-3.3.0 otherwise it still fails.

    Still failing for me eitherway. Installing triton==3.3.0 actually introduces new errors.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions