{"record":{"id":"ff464fa13ad025cc","repo":"sgl-project/sglang","slug":"source-must-be-timesteps-or-sigmas","errorCode":null,"errorMessage":"source must be 'timesteps' or 'sigmas'","messagePattern":"source must be 'timesteps' or 'sigmas'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py","lineNumber":373,"sourceCode":"            audio_denoising_strength = float(\n                kwargs.get(\"audio_denoising_strength\", 1.0)\n            )\n            visual_mu = kwargs.get(\n                \"visual_exponential_shift_mu\", self.exponential_shift_mu\n            )\n            audio_mu = kwargs.get(\n                \"audio_exponential_shift_mu\", self.exponential_shift_mu\n            )\n\n            def _dual_sigma_shift(pairs: torch.Tensor, *, source: str):\n                if not isinstance(pairs, torch.Tensor):\n                    raise TypeError(\"pairs must be a torch.Tensor\")\n                if pairs.ndim != 2 or pairs.shape[1] != 2:\n                    raise ValueError(\"pairs must be a torch.Tensor of shape [N, 2]\")\n                if pairs.shape[0] == 0:\n                    raise ValueError(\"pairs length must be greater than 0\")\n                if source not in (\"timesteps\", \"sigmas\"):\n                    raise ValueError(\"source must be 'timesteps' or 'sigmas'\")\n\n                num_steps = pairs.shape[0]\n                device = pairs.device\n                dtype = pairs.dtype\n\n                def _build_column(\n                    shift_value: float, denoising_strength: float, mu_override\n                ):\n                    if shift_value <= 0:\n                        raise ValueError(\"shift must be positive\")\n                    if denoising_strength <= 0:\n                        raise ValueError(\"denoising_strength must be positive\")\n\n                    sigma_start = (\n                        self.sigma_min\n                        + (self.sigma_max - self.sigma_min) * denoising_strength\n                    )\n                    if self.extra_one_step:","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py#L355-L391","documentation":"_dual_sigma_shift is keyword-only parametrized by source, which tells it whether the pairs represent timesteps or sigmas (the transform differs). Passing anything other than the literal strings 'timesteps' or 'sigmas' (including None, 'Timesteps', 'sigma', or typos) raises ValueError.","triggerScenarios":"Calling the postprocess / step API with source omitted where no default exists, or passing a variant spelling like 'sigma', 'TIMESTEPS', or an enum. Typically happens when a caller copies code from a different scheduler version whose API used different source names.","commonSituations":"API drift between scheduler versions (renamed or newly required keyword); caller passes None because it doesn't know which representation the pairs use; string constants duplicated across the codebase drifting out of sync.","solutions":["Pass the exact keyword: source=\"timesteps\" if pairs came from the timestep schedule, source=\"sigmas\" if from sigma schedule","Check the scheduler's docstring/constants for the accepted values and use those literals (no uppercase/abbreviations)","Centralize the string in one constant shared with the scheduler to avoid drift","Default explicitly in your wrapper: source = source or 'sigmas' based on which cache you read"],"exampleFix":"# before\nresult = postprocess(pairs, source=\"sigma\")\n\n# after\nresult = postprocess(pairs, source=\"sigmas\")","handlingStrategy":"validation","validationCode":"VALID_SOURCES = (\"timesteps\", \"sigmas\")\nif source not in VALID_SOURCES:\n    raise ValueError(f\"source must be one of {VALID_SOURCES}, got {source!r}\")","typeGuard":"def is_valid_source(s) -> TypeGuard[str]:\n    return s in (\"timesteps\", \"sigmas\")","tryCatchPattern":null,"preventionTips":["Always pass the keyword explicitly: source='sigmas' or source='timesteps'","Centralize the literal strings as constants shared with the scheduler to avoid drift"],"tags":["scheduler","enum-validation","api-misuse","sigma-shift"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}