{"record":{"id":"cd8eb7bb17320f72","repo":"sgl-project/sglang","slug":"minimax-h3-num-steps-must-be-0","errorCode":null,"errorMessage":"MiniMax H3 num_steps must be > 0","messagePattern":"MiniMax H3 num_steps must be > 0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/time_request.py","lineNumber":40,"sourceCode":"    if out_t < 2 or (out_t - 2) % 5 != 0:\n        raise ValueError(\"MiniMax H3 video latent T must be 1 or match 5n+2\")\n    return 17 * ((int(out_t) - 2) // 5) + 5\n\n\ndef minimax_h3_audio_latent_t(duration_seconds: float) -> int:\n    # Rounding happens at the 40 Hz audio latent boundary.\n    return int(round(float(duration_seconds) * 40.0))\n\n\ndef minimax_h3_time_shift_sigmas(\n    *,\n    num_steps: int = 50,\n    shift_scale: float = 6.0,\n) -> list[float]:\n    if shift_scale <= 0:\n        raise ValueError(\"MiniMax H3 shift_scale must be > 0\")\n    if num_steps <= 0:\n        raise ValueError(\"MiniMax H3 num_steps must be > 0\")\n\n    import torch\n\n    # The rectified-flow sigma range is fixed at [1.0, 0.0].\n    base = torch.linspace(\n        1.0,\n        0.0,\n        int(num_steps),\n        device=\"cpu\",\n        dtype=torch.float32,\n    )\n    shifted = float(shift_scale) * base / (1 + (float(shift_scale) - 1) * base)\n    shifted, _ = torch.unique_consecutive(shifted, return_counts=True)\n    # A one-point request is still exactly one point.  Normal serving uses\n    # multiple points, but preserving the requested cardinality keeps\n    # ``num_inference_steps`` the sole schedule-size control.\n    if num_steps > 1 and shifted[-1].item() > 0.0:\n        shifted = torch.cat([shifted, torch.tensor([0.0], dtype=shifted.dtype)])","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/time_request.py#L22-L58","documentation":"The same sigma-computation function requires num_steps > 0, since the timestep ladder needs at least one step. Zero or negative steps cannot produce a linspace and would break the scheduler's cached timestep plans.","triggerScenarios":"Calling minimax_h3_time_shift_sigmas(num_steps=0) or with a negative int; passing sampling params with steps=0/missing from the request so a default of 0 is computed; a plan-generation path (_generate_sigmas_from_plan, _cache_timestep_plans) receiving an unset num_steps.","commonSituations":"CLI/config omitting num_steps while a zero-valued default leaks in; passing steps=0 intending 'auto'; JSON payload using 'num_steps' vs 'steps' key mismatch so the value reads as 0.","solutions":["Set num_steps to a positive integer (typical values 30-50 for MiniMax H3)","Check the key name your payload uses for step count and map it to num_steps","Validate sampling params with validate_sampling_params before calling the pipeline"],"exampleFix":"# before\nminimax_h3_time_shift_sigmas(num_steps=0, shift_scale=6.0)\n\n# after\nminimax_h3_time_shift_sigmas(num_steps=50, shift_scale=6.0)","handlingStrategy":"validation","validationCode":"steps = int(params.get(\"num_steps\", 50))\nif steps <= 0:\n    raise ValueError(\"num_steps must be > 0\")\nsigmas = minimax_h3_time_shift_sigmas(num_steps=steps, shift_scale=shift_scale)","typeGuard":"def is_valid_num_steps(x: Any) -> bool:\n    return isinstance(x, int) and not isinstance(x, bool) and x > 0","tryCatchPattern":"catch ValueError and default num_steps to 50 with a logged warning","preventionTips":["Map any 'steps' request key to num_steps explicitly","Reject zero-valued step counts at the API boundary"],"tags":["minimax-h3","sampling","num-steps","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}