sgl-project/sglang · error · RuntimeError
Completion template {completion_template_arg} is not a built
Error message
Completion template {completion_template_arg} is not a built-in template name or a valid completion template file path. What it means
Same pattern as the chat-template case but for --completion-template: load_completion_template accepts either a registered builtin completion template name or a file path; when the name isn't builtin and the path doesn't exist, it raises RuntimeError.
Source
Thrown at python/sglang/srt/parser/template_manager.py:230
model_path: Path to the model
"""
template_name = get_conv_template_by_model_path(model_path)
if template_name is not None:
logger.info(f"Inferred chat template from model path: {template_name}")
self._chat_template_name = template_name
def load_completion_template(self, completion_template_arg: str) -> None:
"""
Load completion template for code completion.
Args:
completion_template_arg: Template name or file path
"""
logger.info(f"Loading completion template: {completion_template_arg}")
if not completion_template_exists(completion_template_arg):
if not os.path.exists(completion_template_arg):
raise RuntimeError(
f"Completion template {completion_template_arg} is not a built-in template name "
"or a valid completion template file path."
)
self._load_json_completion_template(completion_template_arg)
else:
self._completion_template_name = completion_template_arg
set_completion_template(self._completion_template_name)
def initialize_templates(
self,
tokenizer_manager: TokenizerManager,
model_path: str,
chat_template: Optional[str] = None,
completion_template: Optional[str] = None,
) -> None:
"""View on GitHub (pinned to 0132848349)
Solutions
- Check builtin completion template names and use one exactly
- Otherwise pass an absolute path to your JSON/jinja file and confirm it exists (ls)
- Mount the file into the container or bake it into the image
Example fix
# before python -m sglang.launch_server --completion-template tmpl.json # after python -m sglang.launch_server --completion-template /app/templates/tmpl.json
Defensive patterns
Strategy: validation
Validate before calling
import os
ok = completion_template_exists(arg) or os.path.isfile(os.path.abspath(arg))
if not ok:
raise FileNotFoundError(arg) Type guard
def is_loadable_completion_template(arg: str) -> TypeGuard[str]:
import os
from sglang.srt.parser.template_manager import completion_template_exists
return completion_template_exists(arg) or os.path.isfile(arg) Try / catch
try:
tm.load_completion_template(completion_template_arg)
except RuntimeError as e:
if "Completion template" in str(e):
sys.exit(f"bad --completion-template: {completion_template_arg}")
raise Prevention
- Pre-check os.path.isfile on absolute paths at startup
- Keep custom completion templates next to code and reference absolutely
- Smoke-test server args in CI with a template-existence assertion
When it happens
Trigger: Passing --completion-template base (not builtin) with no file named base in the working directory, or a JSON completion-template path that's mistyped or not mounted.
Common situations: Custom JSON completion template files not shipped in the Docker image, wrong relative path, or a builtin-name typo.
Related errors
- Chat template {chat_template_arg} is not a built-in template
- metal shader source not found: {metal_src}
- MiniMax-H3 on MPS requires synchronous layerwise offload for
- MiniMax-H3 MPS execution does not support torch.compile; pas
- MiniMax-H3 ring parallelism requires the FlashAttention back
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/9c0a19a1513c881b.
Report an issue: GitHub.