sgl-project/sglang · error · ValueError
Cannot determine processor class for {model_path}
Error message
Cannot determine processor class for {model_path} What it means
When auto-loading the processor class fails, sglang falls back to _build_processor_manually using the processor_class/auto_map entry from preprocessor_config.json; that reference is missing too, so no processor class can be constructed for the model.
Source
Thrown at python/sglang/srt/utils/hf_transformers/processor.py:162
auto_map = getattr(config, "auto_map", None) or {}
proc_ref = auto_map.get("AutoProcessor")
if not proc_ref:
try:
pp_file = _resolve_local_or_cached_file(
model_path, "preprocessor_config.json", revision
)
with open(pp_file) as f:
pp_auto_map = json.load(f).get("auto_map", {})
proc_ref = pp_auto_map.get("AutoProcessor")
except (OSError, json.JSONDecodeError, ValueError) as e:
logger.warning(
"_build_processor_manually: could not read preprocessor_config.json "
"for %s: %s",
model_path,
e,
)
if not proc_ref:
raise ValueError(f"Cannot determine processor class for {model_path}")
proc_cls = get_class_from_dynamic_module(
proc_ref, model_path, code_revision=revision
)
# Load sub-components individually (these succeed)
tokenizer = AutoTokenizer.from_pretrained(
model_path, trust_remote_code=trust_remote_code, revision=revision
)
init_kwargs = {"tokenizer": tokenizer}
if "image_processor" in getattr(proc_cls, "attributes", []):
try:
init_kwargs["image_processor"] = AutoImageProcessor.from_pretrained(
model_path, trust_remote_code=trust_remote_code, revision=revision
)
except (ImportError, OSError, ValueError) as e:
raise RuntimeError(View on GitHub (pinned to 0132848349)
Solutions
- Ensure preprocessor_config.json contains a processor_class or auto_map entry pointing at the processor implementation
- Re-download the model to restore missing files
- Pass trust_remote_code=True if the model ships remote code
Defensive patterns
Strategy: fallback
Validate before calling
import json; pc = json.load(open(Path(model)/'preprocessor_config.json'))
proc_ref = pc.get('auto_map',{}).get('AutoProcessor') or pc.get('processor_class')
if not proc_ref: expect manual-build failure Try / catch
try:
get_processor(model)
except ValueError as e:
if 'Cannot determine processor class' in str(e): re-download model or use transformers AutoProcessor directly Prevention
- Use complete, official multimodal model repos
- Enable trust_remote_code for custom processors
When it happens
Trigger: Loading a multimodal model whose repo lacks both a resolvable auto_map/processor_class in preprocessor_config.json and standard processor files.
Common situations: Partial uploads, custom models missing processor metadata, or trust_remote_code models whose remote processor code path is absent.
Related errors
- Cannot find corresponding multimodal processor registered in
- Required `vision_config.model_type` is not found in hf_confi
- cos/sin shape does not cover image tokens and head_dim
- Unsupported model type: {model_type}
- Unsupported image type: {type(image)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/d535c5ca0542d28d.
Report an issue: GitHub.