{"record":{"id":"fafb36c4931a1519","repo":"hiyouga/LlamaFactory","slug":"kernel-config-include-kernels-must-be-auto-or-a","errorCode":null,"errorMessage":"kernel_config.include_kernels must be 'auto' or a comma-separated string.","messagePattern":"kernel_config\\.include_kernels must be 'auto' or a comma-separated string\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/v1/plugins/model_plugins/kernels/ops/linear_attention/fla.py","lineNumber":72,"sourceCode":"            import fsdp_turbo.ops.fla  # noqa: F401\n            from fsdp_turbo.ops.registry import get_op  # noqa: F401\n            from fsdp_turbo.utils.patch import patch_model_members  # noqa: F401\n        except ImportError as exc:\n            raise RuntimeError(\"Flash Linear Attention and FSDPTurbo are required for this kernel.\") from exc\n\n    @staticmethod\n    def _apply(**kwargs) -> HFModel:\n        model = kwargs[\"model\"]\n        config = kwargs.get(\"config\") or {}\n        include_kernels = config.get(\"include_kernels\", \"auto\")\n        chunk_size = config.get(\"chunk_size\", 64)\n\n        if include_kernels == \"auto\" or include_kernels is True:\n            selected = list(FLASH_LINEAR_ATTENTION_KERNELS)\n        elif isinstance(include_kernels, str):\n            selected = [name.strip() for name in include_kernels.split(\",\") if name.strip()]\n        else:\n            raise TypeError(\"kernel_config.include_kernels must be 'auto' or a comma-separated string.\")\n\n        if not selected:\n            raise ValueError(\"kernel_config.include_kernels must select at least one FLA kernel.\")\n\n        unsupported = set(selected).difference(FLASH_LINEAR_ATTENTION_KERNELS)\n        if unsupported:\n            raise ValueError(f\"Unsupported Flash Linear Attention kernels: {sorted(unsupported)}\")\n        if isinstance(chunk_size, bool) or not isinstance(chunk_size, int) or chunk_size not in SUPPORTED_CHUNK_SIZES:\n            raise ValueError(f\"chunk_size must be one of {SUPPORTED_CHUNK_SIZES}, got {chunk_size!r}.\")\n\n        from fsdp_turbo.ops.registry import get_op\n        from fsdp_turbo.utils.patch import patch_model_members\n\n        patched = 0\n        named_modules = tuple(model.named_modules())\n        for op_name in selected:\n            module_attribute = FLA_MODULE_ATTRIBUTES[op_name]\n            op = get_op(op_name)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/v1/plugins/model_plugins/kernels/ops/linear_attention/fla.py#L54-L90","documentation":"The FLA (Flash Linear Attention) kernel plugin validates the `kernel_config.include_kernels` setting before patching the model. The value must be the string 'auto' (or boolean True) to select all kernels, or a non-empty comma-separated string of kernel names. Any other type (int, list, dict, None explicitly passed, nested config object) is rejected with a TypeError because the plugin cannot interpret it.","triggerScenarios":"Calling the FLA kernel plugin with a kernel_config dict where include_kernels is a Python list (e.g. ['chunk_gated_delta_rule']), a dict, an int, or None instead of the string 'auto' or 'kern1,kern2'. Happens when YAML/JSON config values are parsed into native structures and passed through unchanged.","commonSituations":"Users writing `include_kernels: [chunk_fwd, chunk_bwd]` as a YAML list instead of a comma-separated string; passing a parsed JSON array; or copying a list-style config from another kernel plugin that accepts sequences.","solutions":["Set include_kernels to the string \"auto\" to enable all FLA kernels","Or set it to a comma-separated string of kernel names, e.g. \"chunk_gated_delta_rule,chunk_fwd\"","Check the code path that builds kernel_config and ensure it serializes lists to strings before the plugin sees it"],"exampleFix":"# before\nkernel_config:\n  include_kernels:\n    - chunk_gated_delta_rule\n    - chunk_fwd\n\n# after\nkernel_config:\n  include_kernels: \"chunk_gated_delta_rule,chunk_fwd\"  # or \"auto\"","handlingStrategy":"type-guard","validationCode":"def normalize_include_kernels(cfg: dict) -> None:\n    v = cfg.get(\"include_kernels\", \"auto\")\n    if not (v == \"auto\" or v is True or isinstance(v, str)):\n        raise TypeError(f\"include_kernels must be 'auto' or str, got {type(v).__name__}\")\n    if isinstance(v, list):\n        cfg[\"include_kernels\"] = \",\".join(v)","typeGuard":"def is_valid_include_kernels(v) -> bool:\n    return v is True or (isinstance(v, str) and not isinstance(v, bool))","tryCatchPattern":null,"preventionTips":["Keep include_kernels as a string in YAML; never a list","Validate kernel_config shape in your own config loader before handing it to the plugin"],"tags":["configuration","type-error","kernel-plugin","linear-attention"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}