{"record":{"id":"0c502de588c41352","repo":"hiyouga/LlamaFactory","slug":"kernel-config-name-must-contain-at-least-one-kerne","errorCode":null,"errorMessage":"kernel_config.name must contain at least one kernel name.","messagePattern":"kernel_config\\.name must contain at least one kernel name\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/v1/plugins/model_plugins/kernels/interface.py","lineNumber":52,"sourceCode":"\n\ndef _apply_auto_kernels(model: HFModel, **kwargs) -> HFModel:\n    device_type = get_current_accelerator().type\n    for kernel_name in _AUTO_KERNELS.get(device_type, ()):\n        model = KernelPlugin(kernel_name).apply(model=model, **kwargs)\n\n    return model\n\n\ndef apply_kernels(model: HFModel, config: dict[str, Any], require_logits: bool = False) -> HFModel:\n    \"\"\"Apply the comma-separated kernel names selected by ``kernel_config.name``.\"\"\"\n    kernel_names = config.get(\"name\")\n    if not isinstance(kernel_names, str):\n        raise TypeError(\"kernel_config.name must be a string.\")\n\n    names = [name.strip() for name in kernel_names.split(\",\") if name.strip()]\n    if not names:\n        raise ValueError(\"kernel_config.name must contain at least one kernel name.\")\n\n    for name in names:\n        if name == \"auto\":\n            model = _apply_auto_kernels(model=model, config=config, require_logits=require_logits)\n        else:\n            model = KernelPlugin(name).apply(model=model, config=config, require_logits=require_logits)\n\n    return model\n\n\ndef apply_v1_kernels(model: HFModel, use_v1_kernels: bool) -> HFModel:\n    \"\"\"Apply v1 automatic kernels for the transitional v0 ``use_v1_kernels`` option.\"\"\"\n    if not use_v1_kernels:\n        return model\n\n    return apply_kernels(model, {\"name\": \"auto\"})\n\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/v1/plugins/model_plugins/kernels/interface.py#L34-L70","documentation":"After splitting kernel_config['name'] on commas, at least one non-empty kernel name must remain. A string of only commas/whitespace (e.g. \"\", \" , \") raises this ValueError, distinguishing 'configured but empty' from 'mis-typed'.","triggerScenarios":"kernel_config name set to \"\" or \"  ,  \" via YAML interpolation, env var expansion, or templating that left the value empty.","commonSituations":"Templated configs (Jinja/envsubst) where the kernel list variable is unset; YAML `name: \"${KERNELS:-}\" producing empty string; trailing-comma edits.","solutions":["Provide at least one valid kernel name or the special \"auto\".","If kernels are optional in your flow, skip calling apply_kernels entirely when the name would be empty.","Add a config lint step that rejects empty kernel_config.name."],"exampleFix":"# before\nkernel_config: {\"name\": \"\"}\n\n# after\nkernel_config: {\"name\": \"auto\"}  # or omit the call","handlingStrategy":"validation","validationCode":"name = kernel_config.get('name', '')\nnames = [n.strip() for n in name.split(',') if n.strip()]\nassert names, 'kernel_config.name resolved to zero kernels'","typeGuard":"def resolves_to_kernels(cfg: dict) -> bool:\n    \"\"\"True when cfg['name'] yields at least one non-empty kernel name.\"\"\"\n    return bool([n for n in cfg.get('name', '').split(',') if n.strip()])","tryCatchPattern":"try:\n    apply_kernels(model, cfg)\nexcept ValueError as e:\n    if 'at least one kernel name' in str(e):\n        cfg['name'] = 'auto'\n        apply_kernels(model, cfg)\n    else:\n        raise","preventionTips":["Default empty kernel lists to 'auto' or skip the call in templating code.","Fail CI on empty interpolated config values.","Validate post-interpolation config, not the raw template."],"tags":["kernels","config","validation"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}