{"record":{"id":"f8e78bf785c671d9","repo":"sgl-project/sglang","slug":"failed-to-cancel-len-errors-vmm-transport-slice","errorCode":null,"errorMessage":"Failed to cancel {len(errors)} VMM transport slice(s)","messagePattern":"Failed to cancel (.+?) VMM transport slice\\(s\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/cuda_vmm_transport_utils.py","lineNumber":1056,"sourceCode":"            return\n\n        errors = []\n        for item in mm_items:\n            fields = (\n                (\"feature\", item.feature),\n                (\"precomputed_embeddings\", item.precomputed_embeddings),\n            )\n            for field, proxy in fields:\n                if not isinstance(proxy, CudaVmmTensorTransportProxy):\n                    continue\n                try:\n                    self.pool.cancel_proxy(proxy)\n                except BaseException as error:\n                    errors.append(error)\n                finally:\n                    setattr(item, field, None)\n        if errors:\n            raise RuntimeError(\n                f\"Failed to cancel {len(errors)} VMM transport slice(s)\"\n            ) from errors[0]\n\n    def shutdown(self) -> None:\n        if self.pool is None:\n            return\n        self.pool.shutdown()\n","sourceCodeStart":1038,"sourceCodeEnd":1064,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/cuda_vmm_transport_utils.py#L1038-L1064","documentation":"cancel_for_dispatch cancels every wrapped VMM slice for outgoing items; if any individual pool.cancel_proxy call raises, the errors are collected and this aggregate RuntimeError is raised chained to the first failure. The commonest root cause is the per-slice 'no occupied slice at control offset' error (double release) or pool shutdown races.","triggerScenarios":"Any single slice cancellation failing during prepare_for_dispatch/_send_one_request/_send_batch_request — e.g. an item whose proxy was already cancelled or whose chunk was recycled; cancelling after pool shutdown began.","commonSituations":"Retry/error paths that re-dispatch items whose slices were already released; concurrent cancellation from multiple senders.","solutions":["Inspect __cause__ of the raised error to identify the underlying per-slice failure and fix that (usually double-cancel)","Make cancellation idempotent: null the field before/after cancel (the finally already sets it to None) so re-dispatch cannot re-cancel","Add a released flag on proxies to short-circuit repeat cancels"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    transport.cancel_for_dispatch(items)\nexcept RuntimeError as e:\n    if \"Failed to cancel\" in str(e):\n        log.warning(\"partial VMM cancel: %s\", e.__cause__)\n        # slices are nulled in finally; safe to proceed or rebuild","preventionTips":["Null wrapped fields right after cancel so re-dispatch can't double-cancel","Inspect __cause__ to find the underlying per-slice failure"],"tags":["cuda","vmm","aggregate-error","dispatch"],"backgroundTag":"resource-cleanup-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}