hiyouga/LlamaFactory · error · ValueError
kernel_config.name must contain at least one kernel name.
Error message
kernel_config.name must contain at least one kernel name.
What it means
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'.
Source
Thrown at src/llamafactory/v1/plugins/model_plugins/kernels/interface.py:52
def _apply_auto_kernels(model: HFModel, **kwargs) -> HFModel:
device_type = get_current_accelerator().type
for kernel_name in _AUTO_KERNELS.get(device_type, ()):
model = KernelPlugin(kernel_name).apply(model=model, **kwargs)
return model
def apply_kernels(model: HFModel, config: dict[str, Any], require_logits: bool = False) -> HFModel:
"""Apply the comma-separated kernel names selected by ``kernel_config.name``."""
kernel_names = config.get("name")
if not isinstance(kernel_names, str):
raise TypeError("kernel_config.name must be a string.")
names = [name.strip() for name in kernel_names.split(",") if name.strip()]
if not names:
raise ValueError("kernel_config.name must contain at least one kernel name.")
for name in names:
if name == "auto":
model = _apply_auto_kernels(model=model, config=config, require_logits=require_logits)
else:
model = KernelPlugin(name).apply(model=model, config=config, require_logits=require_logits)
return model
def apply_v1_kernels(model: HFModel, use_v1_kernels: bool) -> HFModel:
"""Apply v1 automatic kernels for the transitional v0 ``use_v1_kernels`` option."""
if not use_v1_kernels:
return model
return apply_kernels(model, {"name": "auto"})
View on GitHub (pinned to f28afaf635)
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.
Example fix
# before
kernel_config: {"name": ""}
# after
kernel_config: {"name": "auto"} # or omit the call Defensive patterns
Strategy: validation
Validate before calling
name = kernel_config.get('name', '')
names = [n.strip() for n in name.split(',') if n.strip()]
assert names, 'kernel_config.name resolved to zero kernels' Type guard
def resolves_to_kernels(cfg: dict) -> bool:
"""True when cfg['name'] yields at least one non-empty kernel name."""
return bool([n for n in cfg.get('name', '').split(',') if n.strip()]) Try / catch
try:
apply_kernels(model, cfg)
except ValueError as e:
if 'at least one kernel name' in str(e):
cfg['name'] = 'auto'
apply_kernels(model, cfg)
else:
raise Prevention
- 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.
When it happens
Trigger: kernel_config name set to "" or " , " via YAML interpolation, env var expansion, or templating that left the value empty.
Common situations: Templated configs (Jinja/envsubst) where the kernel list variable is unset; YAML `name: "${KERNELS:-}" producing empty string; trailing-comma edits.
Related errors
- kernel_config.name must be a string.
- Unknown Liger op(s) {sorted(ops)} for model_type={model_type
- Unknown mixing strategy: {data_args.mix_strategy}.
- Cannot specify `val_size` if `eval_dataset` is not None.
- `kt_model_max_length` must be a positive integer.
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/0c502de588c41352.
Report an issue: GitHub.