Skip to content

[Bug] Error when loading model from local path: 'GptOssTopKRouter' has no attribute 'weight' #3453

Closed

Description

@ifmain

Hello,

I encountered a new issue when loading any model (even the original ones) from a local file.

Example:

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "models/input/unsloth-gpt-oss-20b-mxfp4",
    dtype = dtype, 
    max_seq_length = max_seq_length,
    load_in_4bit = True, 
    full_finetuning = False, 
) 

I get this error:

AttributeError: 'GptOssTopKRouter' object has no attribute 'weight'

It looks like something breaks when loading from a local path.

#### Unsloth: `hf_xet==1.1.10` and `ipykernel>6.30.1` breaks progress bars. Disabling for now in XET.
#### Unsloth: To re-enable progress bars, please downgrade to `ipykernel==6.30.1` or wait for a fix to
https://github.com/huggingface/xet-core/issues/526
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
Skipping import of cpp extensions due to incompatible torch version 2.8.0+cu129 for torchao version 0.14.0         Please see GitHub issue #2919 for more info
🦥 Unsloth Zoo will now patch everything to make training faster!
==((====))==  Unsloth 2025.10.3: Fast Gpt_Oss patching. Transformers: 4.57.0.dev0.
   \\   /|    NVIDIA GeForce RTX 5060 Ti. Num GPUs = 1. Max memory: 15.928 GB. Platform: Linux.
O^O/ \_/ \    Torch: 2.8.0+cu129. CUDA: 12.0. CUDA Toolkit: 12.9. Triton: 3.4.0
\        /    Bfloat16 = TRUE. FA [Xformers = None. FA2 = False]
 "-____-"     Free license: http://github.com/unslothai/unsloth
Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
INFO:httpx: HTTP Request: HEAD https://huggingface.co/unslothai/other/resolve/main/config.json "HTTP/1.1 307 Temporary Redirect"
INFO:httpx: HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/unslothai/other/43d9e0f2f19a5d7836895f648dc0e762816acf77/config.json "HTTP/1.1 200 OK"
INFO:httpx: HTTP Request: GET https://huggingface.co/api/resolve-cache/models/unslothai/other/43d9e0f2f19a5d7836895f648dc0e762816acf77/config.json "HTTP/1.1 200 OK"
INFO:httpx: HTTP Request: HEAD https://huggingface.co/unslothai/other/resolve/main/config.json "HTTP/1.1 307 Temporary Redirect"
.....
INFO:httpx: HTTP Request: GET https://huggingface.co/api/resolve-cache/models/unslothai/1/7ec782b7604cd9ea0781c23a4270f031650f5617/config.json "HTTP/1.1 200 OK"
INFO:httpx: HTTP Request: HEAD https://huggingface.co/unslothai/1/resolve/main/config.json "HTTP/1.1 307 Temporary Redirect"
INFO:httpx: HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/unslothai/1/7ec782b7604cd9ea0781c23a4270f031650f5617/config.json "HTTP/1.1 200 OK"
INFO:httpx: HTTP Request: GET https://huggingface.co/api/resolve-cache/models/unslothai/1/7ec782b7604cd9ea0781c23a4270f031650f5617/config.json "HTTP/1.1 200 OK"
Traceback (most recent call last):
  File "/mnt/c/AiUtils/train/train_lora_model.py", line 25, in <module>
    model, tokenizer = FastLanguageModel.from_pretrained(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
....
  File "/mnt/c/AiUtils/train/gpt-oss/lib/python3.11/site-packages/transformers/models/gpt_oss/modeling_gpt_oss.py", line 433, in _init_weights
    module.weight.data.normal_(mean=0.0, std=std)
    ^^^^^^^^^^^^^
  File "/mnt/c/AiUtils/train/gpt-oss/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1962, in __getattr__
    raise AttributeError(
AttributeError: 'GptOssTopKRouter' object has no attribute 'weight'

Activity

  1. iFe1er commented on Jan 28, 2026

    @iFe1er

    same issue when loading from local directory. @danielhanchen

    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name="autodl-tmp/gpt-oss-20b",
        max_seq_length=4096,
        dtype=None,
        load_in_4bit=True,
        local_files_only=True
    )
    
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