{"record":{"id":"4fb2bbab2dd79dc4","repo":"sgl-project/sglang","slug":"mode-args-mode-requires-mode-variant","errorCode":null,"errorMessage":"--mode {args.mode} requires {mode_variant}","messagePattern":"--mode (.+?) requires (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/tools/build_minimax_h3_adaln_cache.py","lineNumber":156,"sourceCode":"\ndef _load_tensor(\n    name: str,\n    *,\n    weight_map: dict[str, str],\n    files: dict[str, Any],\n    device: torch.device,\n) -> torch.Tensor:\n    tensor_file = files[weight_map[name]]\n    return tensor_file.get_tensor(name).to(device)\n\n\ndef main() -> None:\n    args = _parse_args()\n    if args.num_inference_steps < 2 and args.timesteps is None:\n        raise ValueError(\"--num-inference-steps must be at least 2\")\n    mode_variant = _MODE_VARIANTS[args.mode]\n    if args.model_variant != mode_variant:\n        raise ValueError(f\"--mode {args.mode} requires {mode_variant}\")\n    device = torch.device(args.device)\n    if device.type != \"cuda\" or not torch.cuda.is_available():\n        raise ValueError(\"MiniMax H3 AdaLN cache must be built on CUDA\")\n\n    index_path = args.transformer_path / \"model.safetensors.index.json\"\n    with index_path.open() as f:\n        weight_map = json.load(f)[\"weight_map\"]\n\n    plans = _cache_timestep_plans(args)\n    if not plans or any(plan.numel() == 0 for plan in plans):\n        raise ValueError(\"AdaLN cache must cover at least one timestep plan\")\n    max_plan_length = max(plan.numel() for plan in plans)\n    plan_timesteps = torch.zeros((len(plans), max_plan_length), dtype=torch.float32)\n    plan_lengths = torch.tensor([plan.numel() for plan in plans], dtype=torch.int64)\n    block_params = torch.empty(\n        (len(plans), max_plan_length, _NUM_BLOCKS, _BLOCK_PARAM_WIDTH),\n        dtype=torch.bfloat16,\n    )","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/tools/build_minimax_h3_adaln_cache.py#L138-L174","documentation":"Each --mode of the cache builder is only valid for one specific --model-variant (looked up in _MODE_VARIANTS); passing a mismatched pair is rejected early before any heavy work.","triggerScenarios":"E.g. selecting --mode for the text-only variant while --model-variant points at the multimodal checkpoint, or vice versa.","commonSituations":"Reusing a command line from a sibling model; mode/variant names drifting between versions of the tool.","solutions":["Check _MODE_VARIANTS in the tool to see which variant the mode requires","Set --model-variant to the value named in the error message","Or switch --mode to one compatible with your variant"],"exampleFix":"# before\n--mode video --model-variant minimax-h3-base\n# after\n--mode video --model-variant minimax-h3-video","handlingStrategy":"validation","validationCode":"if _MODE_VARIANTS[args.mode] != args.model_variant:\n    raise SystemExit(f\"{args.mode} requires {_MODE_VARIANTS[args.mode]}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Encode mode->variant compatibility in argparse choices or a post-parse check"],"tags":["cli","validation","config-mismatch"],"backgroundTag":"invalid-config-combination","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}