[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M799NYSH1R3RVAHSM2D88Y84":3,"skill-same:01M799NYSH1R3RVAHSM2D88Y84":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M799NYSH1R3RVAHSM2D88Y84","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.","VectorSpaceLab\u002FAREX-Skill","VectorSpaceLab","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F180637102?v=4","01M7538C5WPSJGWF7KHR4EFZ9F","01M7538C6R2GFP53NPXTCZNBRT",351,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-triton-opt\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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","ac3fe1afa80fb9a09775ecfb2b6cc3ba850a2db6","skills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-triton-opt",27,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab","2026-09-03 10:25:21",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add VectorSpaceLab\u002FAREX-Skill --skill passnet-triton-opt",{"tool":36,"command":37},"bunx","bunx skills add VectorSpaceLab\u002FAREX-Skill --skill passnet-triton-opt",{"tool":39,"command":40},"pnpm","pnpm dlx skills add VectorSpaceLab\u002FAREX-Skill --skill passnet-triton-opt","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-triton-opt\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M799NS5APEC0N1FZ7XZVW6BN","passnet-solve","END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-solve\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":18},"01M799NNY9BKSM21V5R7QVTBJX","passnet-skill","PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under .\u002Fpass_dir\u002F, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-skill\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M799NHH6NP7Z1RK77KGXAN6S","passnet-pattern-fusion","Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()\u002Freplacement_args()\u002Freplacement_func() files, when a pass \"failed to match\", or when deciding how to fuse multiple kernels\u002Fops.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-pattern-fusion\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M799ND2J4WNC2PGAZ0A06NDF","passnet-orchestrate","Round\u002Fbatch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep\u002Frevert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-orchestrate\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M799N8SBTMY02ZDG2AZF5ZWE","passnet-feedback","Fast, deterministic feedback for PassNet work: pre-flight pattern\u002Fmatch verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-feedback\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M799N5J50300PMTGY5HVJN9R","prompt_template_rendering","Render PromptSource-style Jinja prompt templates into natural-language input\u002Ftarget pairs with answer choices, deterministic choices, skip handling, and structured diagnostics.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPaperBench\u002Fskills\u002Fwhat-will-my-model-forget\u002Fskill\u002Fp3_promptsource\u002Fprompt_template_rendering\u002FSKILL.md",[],[]]