hiyouga/LlamaFactory · error · ValueError
These `kt_config` values are derived from LLaMA-Factory argu
Error message
These `kt_config` values are derived from LLaMA-Factory arguments: {conflicts}. What it means
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.
Source
Thrown at src/llamafactory/hparams/model_args.py:563
return {"cpu": cpu_activation, "gpu": gpu_activation}
@staticmethod
def _get_accelerator_kt_config(training_args: Any) -> Any:
accelerator_config = getattr(training_args, "accelerator_config", None)
if isinstance(accelerator_config, dict):
return accelerator_config.get("kt_config")
return getattr(accelerator_config, "kt_config", None)
def _normalize_advanced_kt_config(self, raw_config: Any) -> dict[str, Any]:
if raw_config is None:
return {}
if not isinstance(raw_config, dict):
raise TypeError("LLaMA-Factory `kt_config` must be a flat mapping.")
config = dict(raw_config)
conflicts = sorted(set(config) & self._KT_DERIVED_KEYS)
if conflicts:
raise ValueError(f"These `kt_config` values are derived from LLaMA-Factory arguments: {conflicts}.")
return config
def _get_advanced_kt_config(self, training_args: Any) -> dict[str, Any]:
raw_config = getattr(training_args, "kt_config", None)
accelerator_config = self._get_accelerator_kt_config(training_args)
if raw_config is None:
if accelerator_config is not None:
raise ValueError(
"Put KTransformers settings in the LLaMA-Factory training YAML `kt_config`; "
"remove `kt_config` from the Accelerate config."
)
return {}
if accelerator_config is not None and accelerator_config != raw_config:
raise ValueError("LLaMA-Factory YAML and Accelerate config cannot define different KT settings.")
return self._normalize_advanced_kt_config(raw_config)
def configure_kt_checkpointing(self, training_args: Any) -> None:
r"""Keep LLaMA-Factory as the single gradient-checkpointing entry point."""View on GitHub (pinned to f28afaf635)
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
Example fix
# before
kt_config:
kt_weight_path: /path/to/weights # derived key
# after
kt_weight_path: /path/to/weights
kt_config:
gen_config:
temperature: 0.7 Defensive patterns
Strategy: validation
Validate before calling
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'}
conflicts = set(cfg.get('kt_config') or {}) & derived
assert not conflicts, f'move {sorted(conflicts)} to top-level arguments' Type guard
def no_derived_conflicts(kt_config: dict | None, derived: set[str]) -> bool:
return not (set(kt_config or {}) & derived) Prevention
- Read _KT_DERIVED_KEYS in model_args.py before porting a KTransformers config
- Use kt_config only for keys LlamaFactory does not expose natively
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Put KTransformers settings in the LLaMA-Factory training YAM
- LLaMA-Factory YAML and Accelerate config cannot define diffe
- `kt_cpu_activation` must be `retain` or `recompute`.
- `kt_cpu_activation` is only valid when `use_kt: true`.
- `kt_cpu_activation: recompute` requires GPU gradient checkpo
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/b3db08ad68ead296.
Report an issue: GitHub.