{"record":{"id":"707de45a9d1299fb","repo":"sgl-project/sglang","slug":"minimax-h3-shift-scale-must-be-0","errorCode":null,"errorMessage":"MiniMax H3 shift_scale must be > 0","messagePattern":"MiniMax H3 shift_scale 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":38,"sourceCode":"    if out_t == 1:\n        return 1\n    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.","sourceCodeStart":20,"sourceCodeEnd":56,"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#L20-L56","documentation":"minimax_h3_time_shift_sigmas computes rectified-flow sigma timesteps for MiniMax H3 and requires a positive shift_scale (default 6.0). Non-positive shift_scale would produce degenerate sigmas, so it fails fast before touching torch.","triggerScenarios":"Calling minimax_h3_time_shift_sigmas(shift_scale=0) or with a negative value; or a sampling-params/config path that reads shift_scale from user settings without validating, feeding it into _generate_sigmas_from_plan / _cache_timestep_plans.","commonSituations":"Setting --shift-scale 0 in CLI flags thinking it disables shifting; YAML config with shift_scale: 0.0 or a negative typo; programmatically deriving shift_scale from another parameter that can go non-positive.","solutions":["Use a positive shift_scale (the default 6.0 is standard for MiniMax H3)","If you intended fewer/less aggressive shift steps, tune shift_scale upward/downward but keep it > 0","Validate sampling params via validate_sampling_params before submitting the request"],"exampleFix":"# before\nminimax_h3_time_shift_sigmas(num_steps=50, shift_scale=0)\n\n# after\nminimax_h3_time_shift_sigmas(num_steps=50, shift_scale=6.0)","handlingStrategy":"validation","validationCode":"shift_scale = float(params.get(\"shift_scale\", 6.0))\nif shift_scale <= 0:\n    raise ValueError(\"shift_scale must be > 0\")\nsigmas = minimax_h3_time_shift_sigmas(num_steps=steps, shift_scale=shift_scale)","typeGuard":"def is_valid_shift_scale(x: Any) -> bool:\n    return isinstance(x, (int, float)) and x > 0","tryCatchPattern":"catch ValueError and fall back to the default shift_scale=6.0 with a warning","preventionTips":["Clamp/validate sampling params at request intake","Don't use 0 to mean 'disabled' for shift_scale"],"tags":["minimax-h3","sampling","shift-scale","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}