{
  "id": "cuda/stream-order-violation-cuda-graph",
  "signature": "CUDA error: stream-order violation during graph launch (cudaErrorStreamOrderViolation)",
  "signature_zh": "CUDA 错误：图启动期间流顺序违规 (cudaErrorStreamOrderViolation)",
  "regex": "stream-order violation during graph launch",
  "domain": "cuda",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A CUDA graph is launched on a stream that has pending operations from a different stream or graph, violating the implicit ordering constraints when using CUDA graph capturing.",
  "root_cause_type": "generic",
  "root_cause_zh": "CUDA 图在具有来自不同流或图的未决操作的流上启动，违反了使用 CUDA 图捕获时的隐式排序约束。",
  "versions": [
    {
      "version": "CUDA 11.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyTorch 2.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyTorch 2.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is about stream synchronization, not parallelism; adding workers can introduce more streams and worsen the violation.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This removes the performance benefit but does not fix the underlying stream management; the error may reappear if graphs are re-enabled.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all operations on the target stream are synchronized before launching a graph. Use `torch.cuda.synchronize()` or stream synchronization primitives before `cudaGraphLaunch`.",
      "success_rate": 0.85,
      "how": "Ensure all operations on the target stream are synchronized before launching a graph. Use `torch.cuda.synchronize()` or stream synchronization primitives before `cudaGraphLaunch`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Re-capture the graph on a dedicated stream that is not used for other operations, ensuring no cross-stream dependencies.",
      "success_rate": 0.9,
      "how": "Re-capture the graph on a dedicated stream that is not used for other operations, ensuring no cross-stream dependencies.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure all operations on the target stream are synchronized before launching a graph. Use `torch.cuda.synchronize()` or stream synchronization primitives before `cudaGraphLaunch`.",
    "Re-capture the graph on a dedicated stream that is not used for other operations, ensuring no cross-stream dependencies."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cuda-graph-stream-order",
  "official_doc_section": null,
  "error_code": "cudaErrorStreamOrderViolation",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}