sgl-project/sglang · error · ValueError

Config file not found: {args.config}

Error message

Config file not found: {args.config}

What it means

Raised by the `generate` CLI command's validate() when --config is given but the file does not exist at that path (os.path.exists fails). The config file is required to parse generation settings before launching.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/cli/generate.py:237

        """Get names of arguments for DiffGenerator initialization"""
        return ["num_gpus", "tp_size", "sp_size", "model_path"]

    def _get_generation_arg_names(self) -> list[str]:
        """Get names of arguments for generate_video method"""
        return [field.name for field in dataclasses.fields(SamplingParams)]

    def cmd(
        self, args: argparse.Namespace, unknown_args: list[str] | None = None
    ) -> None:
        generate_cmd(args, unknown_args)

    def validate(self, args: argparse.Namespace) -> None:
        """Validate the arguments for this command"""
        if args.num_gpus is not None and args.num_gpus <= 0:
            raise ValueError("Number of gpus must be positive")

        if args.config and not os.path.exists(args.config):
            raise ValueError(f"Config file not found: {args.config}")

    def subparser_init(
        self, subparsers: argparse._SubParsersAction
    ) -> FlexibleArgumentParser:
        generate_parser = subparsers.add_parser(
            "generate",
            help="Run inference on a model",
            usage="sglang generate (--model-path MODEL_PATH_OR_ID --prompt PROMPT) | --config CONFIG_FILE [OPTIONS]",
        )

        generate_parser = add_multimodal_gen_generate_args(generate_parser)

        return cast(FlexibleArgumentParser, generate_parser)

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify the path exists: ls the exact path used in the command
  2. Use an absolute path to avoid cwd-dependent resolution
  3. If inside Docker/CI, confirm the config is copied/mounted into the container
Defensive patterns

Strategy: validation

Validate before calling

import os
if args.config and not os.path.isfile(os.path.abspath(args.config)):
    raise SystemExit(f"config not found: {args.config}")

Prevention

When it happens

Trigger: Running `sglang generate --config /path/that/does/not/exist.yaml` — wrong path, relative path resolved from a different cwd, or the file was never created.

Common situations: Relative paths run from a different working directory, typos in the path, files not synced into a container, '~' not expanded by the shell inside quotes.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/fe820e6c47a12b4e. Report an issue: GitHub.