[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FB779YQK3DAFJBMJF56XS7":3,"skill-same:01M7FB779YQK3DAFJBMJF56XS7":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7FB779YQK3DAFJBMJF56XS7","passnet-triton-opt",null,"Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block\u002Fgrid\u002Fwarp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fpassnet-triton-opt\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: passnet-triton-opt\ndescription: >\n  Make a single PassNet Triton kernel fast AND numerically faithful: performance model\n  (when a replacement can win at all), block\u002Fgrid\u002Fwarp tuning, autotune policy, launch\n  overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a\n  pass matches and is correct but speedup below expected, or when correctness fails by small\n  numeric margins.\n---\n\n## 1. Performance model — know if a win is even possible\n\nMeasured costs (A100, torch 2.7.1 \u002F triton 3.3.1; same order of magnitude on the eval box):\n\n| component | cost per call |\n|---|---|\n| dynamo guards + FX graph interpretation + dispatch wrapper | ~25–45 µs on a 3-op graph; grows with node count (~150–230 µs seen on a 13-node graph) — calibrate from your first eval |\n| Triton kernel Python launch (`kernel[grid](...)`) | ~19 µs each |\n| `torch.empty_like` \u002F `torch.empty` | ~2–3 µs each |\n| each aten op you REMOVED from the graph | +5–25 µs back (small ops) or its real kernel time |\n\nSo per variant: `compiled_e2e ≈ eager_e2e − Σ(absorbed aten µs) + tax + Σ(your kernels µs)`.\nRules of thumb:\n- Whole eager forward \u003C ~150 µs and you can absorb ≤2 cheap ops → ceiling \u003C 1. Ship a\n  safe correct pass, accept ~0.8–0.95, spend your time on another bottleneck.\n- Small or narrow fusions can match and be numerically correct yet still lose e2e when\n  launch\u002Fframework overhead exceeds the eager work removed.\n- Layout-only, view\u002Freshape-only, split\u002Ffanout, tiny activation, and small reduction-like\n  kernels can also lose even when their local kernel is correct: eager may treat the work\n  as metadata, use a vendor-tuned primitive, or pay less framework overhead than the\n  compiled path. Treat these as floor\u002Fdownside caps unless they bridge substantial compute\n  or remove an actual materialization.\n- The lever is **ops absorbed per launch** (and avoiding extra launches\u002Fallocs), not\n  shaving 10% off an already-tiny kernel.\n- Big tensors (≥ a few MB; kernel ≥ 100 µs): overhead noise vanishes; now memory traffic\n  is everything — a clean fused kernel that reads each input once and writes once usually\n  beats the multi-pass eager chain by the ratio of memory passes saved.\n- **The biggest wins can be ALGORITHMIC, not tuning** — but the default for a heavy conv\u002Fmatmul\n  is still \"leave it in the library, fuse its tail,\" because the library is near-optimal inside\n  the regime it tuned for. The clearest case where a rewrite beats it: a **non-overlapping\n  convolution** (`stride == kernel_size`, `kernel_size > 1`, `padding == 0`) is a dense patch\n  matmul while cuDNN runs a heavier general im2col path — a `tl.dot` patch-gather kernel\n  (kernel-templates §13) can win big. It usually does NOT pay to rewrite a **1×1 conv** (already\n  a cuBLAS-optimal pointwise GEMM), an **overlapping conv** (im2col blows up memory), a\n  **depthwise\u002Fgrouped conv**, or a **general dense matmul** — those are vendor sweet spots.\n  Treat this as a prior, not a ban: the completed eval decides. Pursue any rewrite only after a\n  floor is banked, and don't dismiss the non-overlapping case as \"cuDNN, unbeatable\" without\n  checking `stride == kernel_size`.\n- For large cat\u002Fstack\u002Fgather-style outputs, one giant kernel is not automatically best if it\n  needs heavy branching or irregular index logic. A small fixed number of simple kernels can\n  be faster and more timing-stable when each launch writes a large contiguous region. Compare\n  sequential micro-bench signals, then trust the completed evaluation.\n- Repeated round evidence favors long memory-bound elementwise and broadcast-affine chains\n  when one legal single-output kernel absorbs multiple affine, activation, residual, layout,\n  or normalization consumers. These are the first places to spend tuning effort after a\n  correct floor because saved memory passes can amortize wrapper and launch overhead.\n- Repeated completed evaluations also favor normalization-affine compute prefixes and\n  concat-to-normalization-affine prefixes when they remove large memory passes in one launch.\n  Treat kernel layout choices for concat branches as workload-dependent: a broad prefix can\n  win strongly, but small\u002Fbranchy cases or attempts to absorb extra producers can regress in\n  score, correctness, or timing stability. Keep the best completed floor\u002Fprefix state and\n  revert completed regressions instead of stacking more small kernels or sweeping blindly.\n- Reduction-only regions and vendor-tail replacements still need completed-evaluation proof.\n  A correct reduction kernel, a small tail behind a vendor op, or a region that replaces a\n  vendor-tuned primitive can remain below eager even when local kernel timing looks plausible.\n  Use the completed eval to decide keep\u002Frevert; do not infer success from the triage family.\n- Compare `[Speedup][gpu]` vs `[Speedup][e2e]` in the eval log: gpu≈e2e&both\u003C1 → on-stream\n  gaps\u002Flaunches dominate (absorb more ops \u002F fewer launches); gpu>1 but e2e\u003C1 → host-side\n  overhead (reduce launches, drop autotune key churn, simplify wrapper Python).\n- Only a completed evaluation can prove the final overhead-bound conclusion. Local\n  micro-bench and `check_pattern --bench` are pre-flight signals; if the completed eval is\n  matched and correct but below eager for the maximal legal region, stop or revert instead\n  of sweeping launch-bound tuning knobs.\n\n## 2. Kernel quality checklist (in order of impact)\n\n1. **One read per input element, one write per output element.** No multi-launch chains\n   when one kernel can hold the chain in registers. Exception: for heterogeneous\n   direct-output cat\u002Fstack branches, compare a branch-heavy single kernel with grouped\n   launches; choose by measured stable e2e speed, not by launch count alone.\n2. **Contiguous innermost access**: thread `offs` should walk the last (stride-1) dim.\n   For strided\u002Fpermuted inputs pass strides; never `.contiguous()` (poison-illegal) —\n   absorbing the transpose INTO the index math is free.\n3. **Block sizing**: elementwise → BLOCK 1024 (n ≥ 1M: 2048, num_warps=8). Row kernels →\n   `BLOCK_N = next_power_of_2(N)`, and start with **num_warps=4** — more warps on small\n   rows HURTS (measured: 512-elem rows, warps=8 was 1.8× slower than warps=4). If\n   N > 16384 switch to a looped accumulation (template 6 in kernel-templates).\n   For tiny rows (≤1024 elems), SWEEP rows-per-program ∈ {1, 2, 4, 8} (2D tile) — the\n   winner is shape-dependent (measured 1.45× for ROWS=4 at D=512\u002F131k rows, but ROWS=1\n   best on a 768-wide LayerNorm); never assume, always micro-bench (§5).\n4. **Grid**: prefer 1D `cdiv(n, BLOCK)`; for row kernels one program per row is fine up\n   to ~256k rows. Avoid grids of 1–4 programs on big inputs (underutilization) — split.\n5. **num_stages**: only matters for `tl.dot`\u002Flooped kernels (3–4); elementwise ignore.\n6. **Avoid recompilation churn**: every distinct `tl.constexpr` value (incl. BLOCK chosen\n   from shape) compiles a new binary during warmup. 2–3 specializations fine; per-shape\n   formulas over 100-variant samples → timeout risk. Derive constexprs from a small fixed\n   set (e.g. BLOCK_N = next_pow2 clamped to {128, 512, 1024, 4096}).\n7. **Autotune policy**: `@triton.autotune` is legal and runs during the untimed warmup\n   (poison-safe). Use ≤4–6 configs, `key=['N']`-style coarse keys. SKIP autotune when the\n   sample has many graph variants (tuning cost × variants × 600 s timeout) or when the\n   kernel is launch-bound anyway. A hand-picked config from one local micro-benchmark is\n   usually within 5%.\n8. **Scalar args beat tensor args**: precompute `n`, `C`, `HW`, strides in the wrapper\n   (metadata access is poison-legal) — never load shape info from tensors in-kernel.\n9. **Reduce wrapper Python**: no dict lookups in hot path beyond the route `if`; compute\n   grid inline; allocate with `torch.empty` (not zeros — don't pay a memset you'll\n   overwrite).\n\n## 3. Numeric fidelity — passing t=-5 baseline tolerances\n\nBaselines: fp32 rtol 1.3e-6\u002Fatol 1e-5 (tight — mirror eager's algorithm), fp16 rtol 1e-3,\nbf16 rtol 1.6e-2 (loose). The same kernel must satisfy ALL dtype variants.\n\nRecipes (these match aten's CUDA implementations):\n- **Always compute in fp32** (`.to(tl.float32)` after load), store with\n  `.to(out_ptr.dtype.element_ty)`. For fp16\u002Fbf16 inputs this reproduces aten (which also\n  accumulates in fp32) to ≤1 ulp.\n- Reductions: `tl.sum`\u002F`tl.max` over a row in one block ≈ aten's order closely enough for\n  fp32 rtol 1.3e-6 at typical sizes (N ≤ 16k). For looped accumulation keep ONE fp32\n  accumulator (don't reorder into multiple partial schemes unnecessarily).\n- softmax: subtract row max (aten does), exp, divide by sum. Don't use exp2 shortcuts on\n  fp32 variants.\n- layer_norm\u002Fbatch_norm: biased variance (÷N), `1\u002Fsqrt(var+eps)` in fp32, then scale\u002Fshift.\n- mean: `sum\u002FN` (single division at the end, not running mean).\n- GELU exact: `0.5x(1+erf(x\u002F√2))` via `tl.math.erf`; tanh GELU only when model.py says\n  `approximate='tanh'`.\n- sigmoid\u002Fsilu: `1\u002F(1+exp(-x))` fp32 — fine at all baselines.\n- `x.pow(2)` → `x*x`; `torch.rsqrt` → `1.0\u002Ftl.sqrt` (matches aten rsqrt within 1 ulp; if\n  a strict fp32 variant complains, try `tl.math.rsqrt`).\n- Integer\u002Fbool tensors: compare with `torch.equal` (atol\u002Frtol=0 conceptually) — your\n  kernel must be EXACT (indices, masks, argmax-style ops: replicate tie-breaking by\n  first-occurrence).\n- Output dtype must equal eager's per output ([Datatype] check), including intermediate\n  `.to(torch.float32)` nodes you absorbed — store in the dtype eager would have at the\n  region's output.\n\nDiagnosing accuracy failures from eval logs: `[Correctness][max_diff]` magnitude vs the\ntable above (parse_eval_log.py does this) —\n- max_diff ~1e-3·|values| on fp16 only → fp16 rounding mismatch: ensure fp32 internal math.\n- fails ONLY fp32 variants → algorithmic mismatch (reduction order, formula) — mirror\n  aten's exact sequence.\n- max_diff huge (≥1) → indexing\u002Fmasking bug, not numerics: check strides, `other=` values\n  contaminating reductions (use `-inf` for max, `0` for sum, and mask BEFORE divide),\n  uninitialized output regions (mask coverage), `offs` overflow on >2^31 elements\n  (use `tl.int64` offsets when numel > 2e9).\n- NaN\u002FInf only in compiled → division by masked-out zero lanes; `tl.where` the mask before\n  the division, not after.\n\n## 4. Launch-overhead reduction (when e2e-bound)\n\n- Merge kernels (one launch per region; the whole point of fusion).\n- Do not add a tiny independent kernel after a correct-but-slow state unless it absorbs\n  enough real eager work to pay for another launch. If a completed eval shows the added\n  region lowers score, revert to the best completed state and stop that line.\n- Avoid per-call `next_power_of_2` recompute churn → precompute in wrapper; constexpr set\n  small (see 2.6).\n- Don't return tuples\u002Flists from the wrapper unless the pattern output needs it.\n- Buffer reuse across calls (cache `out` keyed by shape in a module dict) saves ~2 µs but\n  risks aliasing bugs if the model returns your output AND mutates downstream — only as a\n  last resort, verify with full eval.\n- CUDA graphs \u002F `torch.compile` of the wrapper \u002F `no_dispatch` tricks: NOT allowed\n  (torch.* calls blocked \u002F hacking). Don't.\n\n## 5. Micro-benchmark before full eval (GPU, seconds)\n\n```python\nimport torch, time\ndef bench(fn, *args, iters=500):\n    for _ in range(20): fn(*args)\n    torch.cuda.synchronize(); t0 = time.perf_counter()\n    for _ in range(iters): fn(*args)\n    torch.cuda.synchronize(); return (time.perf_counter() - t0) \u002F iters * 1e6  # µs\n```\nCompare: (a) eager region ops chained, (b) your wrapper. Build inputs with the shapes \u002F\ndtypes from weight_meta (use the checker's replay). Target: wrapper ≤ eager_region − 40 µs\nfor small graphs; for ms-scale kernels target the memory-traffic bound (bytes moved \u002F\n~1.5 TB\u002Fs on A100 ≈ achievable µs).\n\n`check_pattern.py --bench` (passnet-feedback) automates exactly this comparison per\nvariant; trust the full eval for the final number (it adds guards\u002FFX costs that local\nmicro-bench misses).\n","## 1. Performance model — know if a win is even possible\n\nMeasured costs (A100, torch 2.7.1 \u002F triton 3.3.1; same order of magnitude on the eval box):\n\n| component | cost per call |\n|---|---|\n| dynamo guards + FX graph interpretation + dispatch wrapper | ~25–45 µs on a 3-op graph; grows with node count (~150–230 µs seen on a 13-node graph) — calibrate from your first eval |\n| Triton kernel Python launch (`kernel[grid](...)`) | ~19 µs each |\n| `torch.empty_like` \u002F `torch.empty` | ~2–3 µs each |\n| each aten op you REMOVED from the graph | +5–25 µs back (small ops) or its real kernel time |\n\nSo per variant: `compiled_e2e ≈ eager_e2e − Σ(absorbed aten µs) + tax + Σ(your kernels µs)`.\nRules of thumb:\n- Whole eager forward \u003C ~150 µs and you can absorb ≤2 cheap ops → ceiling \u003C 1. Ship a\n  safe correct pass, accept ~0.8–0.95, spend your time on another bottleneck.\n- Small or narrow fusions can match and be numerically correct yet still lose e2e when\n  launch\u002Fframework overhead exceeds the eager work removed.\n- Layout-only, view\u002Freshape-only, split\u002Ffanout, tiny activation, and small reduction-like\n  kernels can also lose even when their local kernel is correct: eager may treat the work\n  as metadata, use a vendor-tuned primitive, or pay less framework overhead than the\n  compiled path. Treat these as floor\u002Fdownside caps unless they bridge substantial compute\n  or remove an actual materialization.\n- The lever is **ops absorbed per launch** (and avoiding extra launches\u002Fallocs), not\n  shaving 10% off an already-tiny kernel.\n- Big tensors (≥ a few MB; kernel ≥ 100 µs): overhead noise vanishes; now memory traffic\n  is everything — a clean fused kernel that reads each input once and writes once usually\n  beats the multi-pass eager chain by the ratio of memory passes saved.\n- **The biggest wins can be ALGORITHMIC, not tuning** — but the default for a heavy conv\u002Fmatmul\n  is still \"leave it in the library, fuse its tail,\" because the library is near-optimal inside\n  the regime it tuned for. The clearest case where a rewrite beats it: a **non-overlapping\n  convolution** (`stride == kernel_size`, `kernel_size > 1`, `padding == 0`) is a dense patch\n  matmul while cuDNN runs a heavier general im2col path — a `tl.dot` patch-gather kernel\n  (kernel-templates §13) can win big. It usually does NOT pay to rewrite a **1×1 conv** (already\n  a cuBLAS-optimal pointwise GEMM), an **overlapping conv** (im2col blows up memory), a\n  **depthwise\u002Fgrouped conv**, or a **general dense matmul** — those are vendor sweet spots.\n  Treat this as a prior, not a ban: the completed eval decides. Pursue any rewrite only after a\n  floor is banked, and don't dismiss the non-overlapping case as \"cuDNN, unbeatable\" without\n  checking `stride == kernel_size`.\n- For large cat\u002Fstack\u002Fgather-style outputs, one giant kernel is not automatically best if it\n  needs heavy branching or irregular index logic. A small fixed number of simple kernels can\n  be faster and more timing-stable when each launch writes a large contiguous region. Compare\n  sequential micro-bench signals, then trust the completed evaluation.\n- Repeated round evidence favors long memory-bound elementwise and broadcast-affine chains\n  when one legal single-output kernel absorbs multiple affine, activation, residual, layout,\n  or normalization consumers. These are the first places to spend tuning effort after a\n  correct floor because saved memory passes can amortize wrapper and launch overhead.\n- Repeated completed evaluations also favor normalization-affine compute prefixes and\n  concat-to-normalization-affine prefixes when they remove large memory passes in one launch.\n  Treat kernel layout choices for concat branches as workload-dependent: a broad prefix can\n  win strongly, but small\u002Fbranchy cases or attempts to absorb extra producers can regress in\n  score, correctness, or timing stability. Keep the best completed floor\u002Fprefix state and\n  revert completed regressions instead of stacking more small kernels or sweeping blindly.\n- Reduction-only regions and vendor-tail replacements still need completed-evaluation proof.\n  A correct reduction kernel, a small tail behind a vendor op, or a region that replaces a\n  vendor-tuned primitive can remain below eager even when local kernel timing looks plausible.\n  Use the completed eval to decide keep\u002Frevert; do not infer success from the triage family.\n- Compare `[Speedup][gpu]` vs `[Speedup][e2e]` in the eval log: gpu≈e2e&both\u003C1 → on-stream\n  gaps\u002Flaunches dominate (absorb more ops \u002F fewer launches); gpu>1 but e2e\u003C1 → host-side\n  overhead (reduce launches, drop autotune key churn, simplify wrapper Python).\n- Only a completed evaluation can prove the final overhead-bound conclusion. Local\n  micro-bench and `check_pattern --bench` are pre-flight signals; if the completed eval is\n  matched and correct but below eager for the maximal legal region, stop or revert instead\n  of sweeping launch-bound tuning knobs.\n\n## 2. Kernel quality checklist (in order of impact)\n\n1. **One read per input element, one write per output element.** No multi-launch chains\n   when one kernel can hold the chain in registers. Exception: for heterogeneous\n   direct-output cat\u002Fstack branches, compare a branch-heavy single kernel with grouped\n   launches; choose by measured stable e2e speed, not by launch count alone.\n2. **Contiguous innermost access**: thread `offs` should walk the last (stride-1) dim.\n   For strided\u002Fpermuted inputs pass strides; never `.contiguous()` (poison-illegal) —\n   absorbing the transpose INTO the index math is free.\n3. **Block sizing**: elementwise → BLOCK 1024 (n ≥ 1M: 2048, num_warps=8). Row kernels →\n   `BLOCK_N = next_power_of_2(N)`, and start with **num_warps=4** — more warps on small\n   rows HURTS (measured: 512-elem rows, warps=8 was 1.8× slower than warps=4). If\n   N > 16384 switch to a looped accumulation (template 6 in kernel-templates).\n   For tiny rows (≤1024 elems), SWEEP rows-per-program ∈ {1, 2, 4, 8} (2D tile) — the\n   winner is shape-dependent (measured 1.45× for ROWS=4 at D=512\u002F131k rows, but ROWS=1\n   best on a 768-wide LayerNorm); never assume, always micro-bench (§5).\n4. **Grid**: prefer 1D `cdiv(n, BLOCK)`; for row kernels one program per row is fine up\n   to ~256k rows. Avoid grids of 1–4 programs on big inputs (underutilization) — split.\n5. **num_stages**: only matters for `tl.dot`\u002Flooped kernels (3–4); elementwise ignore.\n6. **Avoid recompilation churn**: every distinct `tl.constexpr` value (incl. BLOCK chosen\n   from shape) compiles a new binary during warmup. 2–3 specializations fine; per-shape\n   formulas over 100-variant samples → timeout risk. Derive constexprs from a small fixed\n   set (e.g. BLOCK_N = next_pow2 clamped to {128, 512, 1024, 4096}).\n7. **Autotune policy**: `@triton.autotune` is legal and runs during the untimed warmup\n   (poison-safe). Use ≤4–6 configs, `key=['N']`-style coarse keys. SKIP autotune when the\n   sample has many graph variants (tuning cost × variants × 600 s timeout) or when the\n   kernel is launch-bound anyway. A hand-picked config from one local micro-benchmark is\n   usually within 5%.\n8. **Scalar args beat tensor args**: precompute `n`, `C`, `HW`, strides in the wrapper\n   (metadata access is poison-legal) — never load shape info from tensors in-kernel.\n9. **Reduce wrapper Python**: no dict lookups in hot path beyond the route `if`; compute\n   grid inline; allocate with `torch.empty` (not zeros — don't pay a memset you'll\n   overwrite).\n\n## 3. Numeric fidelity — passing t=-5 baseline tolerances\n\nBaselines: fp32 rtol 1.3e-6\u002Fatol 1e-5 (tight — mirror eager's algorithm), fp16 rtol 1e-3,\nbf16 rtol 1.6e-2 (loose). The same kernel must satisfy ALL dtype variants.\n\nRecipes (these match aten's CUDA implementations):\n- **Always compute in fp32** (`.to(tl.float32)` after load), store with\n  `.to(out_ptr.dtype.element_ty)`. For fp16\u002Fbf16 inputs this reproduces aten (which also\n  accumulates in fp32) to ≤1 ulp.\n- Reductions: `tl.sum`\u002F`tl.max` over a row in one block ≈ aten's order closely enough for\n  fp32 rtol 1.3e-6 at typical sizes (N ≤ 16k). For looped accumulation keep ONE fp32\n  accumulator (don't reorder into multiple partial schemes unnecessarily).\n- softmax: subtract row max (aten does), exp, divide by sum. Don't use exp2 shortcuts on\n  fp32 variants.\n- layer_norm\u002Fbatch_norm: biased variance (÷N), `1\u002Fsqrt(var+eps)` in fp32, then scale\u002Fshift.\n- mean: `sum\u002FN` (single division at the end, not running mean).\n- GELU exact: `0.5x(1+erf(x\u002F√2))` via `tl.math.erf`; tanh GELU only when model.py says\n  `approximate='tanh'`.\n- sigmoid\u002Fsilu: `1\u002F(1+exp(-x))` fp32 — fine at all baselines.\n- `x.pow(2)` → `x*x`; `torch.rsqrt` → `1.0\u002Ftl.sqrt` (matches aten rsqrt within 1 ulp; if\n  a strict fp32 variant complains, try `tl.math.rsqrt`).\n- Integer\u002Fbool tensors: compare with `torch.equal` (atol\u002Frtol=0 conceptually) — your\n  kernel must be EXACT (indices, masks, argmax-style ops: replicate tie-breaking by\n  first-occurrence).\n- Output dtype must equal eager's per output ([Datatype] check), including intermediate\n  `.to(torch.float32)` nodes you absorbed — store in the dtype eager would have at the\n  region's output.\n\nDiagnosing accuracy failures from eval logs: `[Correctness][max_diff]` magnitude vs the\ntable above (parse_eval_log.py does this) —\n- max_diff ~1e-3·|values| on fp16 only → fp16 rounding mismatch: ensure fp32 internal math.\n- fails ONLY fp32 variants → algorithmic mismatch (reduction order, formula) — mirror\n  aten's exact sequence.\n- max_diff huge (≥1) → indexing\u002Fmasking bug, not numerics: check strides, `other=` values\n  contaminating reductions (use `-inf` for max, `0` for sum, and mask BEFORE divide),\n  uninitialized output regions (mask coverage), `offs` overflow on >2^31 elements\n  (use `tl.int64` offsets when numel > 2e9).\n- NaN\u002FInf only in compiled → division by masked-out zero lanes; `tl.where` the mask before\n  the division, not after.\n\n## 4. Launch-overhead reduction (when e2e-bound)\n\n- Merge kernels (one launch per region; the whole point of fusion).\n- Do not add a tiny independent kernel after a correct-but-slow state unless it absorbs\n  enough real eager work to pay for another launch. If a completed eval shows the added\n  region lowers score, revert to the best completed state and stop that line.\n- Avoid per-call `next_power_of_2` recompute churn → precompute in wrapper; constexpr set\n  small (see 2.6).\n- Don't return tuples\u002Flists from the wrapper unless the pattern output needs it.\n- Buffer reuse across calls (cache `out` keyed by shape in a module dict) saves ~2 µs but\n  risks aliasing bugs if the model returns your output AND mutates downstream — only as a\n  last resort, verify with full eval.\n- CUDA graphs \u002F `torch.compile` of the wrapper \u002F `no_dispatch` tricks: NOT allowed\n  (torch.* calls blocked \u002F hacking). Don't.\n\n## 5. Micro-benchmark before full eval (GPU, seconds)\n\n```python\nimport torch, time\ndef bench(fn, *args, iters=500):\n    for _ in range(20): fn(*args)\n    torch.cuda.synchronize(); t0 = time.perf_counter()\n    for _ in range(iters): fn(*args)\n    torch.cuda.synchronize(); return (time.perf_counter() - t0) \u002F iters * 1e6  # µs\n```\nCompare: (a) eager region ops chained, (b) your wrapper. Build inputs with the shapes \u002F\ndtypes from weight_meta (use the checker's replay). Target: wrapper ≤ eager_region − 40 µs\nfor small graphs; for ms-scale kernels target the memory-traffic bound (bytes moved \u002F\n~1.5 TB\u002Fs on A100 ≈ achievable µs).\n\n`check_pattern.py --bench` (passnet-feedback) automates exactly this comparison per\nvariant; trust the full eval for the final number (it adds guards\u002FFX costs that local\nmicro-bench misses).\n",{"name":5,"description":7},"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","06-前端与设计\u002Fpassnet-triton-opt",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill passnet-triton-opt",{"tool":38,"command":39},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill passnet-triton-opt",{"tool":41,"command":42},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill passnet-triton-opt","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fpassnet-triton-opt\u002FSKILL.md",true,[],[47,54,59,66,73,80],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":55,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]