{"record":{"id":"7cd8400a6bfb866e","repo":"hiyouga/LlamaFactory","slug":"the-installed-transformers-kt-does-not-provide-co","errorCode":null,"errorMessage":"The installed Transformers-KT does not provide `configure_kt()`.","messagePattern":"The installed Transformers-KT does not provide `configure_kt\\(\\)`\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"src/llamafactory/hparams/model_args.py","lineNumber":693,"sourceCode":"\n        adapter_dir = self._resolve_kt_adapter_artifact_dir(\"training\")\n        update_kt_config(kt_config, adapter_name_or_path=adapter_dir)\n\n    def configure_kt_loading(self, finetuning_args: Any, model_max_length: int | None) -> None:\n        r\"\"\"Configure KT model loading for inference and evaluation.\"\"\"\n        if not self.use_kt:\n            if self._kt_inference_config is not None:\n                raise ValueError(\"`kt_config` requires `use_kt: true`.\")\n            return\n        if self.infer_backend != EngineName.HF:\n            raise ValueError(\"KTransformers inference requires `infer_backend: huggingface`.\")\n\n        adapter_dir = self._resolve_kt_adapter_artifact_dir(\"inference\")\n\n        try:\n            from transformers.integrations.kt import configure_kt\n        except (ImportError, ModuleNotFoundError) as exc:\n            raise RuntimeError(\"The installed Transformers-KT does not provide `configure_kt()`.\") from exc\n\n        kt_config = self.get_kt_config_dict(\n            finetuning_args,\n            model_max_length,\n            self._normalize_advanced_kt_config(self._kt_inference_config),\n        )\n        self._kt_adapter_artifact_path = adapter_dir\n        self._kt_config_handle = configure_kt(kt_config)\n\n\n@dataclass\nclass ModelArguments(\n    SGLangArguments,\n    VllmArguments,\n    KTransformersArguments,\n    ExportArguments,\n    ProcessorArguments,\n    QuantizationArguments,","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/model_args.py#L675-L711","documentation":"Raised by configure_kt_loading when `from transformers.integrations.kt import configure_kt` fails with ImportError/ModuleNotFoundError. Like error 170 this is a dependency-contract failure: the runtime transformers must be the KT-aware fork exposing the integration module, not stock transformers.","triggerScenarios":"use_kt: true at inference time with stock transformers installed, or transformers-kt missing/outdated so the integrations.kt submodule does not exist; the import inside configure_kt_loading fails and is re-raised as this RuntimeError.","commonSituations":"Inference environments (serving containers, eval pods) built from a lighter requirements file that omitted the KT packages used during training.","solutions":["Install the KT stack in the inference environment: `pip install -U transformers-kt accelerate-kt kt-kernel`.","Verify: `python -c \"from transformers.integrations.kt import configure_kt\"`.","Ensure no stock `transformers` shadows `transformers-kt` on sys.path."],"exampleFix":"# before (bash)\npip install transformers  # stock build\nllamafactory-cli chat kt_chat.yaml  # RuntimeError\n\n# after (bash)\npip install -U transformers-kt accelerate-kt kt-kernel\nllamafactory-cli chat kt_chat.yaml","handlingStrategy":"validation","validationCode":"try:\n    from transformers.integrations.kt import configure_kt  # noqa: F401\nexcept ImportError:\n    raise SystemExit('transformers-kt not installed; pip install -U transformers-kt')","typeGuard":null,"tryCatchPattern":"try:\n    model_args.configure_kt_loading(ft_args, cutoff_len)\nexcept RuntimeError as e:\n    if 'configure_kt()' in str(e):\n        raise SystemExit('install the KT transformers fork before KT inference') from e\n    raise","preventionTips":["Use identical dependency lockfiles for KT training and KT inference images.","Add an import smoke test to container entrypoints."],"tags":["ktransformers","dependencies","import-error","llamafactory"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}