{"record":{"id":"b938454cffa62788","repo":"hiyouga/LlamaFactory","slug":"unsloth-is-currently-not-supported-for-oft","errorCode":null,"errorMessage":"Unsloth is currently not supported for OFT.","messagePattern":"Unsloth is currently not supported for OFT\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/model/adapter.py","lineNumber":284,"sourceCode":"            }\n        elif finetuning_args.finetuning_type == \"oft\":\n            peft_kwargs = {\n                \"r\": finetuning_args.oft_rank,\n                \"oft_block_size\": finetuning_args.oft_block_size,\n                \"target_modules\": target_modules,\n                \"module_dropout\": finetuning_args.module_dropout,\n                \"modules_to_save\": finetuning_args.additional_target,\n            }\n\n        if model_args.use_kt:\n            if finetuning_args.finetuning_type != \"lora\":\n                raise ValueError(\"KTransformers only supports LoRA finetuning.\")\n\n            peft_config = LoraConfig(task_type=TaskType.CAUSAL_LM, inference_mode=False, **peft_kwargs)\n            model = get_peft_model(model, peft_config, autocast_adapter_dtype=cast_trainable_params_to_fp32)\n        elif model_args.use_unsloth:\n            if finetuning_args.finetuning_type == \"oft\":\n                raise ValueError(\"Unsloth is currently not supported for OFT.\")\n\n            model = get_unsloth_peft_model(model, model_args, peft_kwargs)\n        else:\n            if finetuning_args.pissa_init:\n                if finetuning_args.pissa_iter == -1:\n                    logger.info_rank0(\"Using PiSSA initialization.\")\n                    peft_kwargs[\"init_lora_weights\"] = \"pissa\"\n                else:\n                    logger.info_rank0(f\"Using PiSSA initialization with FSVD steps {finetuning_args.pissa_iter}.\")\n                    peft_kwargs[\"init_lora_weights\"] = f\"pissa_niter_{finetuning_args.pissa_iter}\"\n\n            if finetuning_args.finetuning_type == \"lora\":\n                peft_config = LoraConfig(\n                    task_type=TaskType.CAUSAL_LM,\n                    inference_mode=False,\n                    **peft_kwargs,\n                )\n            elif finetuning_args.finetuning_type == \"oft\":","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/model/adapter.py#L266-L302","documentation":"Raised in _setup_lora_tuning when use_unsloth is true and finetuning_type is oft. The Unsloth integration path (get_unsloth_peft_model) only implements accelerated LoRA; OFT adapters are not supported by it.","triggerScenarios":"Config with use_unsloth: true and finetuning_type: oft.","commonSituations":"Enabling Unsloth for memory/speed in an OFT experiment config.","solutions":["Set finetuning_type: lora when using Unsloth.","Remove use_unsloth to run OFT on the standard peft path."],"exampleFix":"# before\nuse_unsloth: true\nfinetuning_type: oft\n\n# after\nuse_unsloth: false\nfinetuning_type: oft","handlingStrategy":"validation","validationCode":"if model_args.get(\"use_unsloth\"):\n    assert finetuning_args.get(\"finetuning_type\") != \"oft\", \\\n        \"Unsloth does not implement OFT; use lora or disable use_unsloth\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the supported matrix: Unsloth accelerates LoRA only.","Lint use_unsloth together with finetuning_type in preflight checks."],"tags":["unsloth","oft","finetuning-type"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}