{"record":{"id":"bc2dfd862b8ef05b","repo":"sgl-project/sglang","slug":"invalid-filter-apply-order-filter-apply-order","errorCode":null,"errorMessage":"Invalid filter_apply_order: {filter_apply_order}","messagePattern":"Invalid filter_apply_order: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/aot/python/sgl_kernel/musa.py","lineNumber":314,"sourceCode":"            renorm_probs,\n            top_p,\n            indices,\n            deterministic,\n            generator=generator,\n            check_nan=check_nan,\n        )\n    if filter_apply_order == \"joint\":\n        if check_nan and torch.any(torch.isnan(probs)):\n            raise ValueError(\"Input probs contains NaN.\")\n        return _top_k_top_p_sampling_from_probs_internal(\n            probs,\n            indices,\n            *_to_tensor_scalar_tuple(top_k),\n            *_to_tensor_scalar_tuple(top_p),\n            deterministic,\n            generator,\n        )\n    raise ValueError(f\"Invalid filter_apply_order: {filter_apply_order}\")\n\n\ndef _min_p_sampling_from_probs_internal(\n    probs: torch.Tensor,\n    indices: Optional[torch.Tensor],\n    maybe_min_p_arr: Optional[torch.Tensor],\n    min_p_val: float,\n    deterministic: bool,\n    generator: Optional[torch.Generator],\n) -> torch.Tensor:\n    device = probs.device\n    probs = probs.float()\n    maybe_min_p_arr = maybe_min_p_arr.float() if maybe_min_p_arr is not None else None\n    samples = torch.empty(probs.size(0), dtype=torch.int32, device=device)\n    torch.ops.sgl_kernel.min_p_sampling_from_probs.default(\n        probs,\n        samples,\n        indices,","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/aot/python/sgl_kernel/musa.py#L296-L332","documentation":"top_k_top_p_sampling_from_probs dispatches on a filter_apply_order string that must be exactly 'top_k_first' or 'joint'. Any other value (typo, wrong case, None) falls through both branches and raises.","triggerScenarios":"Passing filter_apply_order='topk_first', 'top-k-first', 'both', 'sequential', None, or any string other than the two supported literals.","commonSituations":"Copy-pasted configs from other sampling APIs, renamed arguments after a version change, or dynamic construction of the order string.","solutions":["Use exactly 'top_k_first' or 'joint'","If constructing dynamically, validate/normalize against {'top_k_first','joint'} before the call","Pin the sgl-kernel version and check its docstring for the accepted values"],"exampleFix":"# before\nsampled = top_k_top_p_sampling_from_probs(p, k, pp, filter_apply_order='topk_first')\n# after\nsampled = top_k_top_p_sampling_from_probs(p, k, pp, filter_apply_order='top_k_first')","handlingStrategy":"validation","validationCode":"if filter_apply_order not in ('top_k_first','joint'): raise ValueError(f'bad order {filter_apply_order!r}')","typeGuard":"def is_valid_order(s): return s in ('top_k_first','joint')","tryCatchPattern":null,"preventionTips":["Literal-type the parameter in wrappers","Unit-test all accepted values"],"tags":["musa","sampling","invalid-argument","enum-value"],"backgroundTag":"invalid-enum-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}