{
  "id": "cuda/triton-ptx-assembly-failed",
  "signature": "RuntimeError: Triton Error [CUDA]: PTX assembly failed: ptxas fatal   : Ptx assembly aborted due to errors",
  "signature_zh": "运行时错误：Triton 错误 [CUDA]：PTX 汇编失败：ptxas 致命错误：由于错误而中止 PTX 汇编",
  "regex": "Triton Error.*PTX assembly failed.*ptxas fatal",
  "domain": "cuda",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "The Triton JIT compiler generated PTX code that cannot be assembled by ptxas, often due to register spilling exceeding the limit, unsupported PTX instructions for the target architecture, or a bug in the Triton compiler IR generation.",
  "root_cause_type": "generic",
  "root_cause_zh": "Triton JIT 编译器生成的 PTX 代码无法被 ptxas 汇编，通常是由于寄存器溢出超过限制、目标架构不支持的 PTX 指令或 Triton 编译器 IR 生成中的错误。",
  "versions": [
    {
      "version": "Triton 2.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Triton 2.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyTorch 2.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstalling Triton from source without changing compiler flags",
      "why_fails": "The error is not due to a missing Triton installation but to a PTX generation issue in the specific kernel; reinstalling does not fix the kernel code.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting `TRITON_PTXAS_PATH` to a different ptxas binary from a newer CUDA version",
      "why_fails": "While a newer ptxas may support more instructions, the root cause is often register spilling or IR bugs; a newer ptxas may still fail with the same PTX.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Reducing the number of blocks per grid arbitrarily",
      "why_fails": "The error is about PTX assembly, not grid launch configuration; changing grid size does not affect the PTX code generated.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Simplify the Triton kernel by reducing the number of operations per program, especially avoiding large loops or heavy use of `tl.where` and `tl.sum`. Break the kernel into multiple smaller kernels and fuse them manually.",
      "success_rate": 0.8,
      "how": "Simplify the Triton kernel by reducing the number of operations per program, especially avoiding large loops or heavy use of `tl.where` and `tl.sum`. Break the kernel into multiple smaller kernels and fuse them manually.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set the environment variable `TRITON_MAX_REGISTERS=0` to disable register allocation hints and let ptxas manage registers automatically, which can reduce spilling. Example: `export TRITON_MAX_REGISTERS=0` before running the script.",
      "success_rate": 0.7,
      "how": "Set the environment variable `TRITON_MAX_REGISTERS=0` to disable register allocation hints and let ptxas manage registers automatically, which can reduce spilling. Example: `export TRITON_MAX_REGISTERS=0` before running the script.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Upgrade Triton to the latest nightly version (`pip install -U --pre triton`) which may contain fixes for PTX generation bugs. If using PyTorch, ensure it is built against a compatible Triton version.",
      "success_rate": 0.75,
      "how": "Upgrade Triton to the latest nightly version (`pip install -U --pre triton`) which may contain fixes for PTX generation bugs. If using PyTorch, ensure it is built against a compatible Triton version.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过减少每个程序的操作数来简化 Triton 内核，特别是避免大型循环或大量使用 `tl.where` 和 `tl.sum`。将内核拆分为多个较小的内核并手动融合。",
    "设置环境变量 `TRITON_MAX_REGISTERS=0` 以禁用寄存器分配提示，让 ptxas 自动管理寄存器，这可以减少溢出。示例：在运行脚本前执行 `export TRITON_MAX_REGISTERS=0`。",
    "将 Triton 升级到最新的 nightly 版本（`pip install -U --pre triton`），其中可能包含 PTX 生成错误的修复。如果使用 PyTorch，确保其构建与兼容的 Triton 版本对应。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://triton-lang.org/main/getting-started/troubleshooting.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2024-01-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2025-05-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}