{"record":{"id":"3977e6cb3f005cc1","repo":"sgl-project/sglang","slug":"unknown-stop-criteria-self-stop-criteria","errorCode":null,"errorMessage":"Unknown stop criteria: {self.stop_criteria}","messagePattern":"Unknown stop criteria: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/debug_utils/schedule_simulator/simulator.py","lineNumber":74,"sourceCode":"            step_records.extend(\n                gpu.get_step_record(self.step) for gpu in self.gpu_states\n            )\n            self._log_step()\n            self._record_metrics()\n            self.step += 1\n\n        return SimulationResult(step_records=step_records, summary=self._get_summary())\n\n    def _should_stop(self) -> bool:\n        if self.max_steps is not None and self.step >= self.max_steps:\n            return True\n        if self.stop_criteria == \"exist_no_pending\":\n            return any(not gpu.pending_requests for gpu in self.gpu_states)\n        if self.stop_criteria == \"all_done\":\n            return not any(\n                gpu.pending_requests or gpu.running_requests for gpu in self.gpu_states\n            )\n        raise ValueError(f\"Unknown stop criteria: {self.stop_criteria}\")\n\n    def _route_requests(self, incoming_requests: List[SimRequest]) -> None:\n        for req in incoming_requests:\n            gpu_id = self.router.route(req)\n            if gpu_id < self.num_gpus_per_engine:\n                self.gpu_states[gpu_id].pending_requests.append(req)\n\n    def _schedule_all_gpus(self) -> None:\n        for gpu in self.gpu_states:\n            self.scheduler.schedule(gpu)\n            assert gpu.is_valid(), (\n                f\"GPU{gpu.gpu_id} invalid after scheduling \"\n                f\"({gpu.total_seq_len()=}, {gpu.max_total_tokens=})\"\n            )\n\n    def _execute_step(self) -> None:\n        for gpu in self.gpu_states:\n            gpu.execute_step()","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/debug_utils/schedule_simulator/simulator.py#L56-L92","documentation":"Raised by Simulator._should_stop when the configured stop_criteria string matches neither 'exist_no_pending' nor 'all_done'. The simulator loop calls _should_stop each tick to decide termination; an unrecognized criteria means the simulation can never terminate correctly, so it fails fast instead of looping forever.","triggerScenarios":"Constructing Simulator(stop_criteria='...') or passing a CLI/config value other than exist_no_pending / all_done, then calling simulator.run().","commonSituations":"Typos in config files or CLI args ('alldone', 'all-done'); version skew where a criteria name was renamed; hand-rolled scripts constructing the Simulator directly.","solutions":["Set stop_criteria to 'exist_no_pending' or 'all_done' exactly","Check for hyphens vs underscores and casing typos in the config","If constructing Simulator programmatically, assert the value against the two literals before run()"],"exampleFix":"# before\nsim = Simulator(..., stop_criteria='all-done')\n\n# after\nsim = Simulator(..., stop_criteria='all_done')","handlingStrategy":"validation","validationCode":"VALID_STOP = {'exist_no_pending', 'all_done'}\nif sim_config.stop_criteria not in VALID_STOP:\n    raise ConfigError(f'stop_criteria must be one of {sorted(VALID_STOP)}')","typeGuard":"def is_valid_stop_criteria(value: str) -> bool:\n    return value in ('exist_no_pending', 'all_done')","tryCatchPattern":"try:\n    sim.run()\nexcept ValueError as e:\n    if 'Unknown stop criteria' in str(e):\n        fix_config_and_retry()\n    else:\n        raise","preventionTips":["Centralize simulator config validation before run()","Prefer an Enum for stop criteria in surrounding code","Use underscores, never hyphens, in criteria names"],"tags":["configuration","simulation","schedule-simulator","sglang"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}