{"prompt": "Write a complete Triton 3.7.1 kernel on Blackwell SM12x that **must use** `tl.atomic_and`.\nDefine exact input shapes/dtypes, include @triton.jit, launcher, masks, and torch.allclose test.\n\nContext:\nCategory: Atomic Ops\nAPI: tl.atomic_and\nSymbol: atomic_and (triton.language)", "system": "You are a Triton 3.7.1 GPU kernel expert for Blackwell SM12x. Write complete runnable Python with @triton.jit, launcher, and torch.allclose test. Always end with print(\"SPARKPROOF_TRITON_PASS\") after tests pass.", "task_id": "api_tl_atomic_and", "source": "api_doc", "origin": "api_doc", "category": "kernel_write", "target_api": "tl.atomic_and", "doc_chunk_id": "api_tl_atomic_and", "title": "atomic_and", "split": "train"} {"prompt": "The following Triton 3.7.1 kernel fails or is numerically wrong. Diagnose the bug and return corrected, runnable code with a torch.allclose test. End with: print(\"SPARKPROOF_TRITON_PASS\"). Do NOT pass BLOCK= to the kernel launch when @triton.autotune is used.\n\n```python\nimport torch\nimport triton\nimport triton.language as tl\n\n@triton.autotune(configs=[triton.Config({'BLOCK': 1024}, num_warps=4, num_stages=2), triton.Config({'BLOCK': 2048}, num_warps=8, num_stages=2)], key=['ncols'])\n@triton.jit\ndef softmax_kernel(out_ptr, in_ptr, stride_row, ncols, BLOCK: tl.constexpr):\n row = tl.program_id(0)\n row_in = in_ptr + row * stride_row\n cols = tl.arange(0, BLOCK)\n mask = cols < ncols\n vals = tl.load(row_in + cols)\n vals = vals.to(tl.float32)\n row_max = tl.max(vals, axis=0)\n vals = vals - row_max\n num = tl.exp(vals)\n den = tl.sum(num, axis=0)\n out = num / den\n tl.store(out_ptr + row * stride_row + cols, out)\n\ndef launch_softmax(x: torch.Tensor) -> torch.Tensor:\n rows, cols = x.shape\n out = torch.empty_like(x)\n grid = (rows,)\n softmax_kernel[grid](out, x, x.stride(0), cols)\n return out\n\ndef test_kernel():\n x = torch.randn(8, 1003, device='cuda', dtype=torch.float32)\n out = launch_softmax(x)\n ref = torch.softmax(x, dim=-1)\n assert torch.allclose(out, ref, rtol=0.001, atol=0.001)\ntest_kernel()\nprint('SPARKPROOF_TRITON_PASS')\n\n```", "system": "You are a Triton 3.7.1 GPU kernel expert for Blackwell SM12x. Write complete runnable Python with @triton.jit, launcher, and torch.allclose test. Always end with print(\"SPARKPROOF_TRITON_PASS\") after tests pass.", "task_id": "mutate_softmax_row_strip_boundary_mask", "source": "mutation", "origin": "mutation", "category": "debugging", "ground_truth_code": "\nimport torch\nimport triton\nimport triton.language as tl\n\n\n@triton.autotune(\n configs=[\n triton.Config({\"BLOCK\": 1024}, num_warps=4, num_stages=2),\n triton.Config({\"BLOCK\": 2048}, num_warps=8, num_stages=2),\n ],\n key=[\"ncols\"],\n)\n@triton.jit\ndef softmax_kernel(out_ptr, in_ptr, stride_row, ncols, BLOCK: tl.constexpr):\n row = tl.program_id(0)\n row_in = in_ptr + row * stride_row\n cols = tl.arange(0, BLOCK)\n mask = cols < ncols\n vals = tl.load(row_in + cols, mask=mask, other=-float(\"inf\"))\n vals = vals.to(tl.float32)\n row_max = tl.max(vals, axis=0)\n vals = vals - row_max\n num = tl.exp(vals)\n den = tl.sum(num, axis=0)\n out = num / den\n tl.store(out_ptr + row * stride_row + cols, out, mask=mask)\n\n\ndef launch_softmax(x: torch.Tensor) -> torch.Tensor:\n rows, cols = x.shape\n out = torch.empty_like(x)\n grid = (rows,)\n softmax_kernel[grid](out, x, x.stride(0), cols)\n return out\n\n\ndef test_kernel():\n x = torch.randn(8, 1003, device=\"cuda\", dtype=torch.float32)\n out = launch_softmax(x)\n ref = torch.softmax(x, dim=-1)\n assert torch.allclose(out, ref, rtol=1e-3, atol=1e-3)\n\n\ntest_kernel()\nprint(\"SPARKPROOF_TRITON_PASS\")\n", "broken_code": "import torch\nimport triton\nimport triton.language as tl\n\n@triton.autotune(configs=[triton.Config({'BLOCK': 1024}, num_warps=4, num_stages=2), triton.Config({'BLOCK': 2048}, num_warps=8, num_stages=2)], key=['ncols'])\n@triton.jit\ndef softmax_kernel(out_ptr, in_ptr, stride_row, ncols, BLOCK: tl.constexpr):\n row = tl.program_id(0)\n row_in = in_ptr + row * stride_row\n cols = tl.arange(0, BLOCK)\n mask = cols < ncols\n vals = tl.load(row_in + cols)\n vals = vals.to(tl.float32)\n row_max = tl.max(vals, axis=0)\n vals = vals - row_max\n num = tl.exp(vals)\n den = tl.sum(num, axis=0)\n out = num / den\n tl.store(out_ptr + row * stride_row + cols, out)\n\ndef launch_softmax(x: torch.Tensor) -> torch.Tensor:\n rows, cols = x.shape\n out = torch.empty_like(x)\n grid = (rows,)\n softmax_kernel[grid](out, x, x.stride(0), cols)\n return out\n\ndef test_kernel():\n x = torch.randn(8, 1003, device='cuda', dtype=torch.float32)\n out = launch_softmax(x)\n ref = torch.softmax(x, dim=-1)\n assert torch.allclose(out, ref, rtol=0.001, atol=0.001)\ntest_kernel()\nprint('SPARKPROOF_TRITON_PASS')\n", "mutation_reason": "Removed boundary masks from tl.load/tl.store.", "task_family": "softmax_row", "split": "train"}