{"record":{"id":"8273724bf55a47d3","repo":"huggingface/transformers","slug":"input-weight-should-be-of-type-nn-parameter-got","errorCode":null,"errorMessage":"Input weight should be of type nn.Parameter, got {type(weight)} instead","messagePattern":"Input weight should be of type nn\\.Parameter, got (.+?) instead","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/bitsandbytes.py","lineNumber":247,"sourceCode":"\n    if not has_been_replaced:\n        logger.warning(\n            \"You are loading your model using eetq but no linear modules were found in your model.\"\n            \" Please double check your model architecture, or submit an issue on github if you think this is\"\n            \" a bug.\"\n        )\n    return model\n\n\n# Copied from PEFT: https://github.com/huggingface/peft/blob/47b3712898539569c02ec5b3ed4a6c36811331a1/src/peft/utils/integrations.py#L41\ndef dequantize_bnb_weight(weight: \"torch.nn.Parameter\", state=None):\n    \"\"\"\n    Helper function to dequantize 4bit or 8bit bnb weights.\n\n    If the weight is not a bnb quantized weight, it will be returned as is.\n    \"\"\"\n    if not isinstance(weight, torch.nn.Parameter):\n        raise TypeError(f\"Input weight should be of type nn.Parameter, got {type(weight)} instead\")\n\n    cls_name = weight.__class__.__name__\n    if cls_name not in (\"Params4bit\", \"Int8Params\"):\n        return weight\n\n    if cls_name == \"Params4bit\":\n        output_tensor = bnb.functional.dequantize_4bit(weight.data, weight.quant_state)\n        return output_tensor\n\n    if state.SCB is None:\n        state.SCB = weight.SCB\n\n    if hasattr(bnb.functional, \"int8_vectorwise_dequant\"):\n        # Use bitsandbytes API if available (requires v0.45.0+)\n        dequantized = bnb.functional.int8_vectorwise_dequant(weight.data, state.SCB)\n    else:\n        # Multiply by (scale/127) to dequantize.\n        dequantized = weight.data * state.SCB.view(-1, 1) * 7.874015718698502e-3","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/bitsandbytes.py#L229-L265","documentation":"Error \"Input weight should be of type nn.Parameter, got {type(weight)} instead\" thrown in huggingface/transformers.","triggerScenarios":"Raised in bitsandbytes quantization when the weight passed to a quantized linear is not an nn.Parameter.","commonSituations":"Passing plain tensors to bnb 8-bit/4-bit linear initialization instead of nn.Parameter.","solutions":["Pass an `nn.Parameter` weight to the bitsandbytes layer replacement.","Wrap plain tensors with `nn.Parameter(tensor)`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}