{"record":{"id":"61d0bc52bcb01272","repo":"hiyouga/LlamaFactory","slug":"chunk-size-must-be-one-of-supported-chunk-sizes","errorCode":null,"errorMessage":"chunk_size must be one of {SUPPORTED_CHUNK_SIZES}, got {chunk_size!r}.","messagePattern":"chunk_size must be one of (.+?), got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/v1/plugins/model_plugins/kernels/ops/linear_attention/fla.py","lineNumber":81,"sourceCode":"        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)\n            configured_op = partial(op, chunk_size=chunk_size) if op_name == CHUNK_GATED_DELTA_RULE else op\n            targets = {\n                f\"{type(module).__module__}.{type(module).__name__}.{module_attribute}\"\n                for _, module in named_modules\n                if callable(getattr(module, module_attribute, None))\n            }\n            matched = patch_model_members(model, sorted(targets), configured_op) if targets else 0\n            if matched == 0:\n                raise RuntimeError(f\"FLA operator `{op_name}` did not match any model module attributes.\")","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/v1/plugins/model_plugins/kernels/ops/linear_attention/fla.py#L63-L99","documentation":"The FLA plugin validates `chunk_size` (used when the chunk_gated_delta_rule kernel is configured) against SUPPORTED_CHUNK_SIZES. It must be a real int (bools are explicitly rejected because bool is a subclass of int) and a member of the supported set; anything else raises a ValueError echoing the offending value.","triggerScenarios":"Setting chunk_size to a value outside SUPPORTED_CHUNK_SIZES, a float like 64.0, a string like \"64\", or a boolean. YAML `chunk_size: true` parses to bool True which is explicitly caught by the isinstance(chunk_size, bool) guard.","commonSituations":"YAML configs where the value is quoted (\"64\") or written as a float; users guessing chunk sizes not supported by the Triton kernels; config templating emitting strings.","solutions":["Read the allowed values from SUPPORTED_CHUNK_SIZES in your installed fla.py and use one of them (64 is the default)","Ensure the YAML value is a plain unquoted integer","If the value comes from templating, cast to int before building kernel_config"],"exampleFix":"# before\nkernel_config:\n  chunk_size: \"64\"\n\n# after\nkernel_config:\n  chunk_size: 64","handlingStrategy":"validation","validationCode":"from llamafactory.v1.plugins.model_plugins.kernels.ops.linear_attention.fla import SUPPORTED_CHUNK_SIZES\nassert isinstance(chunk_size, int) and not isinstance(chunk_size, bool) and chunk_size in SUPPORTED_CHUNK_SIZES, \\\n    f\"chunk_size must be in {SUPPORTED_CHUNK_SIZES}\"","typeGuard":"def is_valid_chunk_size(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v in SUPPORTED_CHUNK_SIZES","tryCatchPattern":null,"preventionTips":["Write chunk_size as a bare integer in YAML","Check SUPPORTED_CHUNK_SIZES for your installed version before setting it"],"tags":["configuration","validation","kernel-plugin"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}