{"record":{"id":"b3db08ad68ead296","repo":"hiyouga/LlamaFactory","slug":"these-kt-config-values-are-derived-from-llama-fa","errorCode":null,"errorMessage":"These `kt_config` values are derived from LLaMA-Factory arguments: {conflicts}.","messagePattern":"These `kt_config` values are derived from LLaMA-Factory arguments: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/model_args.py","lineNumber":563,"sourceCode":"        return {\"cpu\": cpu_activation, \"gpu\": gpu_activation}\n\n    @staticmethod\n    def _get_accelerator_kt_config(training_args: Any) -> Any:\n        accelerator_config = getattr(training_args, \"accelerator_config\", None)\n        if isinstance(accelerator_config, dict):\n            return accelerator_config.get(\"kt_config\")\n        return getattr(accelerator_config, \"kt_config\", None)\n\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.\"\"\"","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/model_args.py#L545-L581","documentation":"Raised by _normalize_advanced_kt_config (model_args.py:563) when the user-supplied kt_config mapping contains any key in _KT_DERIVED_KEYS (the set of kt_weight_path, kt_lora_* , kt_train_mode, etc. shown above the __post_init__). Those settings are derived from the dedicated LlamaFactory kt_* arguments; supplying them inside kt_config too would create two competing sources of truth, so the conflicts are reported with their key names.","triggerScenarios":"Adding kt_weight_path or kt_lora_rank inside the kt_config mapping while also (or instead) using the top-level kt_* arguments; porting a KTransformers recipe that uses those exact key names into kt_config.","commonSituations":"Copy-pasting KTransformers upstream configs whose keys collide with the derived set; users assuming kt_config accepts every KTransformers option (it accepts all EXCEPT the derived ones).","solutions":["Move the listed keys out of kt_config into the corresponding top-level kt_* arguments (e.g. kt_weight_path, kt_lora_rank)","Delete duplicates: keep kt_config only for genuinely advanced KTransformers keys not exposed as LlamaFactory arguments","Check the _KT_DERIVED_KEYS set in model_args.py for the authoritative blacklist"],"exampleFix":"# before\nkt_config:\n  kt_weight_path: /path/to/weights   # derived key\n\n# after\nkt_weight_path: /path/to/weights\nkt_config:\n  gen_config:\n    temperature: 0.7","handlingStrategy":"validation","validationCode":"derived = {'kt_weight_path','kt_non_expert_weight_path','kt_lora_rank','kt_lora_expert_num','kt_train_mode','kt_use_lora_experts','kt_skip_expert_loading'}\nconflicts = set(cfg.get('kt_config') or {}) & derived\nassert not conflicts, f'move {sorted(conflicts)} to top-level arguments'","typeGuard":"def no_derived_conflicts(kt_config: dict | None, derived: set[str]) -> bool:\n    return not (set(kt_config or {}) & derived)","tryCatchPattern":null,"preventionTips":["Read _KT_DERIVED_KEYS in model_args.py before porting a KTransformers config","Use kt_config only for keys LlamaFactory does not expose natively"],"tags":["ktransformers","config-conflict","derived-fields"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}