{"record":{"id":"4187d47adabb6a12","repo":"hiyouga/LlamaFactory","slug":"put-ktransformers-settings-in-the-llama-factory-tr","errorCode":null,"errorMessage":"Put KTransformers settings in the LLaMA-Factory training YAML `kt_config`; remove `kt_config` from the Accelerate config.","messagePattern":"Put KTransformers settings in the LLaMA-Factory training YAML `kt_config`; remove `kt_config` from the Accelerate config\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/model_args.py","lineNumber":571,"sourceCode":"\n    def _normalize_advanced_kt_config(self, raw_config: Any) -> dict[str, Any]:\n        if raw_config is None:\n            return {}\n        if not isinstance(raw_config, dict):\n            raise TypeError(\"LLaMA-Factory `kt_config` must be a flat mapping.\")\n\n        config = dict(raw_config)\n        conflicts = sorted(set(config) & self._KT_DERIVED_KEYS)\n        if conflicts:\n            raise ValueError(f\"These `kt_config` values are derived from LLaMA-Factory arguments: {conflicts}.\")\n        return config\n\n    def _get_advanced_kt_config(self, training_args: Any) -> dict[str, Any]:\n        raw_config = getattr(training_args, \"kt_config\", None)\n        accelerator_config = self._get_accelerator_kt_config(training_args)\n        if raw_config is None:\n            if accelerator_config is not None:\n                raise ValueError(\n                    \"Put KTransformers settings in the LLaMA-Factory training YAML `kt_config`; \"\n                    \"remove `kt_config` from the Accelerate config.\"\n                )\n            return {}\n        if accelerator_config is not None and accelerator_config != raw_config:\n            raise ValueError(\"LLaMA-Factory YAML and Accelerate config cannot define different KT settings.\")\n        return self._normalize_advanced_kt_config(raw_config)\n\n    def configure_kt_checkpointing(self, training_args: Any) -> None:\n        r\"\"\"Keep LLaMA-Factory as the single gradient-checkpointing entry point.\"\"\"\n        if self.use_unsloth or self.use_unsloth_gc:\n            raise ValueError(\"KTransformers cannot be combined with Unsloth checkpoint wrapping.\")\n        if getattr(training_args, \"gradient_checkpointing\", False):\n            raise ValueError(\n                \"KTransformers uses LLaMA-Factory's `disable_gradient_checkpointing`; \"\n                \"remove `gradient_checkpointing: true`.\"\n            )\n        if getattr(training_args, \"gradient_checkpointing_kwargs\", None) is not None:","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/model_args.py#L553-L589","documentation":"Raised by _get_advanced_kt_config (model_args.py:571) when kt_config is absent from the LlamaFactory training YAML but present under accelerator_config.kt_config in the Accelerate config file. LlamaFactory wants a single source of truth for KTransformers settings, so defining them only in the Accelerate launcher config is rejected with instructions on where to put them.","triggerScenarios":"Running accelerate launch with an Accelerate YAML that includes a kt_config: {...} block under accelerator_config, while the training YAML has no kt_config; following an older tutorial that put KT settings in the Accelerate file.","commonSituations":"Migrating setups from when Accelerate-side kt_config was tolerated; team shared Accelerate configs accumulating feature blocks; users pasting the KT block into the wrong YAML.","solutions":["Move the kt_config block from the Accelerate config into the LlamaFactory training YAML under a top-level kt_config key","Delete accelerator_config.kt_config from the Accelerate YAML","Re-run; if both files now define identical kt_config it is accepted (see error 158 for the not-equal case)"],"exampleFix":"# before (accelerate_config.yaml)\naccelerator_config:\n  kt_config:\n    gen_config: {temperature: 0.7}\n\n# after (train.yaml)\nkt_config:\n  gen_config:\n    temperature: 0.7\n# accelerate config: kt_config block removed","handlingStrategy":"validation","validationCode":"acc = yaml.safe_load(open('accelerate_config.yaml'))\nassert 'kt_config' not in (acc.get('accelerator_config') or {}), 'move kt_config to the LF training YAML'","typeGuard":"def accelerate_has_kt_config(acc_cfg: dict) -> bool:\n    return 'kt_config' in (acc_cfg.get('accelerator_config') or {})","tryCatchPattern":null,"preventionTips":["Keep KTransformers settings exclusively in the training YAML","Review shared Accelerate configs before adopting new feature blocks"],"tags":["ktransformers","accelerate","config-conflict"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}