sgl-project/sglang · error · ValueError

BF16 fallback patterns are enabled, but --base-transformer-d

Error message

BF16 fallback patterns are enabled, but --base-transformer-dir was not provided.

What it means

BF16 fallback patterns (defaults for LTX2 plus any --keep-bf16 patterns) require reading original BF16 weights via --base-transformer-dir; for non-LTX2 exports the tool refuses to proceed without that directory.

Source

Thrown at python/sglang/multimodal_gen/tools/build_modelopt_fp8_transformer.py:595

    is_ltx2_export = _is_ltx2_x0_export(
        config=config,
        source_metadata=source_metadata,
        source_weight_map=source_weight_map_all,
    )
    class_name = config.get("_class_name")
    runtime_name_mapper = _get_runtime_module_name_mapper(
        model_type=model_type, class_name=class_name
    )
    ignore_patterns = list(quant_config.get("ignore", []) or [])
    patterns = list(
        get_default_keep_bf16_patterns(model_type=model_type, class_name=class_name)
    )
    if is_ltx2_export and model_type == "auto":
        patterns.extend(DEFAULT_LTX2_KEEP_BF16_PATTERNS)
    if keep_bf16_patterns:
        patterns.extend(keep_bf16_patterns)
    if patterns and base_dir is None and not is_ltx2_export:
        raise ValueError(
            "BF16 fallback patterns are enabled, but --base-transformer-dir was not provided."
        )

    output_path = Path(output_dir).expanduser().resolve()
    if output_path.exists():
        if not overwrite:
            raise FileExistsError(
                f"Output directory already exists: {output_path}. "
                "Use --overwrite to replace it."
            )
        shutil.rmtree(output_path)
    output_path.mkdir(parents=True, exist_ok=True)

    _copy_non_shard_files(source_dir, str(output_path))

    if is_ltx2_export:
        source_weight_map = {
            name: filename

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass --base-transformer-dir pointing at the original BF16 export (containing transformer/config.json)
  2. Or drop the --keep-bf16* pattern flags if BF16 retention is not needed

Example fix

# before
build_modelopt_fp8_transformer(..., keep_bf16_patterns=["*.bias"])
# after
build_modelopt_fp8_transformer(..., keep_bf16_patterns=["*.bias"], base_transformer_dir="/data/bf16_export")
Defensive patterns

Strategy: validation

Validate before calling

if keep_bf16_patterns and base_transformer_dir is None and not is_ltx2:
    raise SystemExit("BF16 fallback needs --base-transformer-dir")

Prevention

When it happens

Trigger: Running the builder on a non-LTX2 ModelOpt export while BF16 keep-patterns are active (explicitly passed) but --base-transformer-dir is omitted.

Common situations: Copy-pasting an LTX2-oriented command for another model; intending per-pattern BF16 retention but forgetting to supply the BF16 source.

Related errors


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