{
  "id": "cuda/triton-compilation-llvm-crash",
  "signature": "RuntimeError: Triton compilation failed: LLVM ERROR: out of memory when compiling kernel with large shared memory",
  "signature_zh": "运行时错误：Triton编译失败：编译具有大共享内存的内核时LLVM错误：内存不足",
  "regex": "Triton compilation failed.*LLVM ERROR.*out of memory",
  "domain": "cuda",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "Triton JIT compiler invokes LLVM to optimize kernel code, but the kernel uses excessive shared memory (>48KB per block on most GPUs), causing LLVM's memory allocation for register spilling or optimization to exceed available host memory.",
  "root_cause_type": "generic",
  "root_cause_zh": "Triton JIT编译器调用LLVM优化内核代码，但内核使用了过多的共享内存（大多数GPU上超过48KB每块），导致LLVM为寄存器溢出或优化分配的内存超过可用主机内存。",
  "versions": [
    {
      "version": "Triton 2.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "LLVM 18.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyTorch 2.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is not about total system memory but about LLVM's internal allocation limits during compilation; more RAM does not help if the kernel design is flawed.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Caching is unrelated to compilation memory; it only affects reuse of compiled kernels.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce shared memory usage in the Triton kernel: decrease block size or use fewer shared memory allocations. Example: change tl.constexpr BLOCK_SIZE from 128 to 64, and ensure shared memory is not allocated per-thread but per-block.",
      "success_rate": 0.8,
      "how": "Reduce shared memory usage in the Triton kernel: decrease block size or use fewer shared memory allocations. Example: change tl.constexpr BLOCK_SIZE from 128 to 64, and ensure shared memory is not allocated per-thread but per-block.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set environment variable TRITON_MAX_SHARED_MEMORY to a lower value (e.g., 32768 bytes) to force Triton to generate kernels within limits. Command: export TRITON_MAX_SHARED_MEMORY=32768 before running the script.",
      "success_rate": 0.75,
      "how": "Set environment variable TRITON_MAX_SHARED_MEMORY to a lower value (e.g., 32768 bytes) to force Triton to generate kernels within limits. Command: export TRITON_MAX_SHARED_MEMORY=32768 before running the script.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Reduce shared memory usage in the Triton kernel: decrease block size or use fewer shared memory allocations. Example: change tl.constexpr BLOCK_SIZE from 128 to 64, and ensure shared memory is not allocated per-thread but per-block.",
    "Set environment variable TRITON_MAX_SHARED_MEMORY to a lower value (e.g., 32768 bytes) to force Triton to generate kernels within limits. Command: export TRITON_MAX_SHARED_MEMORY=32768 before running the script."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://triton-lang.org/main/python-api/generated/triton.compiler.CompilationError.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.72,
  "resolvable": "true",
  "first_seen": "2025-05-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}