{"record":{"id":"6f6084f42df821f2","repo":"hiyouga/LlamaFactory","slug":"unknown-liger-op-s-sorted-ops-for-model-type","errorCode":null,"errorMessage":"Unknown Liger op(s) {sorted(ops)} for model_type={model_type}. Valid: {sorted(togglable)}","messagePattern":"Unknown Liger op\\(s\\) (.+?) for model_type=(.+?)\\. Valid: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/v1/plugins/model_plugins/kernels/liger_kernel_ops.py","lineNumber":118,"sourceCode":"\n        def _normalize_op_name(raw: str) -> str:\n            key = raw.strip().lower().replace(\"-\", \"_\")\n            aliases = {\n                \"rmsnorm\": \"rms_norm\",\n                \"flce\": \"fused_linear_cross_entropy\",\n                \"lce\": \"fused_linear_cross_entropy\",\n                \"fused_ce\": \"fused_linear_cross_entropy\",\n            }\n            return aliases.get(key, key)\n\n        if use_kernels is not None and len(use_kernels) == 0:\n            return model\n\n        if use_kernels != \"auto\":\n            selected = {_normalize_op_name(k) for k in use_kernels}\n            ops = selected - set(togglable)\n            if ops:\n                raise ValueError(\n                    f\"Unknown Liger op(s) {sorted(ops)} for model_type={model_type}. Valid: {sorted(togglable)}\"\n                )\n            if \"cross_entropy\" in selected and \"fused_linear_cross_entropy\" in selected:\n                raise ValueError(\"cross_entropy and fused_linear_cross_entropy cannot both be enabled.\")\n            call_kwargs = {name: (name in selected) for name in togglable}\n            call_kwargs[\"model\"] = model\n        else:\n            # Mirror ``liger_kernel`` signature defaults so patches match upstream defaults\n            # and logging reflects enabled ops (omitted kwargs only live in the callee).\n            call_kwargs = {\"model\": model}\n            for name in togglable:\n                param = sig[name]\n                if param.default is not inspect.Parameter.empty:\n                    call_kwargs[name] = param.default\n\n        if require_logits and \"fused_linear_cross_entropy\" in sig:\n            logger.warning_rank0(\"Current training stage does not support chunked cross entropy.\")\n            call_kwargs[\"fused_linear_cross_entropy\"] = False","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/v1/plugins/model_plugins/kernels/liger_kernel_ops.py#L100-L136","documentation":"When use_kernels is an explicit list (not 'auto'), each requested Liger op is normalized (aliases like lce/fused_ce -> fused_linear_cross_entropy) and must exist in the togglable set for the current model_type. Unknown ops raise ValueError listing the invalid names and the valid set for that architecture.","triggerScenarios":"Passing use_kernels=[\"swiglu\"] for a model whose apply_liger_kernel_to_* signature exposes no swiglu toggle; typo'd op names; using ops valid for LLaMA on a different architecture (e.g. Qwen MoE-specific ops).","commonSituations":"Copying a v0 enable_liger_kernel option list tuned for one model family to another; renaming drift between liger-kernel versions (ops added/renamed upstream); stale docs.","solutions":["Read the error: it prints the valid ops for your exact model_type — use only those.","Fix typos and stale names; check the model's apply_liger_kernel_to_<model_type> signature in your installed liger_kernel version.","Use use_kernels=\"auto\" to take the signature defaults for the model.","Upgrade/downgrade liger-kernel to the version whose op names match your config."],"exampleFix":"# before\nuse_kernels = [\"fused_ce\", \"swiglu\"]  # swiglu not togglable for this model\n\n# after\nuse_kernels = \"auto\"  # or list only names from the error's 'Valid:' set","handlingStrategy":"validation","validationCode":"import inspect\nfrom liger_kernel.transformers import monkey_patch\nfn = getattr(monkey_patch, f'apply_liger_kernel_to_{model_type}', None)\nassert fn is not None, f'no liger patch fn for model_type={model_type}'\ntogglable = {p for p in inspect.signature(fn).parameters if p != 'model'}\nunknown = set(use_kernels) - togglable - {'lce', 'fused_ce'}\nassert not unknown, f'unknown ops {unknown}; valid: {sorted(togglable)}'","typeGuard":"def ops_valid_for(model_type: str, ops: list[str]) -> bool:\n    \"\"\"True when every requested op is togglable for this model_type.\"\"\"\n    fn = getattr(monkey_patch, f'apply_liger_kernel_to_{model_type}', None)\n    if fn is None:\n        return False\n    togglable = set(inspect.signature(fn).parameters) - {'model'}\n    return set(ops) <= togglable | {'lce', 'fused_ce'}","tryCatchPattern":"try:\n    model = KernelPlugin('liger_kernel').apply(model=model, use_kernels=ops)\nexcept ValueError as e:\n    if 'Unknown Liger op' in str(e):\n        use_kernels = 'auto'  # fall back to defaults\n        model = KernelPlugin('liger_kernel').apply(model=model, use_kernels=use_kernels)\n    else:\n        raise","preventionTips":["Derive valid op lists from the installed liger signature per model, not docs.","Use 'auto' unless you need a specific op.","Pin liger-kernel version and re-validate op lists on upgrade."],"tags":["kernels","liger","config","validation"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}