{"record":{"id":"24d0f785cab57add","repo":"sgl-project/sglang","slug":"num-inference-steps-must-be-at-least-2","errorCode":null,"errorMessage":"--num-inference-steps must be at least 2","messagePattern":"--num-inference-steps must be at least 2","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/tools/build_minimax_h3_adaln_cache.py","lineNumber":153,"sourceCode":"        proj_out_bias,\n    )\n\n\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(","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/tools/build_minimax_h3_adaln_cache.py#L135-L171","documentation":"The MiniMax H3 AdaLN cache builder validates that --num-inference-steps is at least 2 unless an explicit --timesteps schedule overrides it. Fewer steps make the cached timestep plan degenerate.","triggerScenarios":"Running build_minimax_h3_adaln_cache.py with --num-inference-steps 0 or 1 and no --timesteps argument.","commonSituations":"Attempting to precompute a single-step cache by passing 1; copy-pasting a config tuned for a different scheduler.","solutions":["Pass --num-inference-steps >= 2","Or supply an explicit --timesteps schedule if you truly need a custom plan"],"exampleFix":"# before\n--num-inference-steps 1\n# after\n--num-inference-steps 2","handlingStrategy":"validation","validationCode":"if args.num_inference_steps is not None and args.num_inference_steps < 2 and args.timesteps is None:\n    raise SystemExit(\"num-inference-steps must be >= 2 (or pass --timesteps)\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add argparse type/range checks for numeric step arguments"],"tags":["cli","validation","diffusion"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}