[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-huggingface-xpu-kernels":3,"mdc--irkwv8-key":36,"related-repo-huggingface-xpu-kernels":2648,"related-org-huggingface-xpu-kernels":2700},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":31,"sourceUrl":34,"mdContent":35},"xpu-kernels","optimize Triton kernels for Intel XPU","Provides guidance for writing, optimizing, and benchmarking Triton kernels for Intel XPU GPUs (Battlemage\u002FArc Pro B50) using the Xe-Forge optimization framework. Includes an LLM-driven trial-loop workflow (analyze, validate, benchmark, profile, finalize), XPU-specific patterns (tensor descriptors, GRF mode, tile swizzling), KernelBench fused kernels, and Flash Attention.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"huggingface","Hugging Face","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fhuggingface.png",[12,16,19,22],{"name":13,"slug":14,"type":15},"Performance","performance","tag",{"name":17,"slug":18,"type":15},"Triton","triton",{"name":20,"slug":21,"type":15},"Deep Learning","deep-learning",{"name":23,"slug":24,"type":15},"AI Infrastructure","ai-infrastructure",712,"https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fkernels","2026-07-18T05:15:18.767865",null,112,[],{"repoUrl":26,"stars":25,"forks":29,"topics":32,"description":33},[],"Build compute kernels and load them from the Hub.","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fkernels\u002Ftree\u002FHEAD\u002Fkernel-builder\u002Fskills\u002Fxpu-kernels","---\nname: xpu-kernels\ndescription: \"Provides guidance for writing, optimizing, and benchmarking Triton kernels for Intel XPU GPUs (Battlemage\u002FArc Pro B50) using the Xe-Forge optimization framework. Includes an LLM-driven trial-loop workflow (analyze, validate, benchmark, profile, finalize), XPU-specific patterns (tensor descriptors, GRF mode, tile swizzling), KernelBench fused kernels, and Flash Attention.\"\ndisable-model-invocation: false\nuser-invocable: true\nallowed-tools: \"Read, Grep, Glob, Bash\"\nargument-hint: \"kernel type: gemm, reduction, flash-attention, optimize, benchmark, tensor-descriptors, xe-forge\"\n---\n\n# XPU Triton Kernels for Intel GPUs\n\nThis skill provides patterns and guidance for developing optimized Triton kernels targeting Intel XPU GPUs (Battlemage\u002FArc Pro B50). It integrates the [Xe-Forge](https:\u002F\u002Fgithub.com\u002FIntelLabs\u002FXe-Forge) optimization framework — an LLM-driven loop that transforms PyTorch code into fast Triton kernels.\n\n## Quick Start\n\n### Optimize a Kernel (Xe-Forge Workflow)\n\nThe full optimization workflow analyzes a PyTorch baseline, generates Triton kernel variants in a branching trial tree, benchmarks each on XPU hardware, and finalizes the best result.\n\n```bash\n# 1. Analyze the baseline\npython scripts\u002Fanalyze_kernel.py test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py\n\n# 2. Initialize trial tracking\npython scripts\u002Ftrial_manager.py init 70_Gemm_Sigmoid test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py\n\n# 3. Validate a generated kernel (no GPU needed)\npython scripts\u002Fvalidate_triton.py my_kernel.py\n\n# 4. Benchmark correctness + performance\npython scripts\u002Fbenchmark.py test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py my_kernel.py\n\n# 5. Profile with VTune (optional)\npython scripts\u002Fxpu_profiler.py my_kernel.py\n\n# 6. Finalize best trial\npython scripts\u002Ftrial_manager.py finalize 70_Gemm_Sigmoid optimized_triton.py\n```\n\n## Supported Hardware\n\n| GPU | Architecture | XVEs | Mem BW | Key Feature | Verified |\n|-----|-------------|------|--------|-------------|:--------:|\n| **Battlemage G21 \u002F Arc Pro B50** | Xe2 | 128 | ~500 GB\u002Fs | Tensor descriptors, GRF 256 | Yes |\n\n> See the [Intel XPU Backend for Triton](https:\u002F\u002Fgithub.com\u002Fintel\u002Fintel-xpu-backend-for-triton) for supported hardware.\n\n## When This Skill Applies\n\nUse this skill when:\n- Optimizing PyTorch operations into Triton kernels for **Intel XPU**\n- Writing GEMM, fused kernels, reductions, or Flash Attention for Intel GPUs\n- Running the **Xe-Forge optimization loop** (analyze → validate → benchmark → profile → finalize)\n- Benchmarking kernel performance against PyTorch baseline on XPU\n\n## Xe-Forge Optimization Workflow\n\nTransform PyTorch code into optimized Triton kernels for Intel XPU. Kernels must be numerically equivalent and faster than baseline.\n\n### Configuration — Read `config.yaml` first\n\nAt the start of every session, read `scripts\u002Fconfig.yaml`. It controls:\n- **`max_trials`** — hard cap on optimization trials; always run all of them (use this instead of hardcoded \"10\")\n- **`vtune_enabled`** — if `false`, skip ALL VTune profiling steps (Step 3.6 and profiler-related decisions)\n- **`vtune_bin`** — path to the VTune binary (also settable via `VTUNE_BIN` env var)\n\n### Rules — Never Violate\n\n1. **ONLY create** Triton kernel files (`test_kernels\u002F*_triton.py` or trial files `t\u003Ctrial_id>.py`).\n2. **NEVER create** benchmark scripts, test scripts, helper utilities, or any other Python files.\n3. **NEVER write custom scripts** to measure performance or test correctness — ONLY use `scripts\u002Fbenchmark.py`.\n4. If a tool fails, **STOP and report the error**. Do NOT work around it with custom scripts.\n5. Generated kernels must be **self-contained** — all helper functions inline.\n6. You **MUST run all `max_trials` trials** from `config.yaml`. Do NOT stop early due to plateau — LLM sampling can discover new ideas at any point. The only valid early stop is speedup > 5x.\n\n### Mandatory Tools\n\n**CRITICAL — Single-XPU serialization**: There is only ONE XPU on this machine. You MUST NOT run multiple GPU workloads in parallel. `benchmark.py` and `xpu_profiler.py` must execute strictly one at a time — concurrent GPU jobs produce wrong results. CPU-only tools (`analyze_kernel.py`, `validate_triton.py`, `trial_manager.py`) are safe to parallelize with each other and with anything else.\n\n| Tool | Command | Purpose |\n|------|---------|---------|\n| **Analyze** | `python scripts\u002Fanalyze_kernel.py \u003Cfile>` | Static analysis: operations, shapes, fusion opportunities |\n| **Validate** | `python scripts\u002Fvalidate_triton.py \u003Cfile>` | Syntax + constraint checks before GPU time |\n| **Benchmark** | `python scripts\u002Fbenchmark.py \u003Cbaseline> \u003Ctriton> [--triton-baseline] [--baseline-us \u003Ccached>]` | Correctness + performance via ai-bench |\n| **Profile** | `python scripts\u002Fxpu_profiler.py \u003Cfile>` | VTune GPU hardware counters + recommendations |\n| **Init trials** | `python scripts\u002Ftrial_manager.py init \u003Ckernel_name> \u003Cbaseline_file> [--triton-baseline]` | Initialize trial tracking |\n| **Save trial** | `python scripts\u002Ftrial_manager.py save \u003Ckernel_name> \u003Cfile> [--parent \u003Cparent_id>] [--strategy \"...\"]` | Save trial to tree |\n| **Record result** | `python scripts\u002Ftrial_manager.py result \u003Ckernel_name> \u003Ctrial_id> --validation pass --correctness \u003Cpass\\|fail> --speedup \u003Cfloat> --baseline_us \u003Cfloat> --triton_us \u003Cfloat>` | Record benchmark result |\n| **Check status** | `python scripts\u002Ftrial_manager.py status \u003Ckernel_name>` | View trial tree |\n| **Best trial** | `python scripts\u002Ftrial_manager.py best \u003Ckernel_name>` | Get best trial |\n| **Baseline time** | `python scripts\u002Ftrial_manager.py baseline-us \u003Ckernel_name>` | Cached baseline time for `--baseline-us` |\n| **Finalize** | `python scripts\u002Ftrial_manager.py finalize \u003Ckernel_name> \u003Cname>_triton.py` | Copy best trial to output |\n\n### Workflow Steps\n\n#### Step 1: Analyze\n- Read the baseline source file. Identify shapes, dtypes, operations, fusion opportunities.\n- If baseline is PyTorch: run `python scripts\u002Fanalyze_kernel.py \u003Cpytorch_file>`.\n- If baseline is Triton (`--triton-baseline`): skip `analyze_kernel.py` (it only supports PyTorch). Read the Triton file directly.\n- Read relevant knowledge base files: start with `references\u002Fcorrectness.yaml` and `references\u002Fxpu_optimizations.yaml`.\n- Read `references\u002Fimplementation_reference.md` for templates and the Model class pattern.\n\n#### Step 2: Initialize\n```bash\npython scripts\u002Ftrial_manager.py init \u003Ckernel_name> \u003Cbaseline_file> [--triton-baseline]\n```\n\n#### Step 3: Trial Loop (always run all `max_trials` from config.yaml)\nFor each trial:\n1. **Write kernel** — start from templates or modify previous trial. See `references\u002Fimplementation_reference.md`.\n2. **Validate** — `python scripts\u002Fvalidate_triton.py \u003Ctriton_file>` (fix until passing; doesn't count as a trial).\n3. **Save** — `python scripts\u002Ftrial_manager.py save \u003Ckernel_name> \u003Ctriton_file> --parent \u003Cparent_id> --strategy \"description\"`. Omit `--parent` for the first trial (t0).\n4. **Benchmark** (MANDATORY every trial):\n   - **Trial t0:** `python scripts\u002Fbenchmark.py \u003Cbaseline_file> \u003Ctriton_file> [--triton-baseline]` (measures both baseline and triton).\n   - **Trials t1+:** Get cached baseline via `python scripts\u002Ftrial_manager.py baseline-us \u003Ckernel_name>`, then run `python scripts\u002Fbenchmark.py \u003Cbaseline_file> \u003Ctriton_file> [--triton-baseline] --baseline-us \u003Ccached_value>` (skips baseline perf, saves time).\n   - **After `finalize`:** Re-run `benchmark.py` without `--baseline-us` for final accurate comparison.\n5. **Record** — `python scripts\u002Ftrial_manager.py result \u003Ckernel_name> \u003Ctrial_id> --validation pass --correctness \u003Cpass|fail> --speedup \u003Cfloat> --baseline_us \u003Cfloat> --triton_us \u003Cfloat>` (runtimes from benchmark output).\n6. **Profile (MANDATORY after t1, if `vtune_enabled` is true in config.yaml)** — Run `python scripts\u002Fxpu_profiler.py \u003Ctriton_file>` after your first benchmarked trial. Use its output to guide subsequent trial strategies. Run again if speedup plateaus after 2+ additional trials. **Skip this step entirely if `vtune_enabled` is false.**\n7. **Decide next action** (use profiler output from step 6 to inform decisions):\n   - Speedup > 5x → stop (excellent), finalize\n   - Speedup improved → continue on this branch, try next optimization level\n   - Speedup regressed → branch back to best trial, try different strategy\n   - Correctness failed → fix on same branch\n   - Profiler says low occupancy (if vtune_enabled) → increase tile sizes, check `references\u002Fxpu_optimizations.yaml`\n   - Profiler says overhead kernels dominate (if vtune_enabled) → pre-pack to bf16, see `references\u002Foptimization_levels.yaml`\n   - Plateau → do NOT stop. Try a fundamentally different approach (different algorithm, tiling, fusion strategy). LLM sampling can discover new ideas.\n   - See `references\u002Foptimization_strategies.md` for the full \"try harder\" decision tree\n\n#### Step 4: Finalize\n```bash\npython scripts\u002Ftrial_manager.py finalize \u003Ckernel_name> \u003Cname>_triton.py\n```\n\n### Reference Docs — Read During Step 1\n\n| Doc | Contents |\n|-----|----------|\n| `references\u002Fimplementation_reference.md` | Code templates, Model class pattern, GEMM example |\n| `references\u002Foptimization_strategies.md` | Strategy reference, optimization levels, checklist |\n| `references\u002Fworkflow_details.md` | Detailed workflow, decision tree, benchmarking\u002Fvalidation details |\n| `references\u002Fcorrectness.yaml` | Critical constraints to avoid bugs |\n| `references\u002Fxpu_optimizations.yaml` | XPU-specific patterns (tensor descriptors, GRF, swizzling) |\n| `references\u002Ffusion_patterns.yaml` | When to fuse vs split operations |\n| `references\u002Foptimization_levels.yaml` | Progressive optimization with \"try harder\" decision tree |\n\n### Existing Baselines Are Naive\n\nThe `test_kernels\u002F*.py` Triton files (non-pytorch) are **unoptimized baselines**. They use manual pointer arithmetic, lack autotune, and miss XPU optimizations. Do NOT copy their patterns. Use `references\u002Fimplementation_reference.md` instead.\n\n## Core XPU Kernel Patterns\n\n### Tensor Descriptors (Preferred on XPU)\n\nTensor descriptors produce better address generation and memory access codegen than block pointers on Intel XPU.\n\n```python\ndesc = tl.make_tensor_descriptor(\n    base=ptr, shape=[M, N],\n    strides=[stride_m, stride_n],\n    block_shape=[BLOCK_M, BLOCK_N],\n)\nblock = tl.load(desc, [pid_m, pid_n], boundary_check=(0, 1))\n```\n\n### GRF Mode '256'\n\nUse the large register file for compute-heavy kernels:\n\n```python\n@triton.autotune(\n    configs=[triton.Config({'BLOCK_M': 256, 'BLOCK_N': 256}, num_warps=32)],\n    key=['M', 'N', 'K'],\n)\n@triton.jit(launch_metadata=lambda *args, **kwargs: {'grf_mode': '256'})\ndef kernel(...):\n    ...\n```\n\n### Register-Spill-Aware Autotune Pruning\n\nFor autotuned XPU kernels, prune configs that are likely to spill even after large-GRF recompilation. This avoids slow double-compile\u002Fbenchmark cycles where the Intel backend reports spills, recompiles in large GRF mode, and still spills.\n\nUse an `early_config_prune` that estimates per-thread GRF pressure from the live accumulator and operand tiles:\n\n```text\nregs ~= (accumulators * BM * BN + stages * (BM * BK + weight_tiles * BN * BK))\n        \u002F (num_warps * warp_size)\n```\n\nGuidelines:\n- Apply this only on XPU; leave other backends' configs unchanged.\n- Read `BM`, `BN`, and `BK` from either autotune config kwargs or launch args.\n- Count accumulator tiles explicitly: gate\u002Fup fused kernels often have 2 accumulators, down\u002Fsimple GEMM usually has 1.\n- Count weight tiles explicitly: gate\u002Fup fused kernels often load 2 weight tiles, down\u002Fsimple GEMM usually loads 1.\n- Use `num_stages` for pipelined MMA paths; use 1 for scalar\u002Fnon-pipelined paths.\n- Keep a never-empty fallback, such as the config with the lowest estimated register pressure.\n- Treat the model as a coarse filter for catastrophic spillers, not a perfect predictor; leave borderline configs for real benchmarking.\n\nThis complements `grf_mode='256'`: large GRF increases the register budget, while pruning removes configs that are still too register-heavy to be useful.\n\nFor an implementation pattern, see `references\u002Fxpu_optimizations.yaml (xpu_register_spill_autotune_pruning)`.\n\n### Tile Swizzling\n\nUse 1D grid with GROUP_SIZE_M for L2 locality:\n\n```python\ngrid = lambda META: (triton.cdiv(M, META['BLOCK_M']) * triton.cdiv(N, META['BLOCK_N']),)\n# Inside kernel:\npid = tl.program_id(0)\nnum_pid_n = tl.cdiv(N, BLOCK_N)\ngroup_id = pid \u002F\u002F (GROUP_SIZE_M * num_pid_n)\n```\n\n### bf16 Inputs with fp32 Accumulation\n\n```python\na = tl.load(a_desc, [pid_m, k], boundary_check=(0, 1))\nb = tl.load(b_desc, [k, pid_n], boundary_check=(0, 1))\nacc += tl.dot(a.to(tl.bfloat16), b.to(tl.bfloat16), acc=acc)  # fp32 accumulator\n```\n\n## Critical XPU Constraints\n\n- **NO default values** for `@triton.autotune` meta-parameters in kernel signature\n- **1D grid** when using tile swizzling (GROUP_SIZE_M)\n- **`boundary_check`** uses dimension indices `(0, 1)`, not booleans\n- **Cast batch indices** to `int64` before stride multiplication\n- **Prefer tensor descriptors** over block pointers for all new XPU kernels\n- **Do NOT mix** block pointer and tensor descriptor APIs on same operation\n- **Pre-zero output buffers** when using atomic accumulation\n- Model class must be compatible with ai-bench (`nn.Module` with `nn.Linear`)\n- Match `get_inputs()`, `get_init_inputs()`, and module-level constants from `*_pytorch.py`\n\n> Full constraint list: [correctness.yaml](references\u002Fcorrectness.yaml)\n\n## Performance Results\n\nMeasured on Intel Battlemage G21 \u002F Arc Pro B50 (128 XVEs). All runtimes are median of benchmark trials.\n\n### KernelBench Level 2 — Fused Kernels (bf16)\n\nSpeedup is vs. PyTorch eager baseline. Includes GEMM+Sigmoid+Scaling, GEMM+GELU+Softmax, Conv+BatchNorm+ReLU, and other fused patterns.\n\n### Flash Attention Forward (fp16)\n\nBaseline is the flash attention kernel from the Intel XPU Triton backend; speedup is vs. that kernel across multiple sequence lengths.\n\n> Full results: see the [Xe-Forge repository](https:\u002F\u002Fgithub.com\u002FIntelLabs\u002FXe-Forge).\n\n## Common Issues\n\n| Issue | Symptom | Fix |\n|-------|---------|-----|\n| **Autotune BLOCK_D** | Wrong results (max_abs 4-8+) | **Never autotune BLOCK_D.** Use `triton.next_power_of_2(D)` |\n| Python min\u002Fmax | Runtime error | `tl.minimum()`\u002F`tl.maximum()` |\n\n## Project Structure\n\n```\nxpu-kernels\u002F\n├── SKILL.md                                    # This file (skill definition + workflow)\n├── manifest.txt                                # Files included in this skill\n│\n├── scripts\u002F                                    # Standalone CLI tools\n│   ├── analyze_kernel.py                       # PyTorch → operations, shapes, fusion opportunities\n│   ├── validate_triton.py                      # Syntax + constraint checks\n│   ├── benchmark.py                            # Correctness + performance via ai-bench\n│   ├── trial_manager.py                        # Tree-structured trial management\n│   ├── xpu_profiler.py                         # VTune GPU hardware counters\n│   ├── config.py                               # Shared configuration loader\n│   ├── config.yaml                             # Session config (max_trials, vtune)\n│   └── requirements.txt                        # Python dependencies\n│\n└── references\u002F                                 # Knowledge base + integration guides\n    ├── correctness.yaml                        # Hard constraints for XPU Triton\n    ├── xpu_optimizations.yaml                  # Tensor descriptors, GRF, swizzling\n    ├── implementation_reference.md             # Code templates, Model class pattern\n    ├── implementation_reference.md             # Code templates, Model class pattern\n    ├── optimization_strategies.md              # Strategy reference + \"try harder\" tree\n    ├── optimization_levels.yaml                # Progressive L1-L5 optimization levels\n    ├── workflow_details.md                     # Detailed workflow and decision tree\n    ├── fusion_patterns.yaml                    # When to fuse vs split\n    ├── memory_patterns.yaml                    # Access patterns and coalescing\n    ├── dtype_optimizations.yaml                # Mixed precision choices\n    ├── persistent_kernel_patterns.yaml         # Stream K and persistent kernels\n    ├── kernel-templates.md                     # Triton kernel templates for XPU\n    └── kernelbench-classification.md           # KernelBench operator taxonomy\n```\n\n## See Also\n\n### Xe-Forge Tools\n- [analyze_kernel.py](scripts\u002Fanalyze_kernel.py) — Static analysis of PyTorch reference\n- [validate_triton.py](scripts\u002Fvalidate_triton.py) — Pre-benchmark constraint checks\n- [benchmark.py](scripts\u002Fbenchmark.py) — Correctness + performance measurement\n- [xpu_profiler.py](scripts\u002Fxpu_profiler.py) — VTune GPU hardware counters\n- [trial_manager.py](scripts\u002Ftrial_manager.py) — Branching trial tree management\n\n### XPU Optimization References\n- [correctness.yaml](references\u002Fcorrectness.yaml) — Critical constraints\n- [xpu_optimizations.yaml](references\u002Fxpu_optimizations.yaml) — Tensor descriptors, GRF, swizzling\n- [optimization_strategies.md](references\u002Foptimization_strategies.md) — Strategy reference\n- [optimization_levels.yaml](references\u002Foptimization_levels.yaml) — Progressive L1-L5 levels\n- [implementation_reference.md](references\u002Fimplementation_reference.md) — Code templates\n\n### Other References\n- [kernelbench-classification.md](references\u002Fkernelbench-classification.md) — KernelBench operator taxonomy\n\n### External Resources\n- [Xe-Forge Repository](https:\u002F\u002Fgithub.com\u002FIntelLabs\u002FXe-Forge)\n- [AI-Bench](https:\u002F\u002Fgithub.com\u002Flibxsmm\u002FAI-bench) — Benchmark harness for correctness + performance\n- [Intel XPU Backend for Triton](https:\u002F\u002Fgithub.com\u002Fintel\u002Fintel-xpu-backend-for-triton)\n- [Triton Language Guide](https:\u002F\u002Ftriton-lang.org\u002F)\n",{"data":37,"body":42},{"name":4,"description":6,"disable-model-invocation":38,"user-invocable":39,"allowed-tools":40,"argument-hint":41},false,true,"Read, Grep, Glob, Bash","kernel type: gemm, reduction, flash-attention, optimize, benchmark, tensor-descriptors, xe-forge",{"type":43,"children":44},"root",[45,54,71,78,85,90,331,337,423,441,447,452,489,495,500,514,527,588,594,702,708,757,1065,1071,1078,1150,1156,1222,1235,1240,1513,1519,1579,1585,1721,1727,1754,1760,1766,1771,1827,1833,1838,1900,1906,1911,1924,1934,1939,2007,2020,2032,2038,2043,2090,2096,2127,2133,2281,2294,2300,2305,2311,2316,2322,2327,2342,2348,2437,2443,2452,2458,2464,2516,2522,2574,2580,2594,2600,2642],{"type":46,"tag":47,"props":48,"children":50},"element","h1",{"id":49},"xpu-triton-kernels-for-intel-gpus",[51],{"type":52,"value":53},"text","XPU Triton Kernels for Intel GPUs",{"type":46,"tag":55,"props":56,"children":57},"p",{},[58,60,69],{"type":52,"value":59},"This skill provides patterns and guidance for developing optimized Triton kernels targeting Intel XPU GPUs (Battlemage\u002FArc Pro B50). It integrates the ",{"type":46,"tag":61,"props":62,"children":66},"a",{"href":63,"rel":64},"https:\u002F\u002Fgithub.com\u002FIntelLabs\u002FXe-Forge",[65],"nofollow",[67],{"type":52,"value":68},"Xe-Forge",{"type":52,"value":70}," optimization framework — an LLM-driven loop that transforms PyTorch code into fast Triton kernels.",{"type":46,"tag":72,"props":73,"children":75},"h2",{"id":74},"quick-start",[76],{"type":52,"value":77},"Quick Start",{"type":46,"tag":79,"props":80,"children":82},"h3",{"id":81},"optimize-a-kernel-xe-forge-workflow",[83],{"type":52,"value":84},"Optimize a Kernel (Xe-Forge Workflow)",{"type":46,"tag":55,"props":86,"children":87},{},[88],{"type":52,"value":89},"The full optimization workflow analyzes a PyTorch baseline, generates Triton kernel variants in a branching trial tree, benchmarks each on XPU hardware, and finalizes the best result.",{"type":46,"tag":91,"props":92,"children":97},"pre",{"className":93,"code":94,"language":95,"meta":96,"style":96},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# 1. Analyze the baseline\npython scripts\u002Fanalyze_kernel.py test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py\n\n# 2. Initialize trial tracking\npython scripts\u002Ftrial_manager.py init 70_Gemm_Sigmoid test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py\n\n# 3. Validate a generated kernel (no GPU needed)\npython scripts\u002Fvalidate_triton.py my_kernel.py\n\n# 4. Benchmark correctness + performance\npython scripts\u002Fbenchmark.py test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py my_kernel.py\n\n# 5. Profile with VTune (optional)\npython scripts\u002Fxpu_profiler.py my_kernel.py\n\n# 6. Finalize best trial\npython scripts\u002Ftrial_manager.py finalize 70_Gemm_Sigmoid optimized_triton.py\n","bash","",[98],{"type":46,"tag":99,"props":100,"children":101},"code",{"__ignoreMap":96},[102,114,135,144,153,180,188,197,215,223,232,254,262,271,288,296,305],{"type":46,"tag":103,"props":104,"children":107},"span",{"class":105,"line":106},"line",1,[108],{"type":46,"tag":103,"props":109,"children":111},{"style":110},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[112],{"type":52,"value":113},"# 1. Analyze the baseline\n",{"type":46,"tag":103,"props":115,"children":117},{"class":105,"line":116},2,[118,124,130],{"type":46,"tag":103,"props":119,"children":121},{"style":120},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[122],{"type":52,"value":123},"python",{"type":46,"tag":103,"props":125,"children":127},{"style":126},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[128],{"type":52,"value":129}," scripts\u002Fanalyze_kernel.py",{"type":46,"tag":103,"props":131,"children":132},{"style":126},[133],{"type":52,"value":134}," test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py\n",{"type":46,"tag":103,"props":136,"children":138},{"class":105,"line":137},3,[139],{"type":46,"tag":103,"props":140,"children":141},{"emptyLinePlaceholder":39},[142],{"type":52,"value":143},"\n",{"type":46,"tag":103,"props":145,"children":147},{"class":105,"line":146},4,[148],{"type":46,"tag":103,"props":149,"children":150},{"style":110},[151],{"type":52,"value":152},"# 2. Initialize trial tracking\n",{"type":46,"tag":103,"props":154,"children":156},{"class":105,"line":155},5,[157,161,166,171,176],{"type":46,"tag":103,"props":158,"children":159},{"style":120},[160],{"type":52,"value":123},{"type":46,"tag":103,"props":162,"children":163},{"style":126},[164],{"type":52,"value":165}," scripts\u002Ftrial_manager.py",{"type":46,"tag":103,"props":167,"children":168},{"style":126},[169],{"type":52,"value":170}," init",{"type":46,"tag":103,"props":172,"children":173},{"style":126},[174],{"type":52,"value":175}," 70_Gemm_Sigmoid",{"type":46,"tag":103,"props":177,"children":178},{"style":126},[179],{"type":52,"value":134},{"type":46,"tag":103,"props":181,"children":183},{"class":105,"line":182},6,[184],{"type":46,"tag":103,"props":185,"children":186},{"emptyLinePlaceholder":39},[187],{"type":52,"value":143},{"type":46,"tag":103,"props":189,"children":191},{"class":105,"line":190},7,[192],{"type":46,"tag":103,"props":193,"children":194},{"style":110},[195],{"type":52,"value":196},"# 3. Validate a generated kernel (no GPU needed)\n",{"type":46,"tag":103,"props":198,"children":200},{"class":105,"line":199},8,[201,205,210],{"type":46,"tag":103,"props":202,"children":203},{"style":120},[204],{"type":52,"value":123},{"type":46,"tag":103,"props":206,"children":207},{"style":126},[208],{"type":52,"value":209}," scripts\u002Fvalidate_triton.py",{"type":46,"tag":103,"props":211,"children":212},{"style":126},[213],{"type":52,"value":214}," my_kernel.py\n",{"type":46,"tag":103,"props":216,"children":218},{"class":105,"line":217},9,[219],{"type":46,"tag":103,"props":220,"children":221},{"emptyLinePlaceholder":39},[222],{"type":52,"value":143},{"type":46,"tag":103,"props":224,"children":226},{"class":105,"line":225},10,[227],{"type":46,"tag":103,"props":228,"children":229},{"style":110},[230],{"type":52,"value":231},"# 4. Benchmark correctness + performance\n",{"type":46,"tag":103,"props":233,"children":235},{"class":105,"line":234},11,[236,240,245,250],{"type":46,"tag":103,"props":237,"children":238},{"style":120},[239],{"type":52,"value":123},{"type":46,"tag":103,"props":241,"children":242},{"style":126},[243],{"type":52,"value":244}," scripts\u002Fbenchmark.py",{"type":46,"tag":103,"props":246,"children":247},{"style":126},[248],{"type":52,"value":249}," test_kernels\u002F70_Gemm_Sigmoid_Scaling_ResidualAdd_pytorch.py",{"type":46,"tag":103,"props":251,"children":252},{"style":126},[253],{"type":52,"value":214},{"type":46,"tag":103,"props":255,"children":257},{"class":105,"line":256},12,[258],{"type":46,"tag":103,"props":259,"children":260},{"emptyLinePlaceholder":39},[261],{"type":52,"value":143},{"type":46,"tag":103,"props":263,"children":265},{"class":105,"line":264},13,[266],{"type":46,"tag":103,"props":267,"children":268},{"style":110},[269],{"type":52,"value":270},"# 5. Profile with VTune (optional)\n",{"type":46,"tag":103,"props":272,"children":274},{"class":105,"line":273},14,[275,279,284],{"type":46,"tag":103,"props":276,"children":277},{"style":120},[278],{"type":52,"value":123},{"type":46,"tag":103,"props":280,"children":281},{"style":126},[282],{"type":52,"value":283}," scripts\u002Fxpu_profiler.py",{"type":46,"tag":103,"props":285,"children":286},{"style":126},[287],{"type":52,"value":214},{"type":46,"tag":103,"props":289,"children":291},{"class":105,"line":290},15,[292],{"type":46,"tag":103,"props":293,"children":294},{"emptyLinePlaceholder":39},[295],{"type":52,"value":143},{"type":46,"tag":103,"props":297,"children":299},{"class":105,"line":298},16,[300],{"type":46,"tag":103,"props":301,"children":302},{"style":110},[303],{"type":52,"value":304},"# 6. Finalize best trial\n",{"type":46,"tag":103,"props":306,"children":308},{"class":105,"line":307},17,[309,313,317,322,326],{"type":46,"tag":103,"props":310,"children":311},{"style":120},[312],{"type":52,"value":123},{"type":46,"tag":103,"props":314,"children":315},{"style":126},[316],{"type":52,"value":165},{"type":46,"tag":103,"props":318,"children":319},{"style":126},[320],{"type":52,"value":321}," finalize",{"type":46,"tag":103,"props":323,"children":324},{"style":126},[325],{"type":52,"value":175},{"type":46,"tag":103,"props":327,"children":328},{"style":126},[329],{"type":52,"value":330}," optimized_triton.py\n",{"type":46,"tag":72,"props":332,"children":334},{"id":333},"supported-hardware",[335],{"type":52,"value":336},"Supported Hardware",{"type":46,"tag":338,"props":339,"children":340},"table",{},[341,381],{"type":46,"tag":342,"props":343,"children":344},"thead",{},[345],{"type":46,"tag":346,"props":347,"children":348},"tr",{},[349,355,360,365,370,375],{"type":46,"tag":350,"props":351,"children":352},"th",{},[353],{"type":52,"value":354},"GPU",{"type":46,"tag":350,"props":356,"children":357},{},[358],{"type":52,"value":359},"Architecture",{"type":46,"tag":350,"props":361,"children":362},{},[363],{"type":52,"value":364},"XVEs",{"type":46,"tag":350,"props":366,"children":367},{},[368],{"type":52,"value":369},"Mem BW",{"type":46,"tag":350,"props":371,"children":372},{},[373],{"type":52,"value":374},"Key Feature",{"type":46,"tag":350,"props":376,"children":378},{"align":377},"center",[379],{"type":52,"value":380},"Verified",{"type":46,"tag":382,"props":383,"children":384},"tbody",{},[385],{"type":46,"tag":346,"props":386,"children":387},{},[388,398,403,408,413,418],{"type":46,"tag":389,"props":390,"children":391},"td",{},[392],{"type":46,"tag":393,"props":394,"children":395},"strong",{},[396],{"type":52,"value":397},"Battlemage G21 \u002F Arc Pro B50",{"type":46,"tag":389,"props":399,"children":400},{},[401],{"type":52,"value":402},"Xe2",{"type":46,"tag":389,"props":404,"children":405},{},[406],{"type":52,"value":407},"128",{"type":46,"tag":389,"props":409,"children":410},{},[411],{"type":52,"value":412},"~500 GB\u002Fs",{"type":46,"tag":389,"props":414,"children":415},{},[416],{"type":52,"value":417},"Tensor descriptors, GRF 256",{"type":46,"tag":389,"props":419,"children":420},{"align":377},[421],{"type":52,"value":422},"Yes",{"type":46,"tag":424,"props":425,"children":426},"blockquote",{},[427],{"type":46,"tag":55,"props":428,"children":429},{},[430,432,439],{"type":52,"value":431},"See the ",{"type":46,"tag":61,"props":433,"children":436},{"href":434,"rel":435},"https:\u002F\u002Fgithub.com\u002Fintel\u002Fintel-xpu-backend-for-triton",[65],[437],{"type":52,"value":438},"Intel XPU Backend for Triton",{"type":52,"value":440}," for supported hardware.",{"type":46,"tag":72,"props":442,"children":444},{"id":443},"when-this-skill-applies",[445],{"type":52,"value":446},"When This Skill Applies",{"type":46,"tag":55,"props":448,"children":449},{},[450],{"type":52,"value":451},"Use this skill when:",{"type":46,"tag":453,"props":454,"children":455},"ul",{},[456,467,472,484],{"type":46,"tag":457,"props":458,"children":459},"li",{},[460,462],{"type":52,"value":461},"Optimizing PyTorch operations into Triton kernels for ",{"type":46,"tag":393,"props":463,"children":464},{},[465],{"type":52,"value":466},"Intel XPU",{"type":46,"tag":457,"props":468,"children":469},{},[470],{"type":52,"value":471},"Writing GEMM, fused kernels, reductions, or Flash Attention for Intel GPUs",{"type":46,"tag":457,"props":473,"children":474},{},[475,477,482],{"type":52,"value":476},"Running the ",{"type":46,"tag":393,"props":478,"children":479},{},[480],{"type":52,"value":481},"Xe-Forge optimization loop",{"type":52,"value":483}," (analyze → validate → benchmark → profile → finalize)",{"type":46,"tag":457,"props":485,"children":486},{},[487],{"type":52,"value":488},"Benchmarking kernel performance against PyTorch baseline on XPU",{"type":46,"tag":72,"props":490,"children":492},{"id":491},"xe-forge-optimization-workflow",[493],{"type":52,"value":494},"Xe-Forge Optimization Workflow",{"type":46,"tag":55,"props":496,"children":497},{},[498],{"type":52,"value":499},"Transform PyTorch code into optimized Triton kernels for Intel XPU. Kernels must be numerically equivalent and faster than baseline.",{"type":46,"tag":79,"props":501,"children":503},{"id":502},"configuration-read-configyaml-first",[504,506,512],{"type":52,"value":505},"Configuration — Read ",{"type":46,"tag":99,"props":507,"children":509},{"className":508},[],[510],{"type":52,"value":511},"config.yaml",{"type":52,"value":513}," first",{"type":46,"tag":55,"props":515,"children":516},{},[517,519,525],{"type":52,"value":518},"At the start of every session, read ",{"type":46,"tag":99,"props":520,"children":522},{"className":521},[],[523],{"type":52,"value":524},"scripts\u002Fconfig.yaml",{"type":52,"value":526},". It controls:",{"type":46,"tag":453,"props":528,"children":529},{},[530,544,566],{"type":46,"tag":457,"props":531,"children":532},{},[533,542],{"type":46,"tag":393,"props":534,"children":535},{},[536],{"type":46,"tag":99,"props":537,"children":539},{"className":538},[],[540],{"type":52,"value":541},"max_trials",{"type":52,"value":543}," — hard cap on optimization trials; always run all of them (use this instead of hardcoded \"10\")",{"type":46,"tag":457,"props":545,"children":546},{},[547,556,558,564],{"type":46,"tag":393,"props":548,"children":549},{},[550],{"type":46,"tag":99,"props":551,"children":553},{"className":552},[],[554],{"type":52,"value":555},"vtune_enabled",{"type":52,"value":557}," — if ",{"type":46,"tag":99,"props":559,"children":561},{"className":560},[],[562],{"type":52,"value":563},"false",{"type":52,"value":565},", skip ALL VTune profiling steps (Step 3.6 and profiler-related decisions)",{"type":46,"tag":457,"props":567,"children":568},{},[569,578,580,586],{"type":46,"tag":393,"props":570,"children":571},{},[572],{"type":46,"tag":99,"props":573,"children":575},{"className":574},[],[576],{"type":52,"value":577},"vtune_bin",{"type":52,"value":579}," — path to the VTune binary (also settable via ",{"type":46,"tag":99,"props":581,"children":583},{"className":582},[],[584],{"type":52,"value":585},"VTUNE_BIN",{"type":52,"value":587}," env var)",{"type":46,"tag":79,"props":589,"children":591},{"id":590},"rules-never-violate",[592],{"type":52,"value":593},"Rules — Never Violate",{"type":46,"tag":595,"props":596,"children":597},"ol",{},[598,624,634,652,664,676],{"type":46,"tag":457,"props":599,"children":600},{},[601,606,608,614,616,622],{"type":46,"tag":393,"props":602,"children":603},{},[604],{"type":52,"value":605},"ONLY create",{"type":52,"value":607}," Triton kernel files (",{"type":46,"tag":99,"props":609,"children":611},{"className":610},[],[612],{"type":52,"value":613},"test_kernels\u002F*_triton.py",{"type":52,"value":615}," or trial files ",{"type":46,"tag":99,"props":617,"children":619},{"className":618},[],[620],{"type":52,"value":621},"t\u003Ctrial_id>.py",{"type":52,"value":623},").",{"type":46,"tag":457,"props":625,"children":626},{},[627,632],{"type":46,"tag":393,"props":628,"children":629},{},[630],{"type":52,"value":631},"NEVER create",{"type":52,"value":633}," benchmark scripts, test scripts, helper utilities, or any other Python files.",{"type":46,"tag":457,"props":635,"children":636},{},[637,642,644,650],{"type":46,"tag":393,"props":638,"children":639},{},[640],{"type":52,"value":641},"NEVER write custom scripts",{"type":52,"value":643}," to measure performance or test correctness — ONLY use ",{"type":46,"tag":99,"props":645,"children":647},{"className":646},[],[648],{"type":52,"value":649},"scripts\u002Fbenchmark.py",{"type":52,"value":651},".",{"type":46,"tag":457,"props":653,"children":654},{},[655,657,662],{"type":52,"value":656},"If a tool fails, ",{"type":46,"tag":393,"props":658,"children":659},{},[660],{"type":52,"value":661},"STOP and report the error",{"type":52,"value":663},". Do NOT work around it with custom scripts.",{"type":46,"tag":457,"props":665,"children":666},{},[667,669,674],{"type":52,"value":668},"Generated kernels must be ",{"type":46,"tag":393,"props":670,"children":671},{},[672],{"type":52,"value":673},"self-contained",{"type":52,"value":675}," — all helper functions inline.",{"type":46,"tag":457,"props":677,"children":678},{},[679,681,693,695,700],{"type":52,"value":680},"You ",{"type":46,"tag":393,"props":682,"children":683},{},[684,686,691],{"type":52,"value":685},"MUST run all ",{"type":46,"tag":99,"props":687,"children":689},{"className":688},[],[690],{"type":52,"value":541},{"type":52,"value":692}," trials",{"type":52,"value":694}," from ",{"type":46,"tag":99,"props":696,"children":698},{"className":697},[],[699],{"type":52,"value":511},{"type":52,"value":701},". Do NOT stop early due to plateau — LLM sampling can discover new ideas at any point. The only valid early stop is speedup > 5x.",{"type":46,"tag":79,"props":703,"children":705},{"id":704},"mandatory-tools",[706],{"type":52,"value":707},"Mandatory Tools",{"type":46,"tag":55,"props":709,"children":710},{},[711,716,718,724,726,732,734,740,742,748,749,755],{"type":46,"tag":393,"props":712,"children":713},{},[714],{"type":52,"value":715},"CRITICAL — Single-XPU serialization",{"type":52,"value":717},": There is only ONE XPU on this machine. You MUST NOT run multiple GPU workloads in parallel. ",{"type":46,"tag":99,"props":719,"children":721},{"className":720},[],[722],{"type":52,"value":723},"benchmark.py",{"type":52,"value":725}," and ",{"type":46,"tag":99,"props":727,"children":729},{"className":728},[],[730],{"type":52,"value":731},"xpu_profiler.py",{"type":52,"value":733}," must execute strictly one at a time — concurrent GPU jobs produce wrong results. CPU-only tools (",{"type":46,"tag":99,"props":735,"children":737},{"className":736},[],[738],{"type":52,"value":739},"analyze_kernel.py",{"type":52,"value":741},", ",{"type":46,"tag":99,"props":743,"children":745},{"className":744},[],[746],{"type":52,"value":747},"validate_triton.py",{"type":52,"value":741},{"type":46,"tag":99,"props":750,"children":752},{"className":751},[],[753],{"type":52,"value":754},"trial_manager.py",{"type":52,"value":756},") are safe to parallelize with each other and with anything else.",{"type":46,"tag":338,"props":758,"children":759},{},[760,781],{"type":46,"tag":342,"props":761,"children":762},{},[763],{"type":46,"tag":346,"props":764,"children":765},{},[766,771,776],{"type":46,"tag":350,"props":767,"children":768},{},[769],{"type":52,"value":770},"Tool",{"type":46,"tag":350,"props":772,"children":773},{},[774],{"type":52,"value":775},"Command",{"type":46,"tag":350,"props":777,"children":778},{},[779],{"type":52,"value":780},"Purpose",{"type":46,"tag":382,"props":782,"children":783},{},[784,809,834,859,884,909,934,959,984,1009,1040],{"type":46,"tag":346,"props":785,"children":786},{},[787,795,804],{"type":46,"tag":389,"props":788,"children":789},{},[790],{"type":46,"tag":393,"props":791,"children":792},{},[793],{"type":52,"value":794},"Analyze",{"type":46,"tag":389,"props":796,"children":797},{},[798],{"type":46,"tag":99,"props":799,"children":801},{"className":800},[],[802],{"type":52,"value":803},"python scripts\u002Fanalyze_kernel.py \u003Cfile>",{"type":46,"tag":389,"props":805,"children":806},{},[807],{"type":52,"value":808},"Static analysis: operations, shapes, fusion opportunities",{"type":46,"tag":346,"props":810,"children":811},{},[812,820,829],{"type":46,"tag":389,"props":813,"children":814},{},[815],{"type":46,"tag":393,"props":816,"children":817},{},[818],{"type":52,"value":819},"Validate",{"type":46,"tag":389,"props":821,"children":822},{},[823],{"type":46,"tag":99,"props":824,"children":826},{"className":825},[],[827],{"type":52,"value":828},"python scripts\u002Fvalidate_triton.py \u003Cfile>",{"type":46,"tag":389,"props":830,"children":831},{},[832],{"type":52,"value":833},"Syntax + constraint checks before GPU time",{"type":46,"tag":346,"props":835,"children":836},{},[837,845,854],{"type":46,"tag":389,"props":838,"children":839},{},[840],{"type":46,"tag":393,"props":841,"children":842},{},[843],{"type":52,"value":844},"Benchmark",{"type":46,"tag":389,"props":846,"children":847},{},[848],{"type":46,"tag":99,"props":849,"children":851},{"className":850},[],[852],{"type":52,"value":853},"python scripts\u002Fbenchmark.py \u003Cbaseline> \u003Ctriton> [--triton-baseline] [--baseline-us \u003Ccached>]",{"type":46,"tag":389,"props":855,"children":856},{},[857],{"type":52,"value":858},"Correctness + performance via ai-bench",{"type":46,"tag":346,"props":860,"children":861},{},[862,870,879],{"type":46,"tag":389,"props":863,"children":864},{},[865],{"type":46,"tag":393,"props":866,"children":867},{},[868],{"type":52,"value":869},"Profile",{"type":46,"tag":389,"props":871,"children":872},{},[873],{"type":46,"tag":99,"props":874,"children":876},{"className":875},[],[877],{"type":52,"value":878},"python scripts\u002Fxpu_profiler.py \u003Cfile>",{"type":46,"tag":389,"props":880,"children":881},{},[882],{"type":52,"value":883},"VTune GPU hardware counters + recommendations",{"type":46,"tag":346,"props":885,"children":886},{},[887,895,904],{"type":46,"tag":389,"props":888,"children":889},{},[890],{"type":46,"tag":393,"props":891,"children":892},{},[893],{"type":52,"value":894},"Init trials",{"type":46,"tag":389,"props":896,"children":897},{},[898],{"type":46,"tag":99,"props":899,"children":901},{"className":900},[],[902],{"type":52,"value":903},"python scripts\u002Ftrial_manager.py init \u003Ckernel_name> \u003Cbaseline_file> [--triton-baseline]",{"type":46,"tag":389,"props":905,"children":906},{},[907],{"type":52,"value":908},"Initialize trial tracking",{"type":46,"tag":346,"props":910,"children":911},{},[912,920,929],{"type":46,"tag":389,"props":913,"children":914},{},[915],{"type":46,"tag":393,"props":916,"children":917},{},[918],{"type":52,"value":919},"Save trial",{"type":46,"tag":389,"props":921,"children":922},{},[923],{"type":46,"tag":99,"props":924,"children":926},{"className":925},[],[927],{"type":52,"value":928},"python scripts\u002Ftrial_manager.py save \u003Ckernel_name> \u003Cfile> [--parent \u003Cparent_id>] [--strategy \"...\"]",{"type":46,"tag":389,"props":930,"children":931},{},[932],{"type":52,"value":933},"Save trial to tree",{"type":46,"tag":346,"props":935,"children":936},{},[937,945,954],{"type":46,"tag":389,"props":938,"children":939},{},[940],{"type":46,"tag":393,"props":941,"children":942},{},[943],{"type":52,"value":944},"Record result",{"type":46,"tag":389,"props":946,"children":947},{},[948],{"type":46,"tag":99,"props":949,"children":951},{"className":950},[],[952],{"type":52,"value":953},"python scripts\u002Ftrial_manager.py result \u003Ckernel_name> \u003Ctrial_id> --validation pass --correctness \u003Cpass|fail> --speedup \u003Cfloat> --baseline_us \u003Cfloat> --triton_us \u003Cfloat>",{"type":46,"tag":389,"props":955,"children":956},{},[957],{"type":52,"value":958},"Record benchmark result",{"type":46,"tag":346,"props":960,"children":961},{},[962,970,979],{"type":46,"tag":389,"props":963,"children":964},{},[965],{"type":46,"tag":393,"props":966,"children":967},{},[968],{"type":52,"value":969},"Check status",{"type":46,"tag":389,"props":971,"children":972},{},[973],{"type":46,"tag":99,"props":974,"children":976},{"className":975},[],[977],{"type":52,"value":978},"python scripts\u002Ftrial_manager.py status \u003Ckernel_name>",{"type":46,"tag":389,"props":980,"children":981},{},[982],{"type":52,"value":983},"View trial tree",{"type":46,"tag":346,"props":985,"children":986},{},[987,995,1004],{"type":46,"tag":389,"props":988,"children":989},{},[990],{"type":46,"tag":393,"props":991,"children":992},{},[993],{"type":52,"value":994},"Best trial",{"type":46,"tag":389,"props":996,"children":997},{},[998],{"type":46,"tag":99,"props":999,"children":1001},{"className":1000},[],[1002],{"type":52,"value":1003},"python scripts\u002Ftrial_manager.py best \u003Ckernel_name>",{"type":46,"tag":389,"props":1005,"children":1006},{},[1007],{"type":52,"value":1008},"Get best trial",{"type":46,"tag":346,"props":1010,"children":1011},{},[1012,1020,1029],{"type":46,"tag":389,"props":1013,"children":1014},{},[1015],{"type":46,"tag":393,"props":1016,"children":1017},{},[1018],{"type":52,"value":1019},"Baseline time",{"type":46,"tag":389,"props":1021,"children":1022},{},[1023],{"type":46,"tag":99,"props":1024,"children":1026},{"className":1025},[],[1027],{"type":52,"value":1028},"python scripts\u002Ftrial_manager.py baseline-us \u003Ckernel_name>",{"type":46,"tag":389,"props":1030,"children":1031},{},[1032,1034],{"type":52,"value":1033},"Cached baseline time for ",{"type":46,"tag":99,"props":1035,"children":1037},{"className":1036},[],[1038],{"type":52,"value":1039},"--baseline-us",{"type":46,"tag":346,"props":1041,"children":1042},{},[1043,1051,1060],{"type":46,"tag":389,"props":1044,"children":1045},{},[1046],{"type":46,"tag":393,"props":1047,"children":1048},{},[1049],{"type":52,"value":1050},"Finalize",{"type":46,"tag":389,"props":1052,"children":1053},{},[1054],{"type":46,"tag":99,"props":1055,"children":1057},{"className":1056},[],[1058],{"type":52,"value":1059},"python scripts\u002Ftrial_manager.py finalize \u003Ckernel_name> \u003Cname>_triton.py",{"type":46,"tag":389,"props":1061,"children":1062},{},[1063],{"type":52,"value":1064},"Copy best trial to output",{"type":46,"tag":79,"props":1066,"children":1068},{"id":1067},"workflow-steps",[1069],{"type":52,"value":1070},"Workflow Steps",{"type":46,"tag":1072,"props":1073,"children":1075},"h4",{"id":1074},"step-1-analyze",[1076],{"type":52,"value":1077},"Step 1: Analyze",{"type":46,"tag":453,"props":1079,"children":1080},{},[1081,1086,1098,1118,1137],{"type":46,"tag":457,"props":1082,"children":1083},{},[1084],{"type":52,"value":1085},"Read the baseline source file. Identify shapes, dtypes, operations, fusion opportunities.",{"type":46,"tag":457,"props":1087,"children":1088},{},[1089,1091,1097],{"type":52,"value":1090},"If baseline is PyTorch: run ",{"type":46,"tag":99,"props":1092,"children":1094},{"className":1093},[],[1095],{"type":52,"value":1096},"python scripts\u002Fanalyze_kernel.py \u003Cpytorch_file>",{"type":52,"value":651},{"type":46,"tag":457,"props":1099,"children":1100},{},[1101,1103,1109,1111,1116],{"type":52,"value":1102},"If baseline is Triton (",{"type":46,"tag":99,"props":1104,"children":1106},{"className":1105},[],[1107],{"type":52,"value":1108},"--triton-baseline",{"type":52,"value":1110},"): skip ",{"type":46,"tag":99,"props":1112,"children":1114},{"className":1113},[],[1115],{"type":52,"value":739},{"type":52,"value":1117}," (it only supports PyTorch). Read the Triton file directly.",{"type":46,"tag":457,"props":1119,"children":1120},{},[1121,1123,1129,1130,1136],{"type":52,"value":1122},"Read relevant knowledge base files: start with ",{"type":46,"tag":99,"props":1124,"children":1126},{"className":1125},[],[1127],{"type":52,"value":1128},"references\u002Fcorrectness.yaml",{"type":52,"value":725},{"type":46,"tag":99,"props":1131,"children":1133},{"className":1132},[],[1134],{"type":52,"value":1135},"references\u002Fxpu_optimizations.yaml",{"type":52,"value":651},{"type":46,"tag":457,"props":1138,"children":1139},{},[1140,1142,1148],{"type":52,"value":1141},"Read ",{"type":46,"tag":99,"props":1143,"children":1145},{"className":1144},[],[1146],{"type":52,"value":1147},"references\u002Fimplementation_reference.md",{"type":52,"value":1149}," for templates and the Model class pattern.",{"type":46,"tag":1072,"props":1151,"children":1153},{"id":1152},"step-2-initialize",[1154],{"type":52,"value":1155},"Step 2: Initialize",{"type":46,"tag":91,"props":1157,"children":1159},{"className":93,"code":1158,"language":95,"meta":96,"style":96},"python scripts\u002Ftrial_manager.py init \u003Ckernel_name> \u003Cbaseline_file> [--triton-baseline]\n",[1160],{"type":46,"tag":99,"props":1161,"children":1162},{"__ignoreMap":96},[1163],{"type":46,"tag":103,"props":1164,"children":1165},{"class":105,"line":106},[1166,1170,1174,1178,1184,1189,1195,1200,1204,1209,1213,1217],{"type":46,"tag":103,"props":1167,"children":1168},{"style":120},[1169],{"type":52,"value":123},{"type":46,"tag":103,"props":1171,"children":1172},{"style":126},[1173],{"type":52,"value":165},{"type":46,"tag":103,"props":1175,"children":1176},{"style":126},[1177],{"type":52,"value":170},{"type":46,"tag":103,"props":1179,"children":1181},{"style":1180},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[1182],{"type":52,"value":1183}," \u003C",{"type":46,"tag":103,"props":1185,"children":1186},{"style":126},[1187],{"type":52,"value":1188},"kernel_nam",{"type":46,"tag":103,"props":1190,"children":1192},{"style":1191},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[1193],{"type":52,"value":1194},"e",{"type":46,"tag":103,"props":1196,"children":1197},{"style":1180},[1198],{"type":52,"value":1199},">",{"type":46,"tag":103,"props":1201,"children":1202},{"style":1180},[1203],{"type":52,"value":1183},{"type":46,"tag":103,"props":1205,"children":1206},{"style":126},[1207],{"type":52,"value":1208},"baseline_fil",{"type":46,"tag":103,"props":1210,"children":1211},{"style":1191},[1212],{"type":52,"value":1194},{"type":46,"tag":103,"props":1214,"children":1215},{"style":1180},[1216],{"type":52,"value":1199},{"type":46,"tag":103,"props":1218,"children":1219},{"style":1191},[1220],{"type":52,"value":1221}," [--triton-baseline]\n",{"type":46,"tag":1072,"props":1223,"children":1225},{"id":1224},"step-3-trial-loop-always-run-all-max_trials-from-configyaml",[1226,1228,1233],{"type":52,"value":1227},"Step 3: Trial Loop (always run all ",{"type":46,"tag":99,"props":1229,"children":1231},{"className":1230},[],[1232],{"type":52,"value":541},{"type":52,"value":1234}," from config.yaml)",{"type":46,"tag":55,"props":1236,"children":1237},{},[1238],{"type":52,"value":1239},"For each trial:",{"type":46,"tag":595,"props":1241,"children":1242},{},[1243,1259,1276,1301,1388,1404,1441],{"type":46,"tag":457,"props":1244,"children":1245},{},[1246,1251,1253,1258],{"type":46,"tag":393,"props":1247,"children":1248},{},[1249],{"type":52,"value":1250},"Write kernel",{"type":52,"value":1252}," — start from templates or modify previous trial. See ",{"type":46,"tag":99,"props":1254,"children":1256},{"className":1255},[],[1257],{"type":52,"value":1147},{"type":52,"value":651},{"type":46,"tag":457,"props":1260,"children":1261},{},[1262,1266,1268,1274],{"type":46,"tag":393,"props":1263,"children":1264},{},[1265],{"type":52,"value":819},{"type":52,"value":1267}," — ",{"type":46,"tag":99,"props":1269,"children":1271},{"className":1270},[],[1272],{"type":52,"value":1273},"python scripts\u002Fvalidate_triton.py \u003Ctriton_file>",{"type":52,"value":1275}," (fix until passing; doesn't count as a trial).",{"type":46,"tag":457,"props":1277,"children":1278},{},[1279,1284,1285,1291,1293,1299],{"type":46,"tag":393,"props":1280,"children":1281},{},[1282],{"type":52,"value":1283},"Save",{"type":52,"value":1267},{"type":46,"tag":99,"props":1286,"children":1288},{"className":1287},[],[1289],{"type":52,"value":1290},"python scripts\u002Ftrial_manager.py save \u003Ckernel_name> \u003Ctriton_file> --parent \u003Cparent_id> --strategy \"description\"",{"type":52,"value":1292},". Omit ",{"type":46,"tag":99,"props":1294,"children":1296},{"className":1295},[],[1297],{"type":52,"value":1298},"--parent",{"type":52,"value":1300}," for the first trial (t0).",{"type":46,"tag":457,"props":1302,"children":1303},{},[1304,1308,1310],{"type":46,"tag":393,"props":1305,"children":1306},{},[1307],{"type":52,"value":844},{"type":52,"value":1309}," (MANDATORY every trial):\n",{"type":46,"tag":453,"props":1311,"children":1312},{},[1313,1331,1356],{"type":46,"tag":457,"props":1314,"children":1315},{},[1316,1321,1323,1329],{"type":46,"tag":393,"props":1317,"children":1318},{},[1319],{"type":52,"value":1320},"Trial t0:",{"type":52,"value":1322}," ",{"type":46,"tag":99,"props":1324,"children":1326},{"className":1325},[],[1327],{"type":52,"value":1328},"python scripts\u002Fbenchmark.py \u003Cbaseline_file> \u003Ctriton_file> [--triton-baseline]",{"type":52,"value":1330}," (measures both baseline and triton).",{"type":46,"tag":457,"props":1332,"children":1333},{},[1334,1339,1341,1346,1348,1354],{"type":46,"tag":393,"props":1335,"children":1336},{},[1337],{"type":52,"value":1338},"Trials t1+:",{"type":52,"value":1340}," Get cached baseline via ",{"type":46,"tag":99,"props":1342,"children":1344},{"className":1343},[],[1345],{"type":52,"value":1028},{"type":52,"value":1347},", then run ",{"type":46,"tag":99,"props":1349,"children":1351},{"className":1350},[],[1352],{"type":52,"value":1353},"python scripts\u002Fbenchmark.py \u003Cbaseline_file> \u003Ctriton_file> [--triton-baseline] --baseline-us \u003Ccached_value>",{"type":52,"value":1355}," (skips baseline perf, saves time).",{"type":46,"tag":457,"props":1357,"children":1358},{},[1359,1372,1374,1379,1381,1386],{"type":46,"tag":393,"props":1360,"children":1361},{},[1362,1364,1370],{"type":52,"value":1363},"After ",{"type":46,"tag":99,"props":1365,"children":1367},{"className":1366},[],[1368],{"type":52,"value":1369},"finalize",{"type":52,"value":1371},":",{"type":52,"value":1373}," Re-run ",{"type":46,"tag":99,"props":1375,"children":1377},{"className":1376},[],[1378],{"type":52,"value":723},{"type":52,"value":1380}," without ",{"type":46,"tag":99,"props":1382,"children":1384},{"className":1383},[],[1385],{"type":52,"value":1039},{"type":52,"value":1387}," for final accurate comparison.",{"type":46,"tag":457,"props":1389,"children":1390},{},[1391,1396,1397,1402],{"type":46,"tag":393,"props":1392,"children":1393},{},[1394],{"type":52,"value":1395},"Record",{"type":52,"value":1267},{"type":46,"tag":99,"props":1398,"children":1400},{"className":1399},[],[1401],{"type":52,"value":953},{"type":52,"value":1403}," (runtimes from benchmark output).",{"type":46,"tag":457,"props":1405,"children":1406},{},[1407,1419,1421,1427,1429],{"type":46,"tag":393,"props":1408,"children":1409},{},[1410,1412,1417],{"type":52,"value":1411},"Profile (MANDATORY after t1, if ",{"type":46,"tag":99,"props":1413,"children":1415},{"className":1414},[],[1416],{"type":52,"value":555},{"type":52,"value":1418}," is true in config.yaml)",{"type":52,"value":1420}," — Run ",{"type":46,"tag":99,"props":1422,"children":1424},{"className":1423},[],[1425],{"type":52,"value":1426},"python scripts\u002Fxpu_profiler.py \u003Ctriton_file>",{"type":52,"value":1428}," after your first benchmarked trial. Use its output to guide subsequent trial strategies. Run again if speedup plateaus after 2+ additional trials. ",{"type":46,"tag":393,"props":1430,"children":1431},{},[1432,1434,1439],{"type":52,"value":1433},"Skip this step entirely if ",{"type":46,"tag":99,"props":1435,"children":1437},{"className":1436},[],[1438],{"type":52,"value":555},{"type":52,"value":1440}," is false.",{"type":46,"tag":457,"props":1442,"children":1443},{},[1444,1449,1451],{"type":46,"tag":393,"props":1445,"children":1446},{},[1447],{"type":52,"value":1448},"Decide next action",{"type":52,"value":1450}," (use profiler output from step 6 to inform decisions):\n",{"type":46,"tag":453,"props":1452,"children":1453},{},[1454,1459,1464,1469,1474,1484,1495,1500],{"type":46,"tag":457,"props":1455,"children":1456},{},[1457],{"type":52,"value":1458},"Speedup > 5x → stop (excellent), finalize",{"type":46,"tag":457,"props":1460,"children":1461},{},[1462],{"type":52,"value":1463},"Speedup improved → continue on this branch, try next optimization level",{"type":46,"tag":457,"props":1465,"children":1466},{},[1467],{"type":52,"value":1468},"Speedup regressed → branch back to best trial, try different strategy",{"type":46,"tag":457,"props":1470,"children":1471},{},[1472],{"type":52,"value":1473},"Correctness failed → fix on same branch",{"type":46,"tag":457,"props":1475,"children":1476},{},[1477,1479],{"type":52,"value":1478},"Profiler says low occupancy (if vtune_enabled) → increase tile sizes, check ",{"type":46,"tag":99,"props":1480,"children":1482},{"className":1481},[],[1483],{"type":52,"value":1135},{"type":46,"tag":457,"props":1485,"children":1486},{},[1487,1489],{"type":52,"value":1488},"Profiler says overhead kernels dominate (if vtune_enabled) → pre-pack to bf16, see ",{"type":46,"tag":99,"props":1490,"children":1492},{"className":1491},[],[1493],{"type":52,"value":1494},"references\u002Foptimization_levels.yaml",{"type":46,"tag":457,"props":1496,"children":1497},{},[1498],{"type":52,"value":1499},"Plateau → do NOT stop. Try a fundamentally different approach (different algorithm, tiling, fusion strategy). LLM sampling can discover new ideas.",{"type":46,"tag":457,"props":1501,"children":1502},{},[1503,1505,1511],{"type":52,"value":1504},"See ",{"type":46,"tag":99,"props":1506,"children":1508},{"className":1507},[],[1509],{"type":52,"value":1510},"references\u002Foptimization_strategies.md",{"type":52,"value":1512}," for the full \"try harder\" decision tree",{"type":46,"tag":1072,"props":1514,"children":1516},{"id":1515},"step-4-finalize",[1517],{"type":52,"value":1518},"Step 4: Finalize",{"type":46,"tag":91,"props":1520,"children":1522},{"className":93,"code":1521,"language":95,"meta":96,"style":96},"python scripts\u002Ftrial_manager.py finalize \u003Ckernel_name> \u003Cname>_triton.py\n",[1523],{"type":46,"tag":99,"props":1524,"children":1525},{"__ignoreMap":96},[1526],{"type":46,"tag":103,"props":1527,"children":1528},{"class":105,"line":106},[1529,1533,1537,1541,1545,1549,1553,1557,1561,1566,1570,1574],{"type":46,"tag":103,"props":1530,"children":1531},{"style":120},[1532],{"type":52,"value":123},{"type":46,"tag":103,"props":1534,"children":1535},{"style":126},[1536],{"type":52,"value":165},{"type":46,"tag":103,"props":1538,"children":1539},{"style":126},[1540],{"type":52,"value":321},{"type":46,"tag":103,"props":1542,"children":1543},{"style":1180},[1544],{"type":52,"value":1183},{"type":46,"tag":103,"props":1546,"children":1547},{"style":126},[1548],{"type":52,"value":1188},{"type":46,"tag":103,"props":1550,"children":1551},{"style":1191},[1552],{"type":52,"value":1194},{"type":46,"tag":103,"props":1554,"children":1555},{"style":1180},[1556],{"type":52,"value":1199},{"type":46,"tag":103,"props":1558,"children":1559},{"style":1180},[1560],{"type":52,"value":1183},{"type":46,"tag":103,"props":1562,"children":1563},{"style":126},[1564],{"type":52,"value":1565},"nam",{"type":46,"tag":103,"props":1567,"children":1568},{"style":1191},[1569],{"type":52,"value":1194},{"type":46,"tag":103,"props":1571,"children":1572},{"style":1180},[1573],{"type":52,"value":1199},{"type":46,"tag":103,"props":1575,"children":1576},{"style":126},[1577],{"type":52,"value":1578},"_triton.py\n",{"type":46,"tag":79,"props":1580,"children":1582},{"id":1581},"reference-docs-read-during-step-1",[1583],{"type":52,"value":1584},"Reference Docs — Read During Step 1",{"type":46,"tag":338,"props":1586,"children":1587},{},[1588,1604],{"type":46,"tag":342,"props":1589,"children":1590},{},[1591],{"type":46,"tag":346,"props":1592,"children":1593},{},[1594,1599],{"type":46,"tag":350,"props":1595,"children":1596},{},[1597],{"type":52,"value":1598},"Doc",{"type":46,"tag":350,"props":1600,"children":1601},{},[1602],{"type":52,"value":1603},"Contents",{"type":46,"tag":382,"props":1605,"children":1606},{},[1607,1623,1639,1656,1672,1688,1705],{"type":46,"tag":346,"props":1608,"children":1609},{},[1610,1618],{"type":46,"tag":389,"props":1611,"children":1612},{},[1613],{"type":46,"tag":99,"props":1614,"children":1616},{"className":1615},[],[1617],{"type":52,"value":1147},{"type":46,"tag":389,"props":1619,"children":1620},{},[1621],{"type":52,"value":1622},"Code templates, Model class pattern, GEMM example",{"type":46,"tag":346,"props":1624,"children":1625},{},[1626,1634],{"type":46,"tag":389,"props":1627,"children":1628},{},[1629],{"type":46,"tag":99,"props":1630,"children":1632},{"className":1631},[],[1633],{"type":52,"value":1510},{"type":46,"tag":389,"props":1635,"children":1636},{},[1637],{"type":52,"value":1638},"Strategy reference, optimization levels, checklist",{"type":46,"tag":346,"props":1640,"children":1641},{},[1642,1651],{"type":46,"tag":389,"props":1643,"children":1644},{},[1645],{"type":46,"tag":99,"props":1646,"children":1648},{"className":1647},[],[1649],{"type":52,"value":1650},"references\u002Fworkflow_details.md",{"type":46,"tag":389,"props":1652,"children":1653},{},[1654],{"type":52,"value":1655},"Detailed workflow, decision tree, benchmarking\u002Fvalidation details",{"type":46,"tag":346,"props":1657,"children":1658},{},[1659,1667],{"type":46,"tag":389,"props":1660,"children":1661},{},[1662],{"type":46,"tag":99,"props":1663,"children":1665},{"className":1664},[],[1666],{"type":52,"value":1128},{"type":46,"tag":389,"props":1668,"children":1669},{},[1670],{"type":52,"value":1671},"Critical constraints to avoid bugs",{"type":46,"tag":346,"props":1673,"children":1674},{},[1675,1683],{"type":46,"tag":389,"props":1676,"children":1677},{},[1678],{"type":46,"tag":99,"props":1679,"children":1681},{"className":1680},[],[1682],{"type":52,"value":1135},{"type":46,"tag":389,"props":1684,"children":1685},{},[1686],{"type":52,"value":1687},"XPU-specific patterns (tensor descriptors, GRF, swizzling)",{"type":46,"tag":346,"props":1689,"children":1690},{},[1691,1700],{"type":46,"tag":389,"props":1692,"children":1693},{},[1694],{"type":46,"tag":99,"props":1695,"children":1697},{"className":1696},[],[1698],{"type":52,"value":1699},"references\u002Ffusion_patterns.yaml",{"type":46,"tag":389,"props":1701,"children":1702},{},[1703],{"type":52,"value":1704},"When to fuse vs split operations",{"type":46,"tag":346,"props":1706,"children":1707},{},[1708,1716],{"type":46,"tag":389,"props":1709,"children":1710},{},[1711],{"type":46,"tag":99,"props":1712,"children":1714},{"className":1713},[],[1715],{"type":52,"value":1494},{"type":46,"tag":389,"props":1717,"children":1718},{},[1719],{"type":52,"value":1720},"Progressive optimization with \"try harder\" decision tree",{"type":46,"tag":79,"props":1722,"children":1724},{"id":1723},"existing-baselines-are-naive",[1725],{"type":52,"value":1726},"Existing Baselines Are Naive",{"type":46,"tag":55,"props":1728,"children":1729},{},[1730,1732,1738,1740,1745,1747,1752],{"type":52,"value":1731},"The ",{"type":46,"tag":99,"props":1733,"children":1735},{"className":1734},[],[1736],{"type":52,"value":1737},"test_kernels\u002F*.py",{"type":52,"value":1739}," Triton files (non-pytorch) are ",{"type":46,"tag":393,"props":1741,"children":1742},{},[1743],{"type":52,"value":1744},"unoptimized baselines",{"type":52,"value":1746},". They use manual pointer arithmetic, lack autotune, and miss XPU optimizations. Do NOT copy their patterns. Use ",{"type":46,"tag":99,"props":1748,"children":1750},{"className":1749},[],[1751],{"type":52,"value":1147},{"type":52,"value":1753}," instead.",{"type":46,"tag":72,"props":1755,"children":1757},{"id":1756},"core-xpu-kernel-patterns",[1758],{"type":52,"value":1759},"Core XPU Kernel Patterns",{"type":46,"tag":79,"props":1761,"children":1763},{"id":1762},"tensor-descriptors-preferred-on-xpu",[1764],{"type":52,"value":1765},"Tensor Descriptors (Preferred on XPU)",{"type":46,"tag":55,"props":1767,"children":1768},{},[1769],{"type":52,"value":1770},"Tensor descriptors produce better address generation and memory access codegen than block pointers on Intel XPU.",{"type":46,"tag":91,"props":1772,"children":1775},{"className":1773,"code":1774,"language":123,"meta":96,"style":96},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","desc = tl.make_tensor_descriptor(\n    base=ptr, shape=[M, N],\n    strides=[stride_m, stride_n],\n    block_shape=[BLOCK_M, BLOCK_N],\n)\nblock = tl.load(desc, [pid_m, pid_n], boundary_check=(0, 1))\n",[1776],{"type":46,"tag":99,"props":1777,"children":1778},{"__ignoreMap":96},[1779,1787,1795,1803,1811,1819],{"type":46,"tag":103,"props":1780,"children":1781},{"class":105,"line":106},[1782],{"type":46,"tag":103,"props":1783,"children":1784},{},[1785],{"type":52,"value":1786},"desc = tl.make_tensor_descriptor(\n",{"type":46,"tag":103,"props":1788,"children":1789},{"class":105,"line":116},[1790],{"type":46,"tag":103,"props":1791,"children":1792},{},[1793],{"type":52,"value":1794},"    base=ptr, shape=[M, N],\n",{"type":46,"tag":103,"props":1796,"children":1797},{"class":105,"line":137},[1798],{"type":46,"tag":103,"props":1799,"children":1800},{},[1801],{"type":52,"value":1802},"    strides=[stride_m, stride_n],\n",{"type":46,"tag":103,"props":1804,"children":1805},{"class":105,"line":146},[1806],{"type":46,"tag":103,"props":1807,"children":1808},{},[1809],{"type":52,"value":1810},"    block_shape=[BLOCK_M, BLOCK_N],\n",{"type":46,"tag":103,"props":1812,"children":1813},{"class":105,"line":155},[1814],{"type":46,"tag":103,"props":1815,"children":1816},{},[1817],{"type":52,"value":1818},")\n",{"type":46,"tag":103,"props":1820,"children":1821},{"class":105,"line":182},[1822],{"type":46,"tag":103,"props":1823,"children":1824},{},[1825],{"type":52,"value":1826},"block = tl.load(desc, [pid_m, pid_n], boundary_check=(0, 1))\n",{"type":46,"tag":79,"props":1828,"children":1830},{"id":1829},"grf-mode-256",[1831],{"type":52,"value":1832},"GRF Mode '256'",{"type":46,"tag":55,"props":1834,"children":1835},{},[1836],{"type":52,"value":1837},"Use the large register file for compute-heavy kernels:",{"type":46,"tag":91,"props":1839,"children":1841},{"className":1773,"code":1840,"language":123,"meta":96,"style":96},"@triton.autotune(\n    configs=[triton.Config({'BLOCK_M': 256, 'BLOCK_N': 256}, num_warps=32)],\n    key=['M', 'N', 'K'],\n)\n@triton.jit(launch_metadata=lambda *args, **kwargs: {'grf_mode': '256'})\ndef kernel(...):\n    ...\n",[1842],{"type":46,"tag":99,"props":1843,"children":1844},{"__ignoreMap":96},[1845,1853,1861,1869,1876,1884,1892],{"type":46,"tag":103,"props":1846,"children":1847},{"class":105,"line":106},[1848],{"type":46,"tag":103,"props":1849,"children":1850},{},[1851],{"type":52,"value":1852},"@triton.autotune(\n",{"type":46,"tag":103,"props":1854,"children":1855},{"class":105,"line":116},[1856],{"type":46,"tag":103,"props":1857,"children":1858},{},[1859],{"type":52,"value":1860},"    configs=[triton.Config({'BLOCK_M': 256, 'BLOCK_N': 256}, num_warps=32)],\n",{"type":46,"tag":103,"props":1862,"children":1863},{"class":105,"line":137},[1864],{"type":46,"tag":103,"props":1865,"children":1866},{},[1867],{"type":52,"value":1868},"    key=['M', 'N', 'K'],\n",{"type":46,"tag":103,"props":1870,"children":1871},{"class":105,"line":146},[1872],{"type":46,"tag":103,"props":1873,"children":1874},{},[1875],{"type":52,"value":1818},{"type":46,"tag":103,"props":1877,"children":1878},{"class":105,"line":155},[1879],{"type":46,"tag":103,"props":1880,"children":1881},{},[1882],{"type":52,"value":1883},"@triton.jit(launch_metadata=lambda *args, **kwargs: {'grf_mode': '256'})\n",{"type":46,"tag":103,"props":1885,"children":1886},{"class":105,"line":182},[1887],{"type":46,"tag":103,"props":1888,"children":1889},{},[1890],{"type":52,"value":1891},"def kernel(...):\n",{"type":46,"tag":103,"props":1893,"children":1894},{"class":105,"line":190},[1895],{"type":46,"tag":103,"props":1896,"children":1897},{},[1898],{"type":52,"value":1899},"    ...\n",{"type":46,"tag":79,"props":1901,"children":1903},{"id":1902},"register-spill-aware-autotune-pruning",[1904],{"type":52,"value":1905},"Register-Spill-Aware Autotune Pruning",{"type":46,"tag":55,"props":1907,"children":1908},{},[1909],{"type":52,"value":1910},"For autotuned XPU kernels, prune configs that are likely to spill even after large-GRF recompilation. This avoids slow double-compile\u002Fbenchmark cycles where the Intel backend reports spills, recompiles in large GRF mode, and still spills.",{"type":46,"tag":55,"props":1912,"children":1913},{},[1914,1916,1922],{"type":52,"value":1915},"Use an ",{"type":46,"tag":99,"props":1917,"children":1919},{"className":1918},[],[1920],{"type":52,"value":1921},"early_config_prune",{"type":52,"value":1923}," that estimates per-thread GRF pressure from the live accumulator and operand tiles:",{"type":46,"tag":91,"props":1925,"children":1929},{"className":1926,"code":1928,"language":52,"meta":96},[1927],"language-text","regs ~= (accumulators * BM * BN + stages * (BM * BK + weight_tiles * BN * BK))\n        \u002F (num_warps * warp_size)\n",[1930],{"type":46,"tag":99,"props":1931,"children":1932},{"__ignoreMap":96},[1933],{"type":52,"value":1928},{"type":46,"tag":55,"props":1935,"children":1936},{},[1937],{"type":52,"value":1938},"Guidelines:",{"type":46,"tag":453,"props":1940,"children":1941},{},[1942,1947,1974,1979,1984,1997,2002],{"type":46,"tag":457,"props":1943,"children":1944},{},[1945],{"type":52,"value":1946},"Apply this only on XPU; leave other backends' configs unchanged.",{"type":46,"tag":457,"props":1948,"children":1949},{},[1950,1951,1957,1958,1964,1966,1972],{"type":52,"value":1141},{"type":46,"tag":99,"props":1952,"children":1954},{"className":1953},[],[1955],{"type":52,"value":1956},"BM",{"type":52,"value":741},{"type":46,"tag":99,"props":1959,"children":1961},{"className":1960},[],[1962],{"type":52,"value":1963},"BN",{"type":52,"value":1965},", and ",{"type":46,"tag":99,"props":1967,"children":1969},{"className":1968},[],[1970],{"type":52,"value":1971},"BK",{"type":52,"value":1973}," from either autotune config kwargs or launch args.",{"type":46,"tag":457,"props":1975,"children":1976},{},[1977],{"type":52,"value":1978},"Count accumulator tiles explicitly: gate\u002Fup fused kernels often have 2 accumulators, down\u002Fsimple GEMM usually has 1.",{"type":46,"tag":457,"props":1980,"children":1981},{},[1982],{"type":52,"value":1983},"Count weight tiles explicitly: gate\u002Fup fused kernels often load 2 weight tiles, down\u002Fsimple GEMM usually loads 1.",{"type":46,"tag":457,"props":1985,"children":1986},{},[1987,1989,1995],{"type":52,"value":1988},"Use ",{"type":46,"tag":99,"props":1990,"children":1992},{"className":1991},[],[1993],{"type":52,"value":1994},"num_stages",{"type":52,"value":1996}," for pipelined MMA paths; use 1 for scalar\u002Fnon-pipelined paths.",{"type":46,"tag":457,"props":1998,"children":1999},{},[2000],{"type":52,"value":2001},"Keep a never-empty fallback, such as the config with the lowest estimated register pressure.",{"type":46,"tag":457,"props":2003,"children":2004},{},[2005],{"type":52,"value":2006},"Treat the model as a coarse filter for catastrophic spillers, not a perfect predictor; leave borderline configs for real benchmarking.",{"type":46,"tag":55,"props":2008,"children":2009},{},[2010,2012,2018],{"type":52,"value":2011},"This complements ",{"type":46,"tag":99,"props":2013,"children":2015},{"className":2014},[],[2016],{"type":52,"value":2017},"grf_mode='256'",{"type":52,"value":2019},": large GRF increases the register budget, while pruning removes configs that are still too register-heavy to be useful.",{"type":46,"tag":55,"props":2021,"children":2022},{},[2023,2025,2031],{"type":52,"value":2024},"For an implementation pattern, see ",{"type":46,"tag":99,"props":2026,"children":2028},{"className":2027},[],[2029],{"type":52,"value":2030},"references\u002Fxpu_optimizations.yaml (xpu_register_spill_autotune_pruning)",{"type":52,"value":651},{"type":46,"tag":79,"props":2033,"children":2035},{"id":2034},"tile-swizzling",[2036],{"type":52,"value":2037},"Tile Swizzling",{"type":46,"tag":55,"props":2039,"children":2040},{},[2041],{"type":52,"value":2042},"Use 1D grid with GROUP_SIZE_M for L2 locality:",{"type":46,"tag":91,"props":2044,"children":2046},{"className":1773,"code":2045,"language":123,"meta":96,"style":96},"grid = lambda META: (triton.cdiv(M, META['BLOCK_M']) * triton.cdiv(N, META['BLOCK_N']),)\n# Inside kernel:\npid = tl.program_id(0)\nnum_pid_n = tl.cdiv(N, BLOCK_N)\ngroup_id = pid \u002F\u002F (GROUP_SIZE_M * num_pid_n)\n",[2047],{"type":46,"tag":99,"props":2048,"children":2049},{"__ignoreMap":96},[2050,2058,2066,2074,2082],{"type":46,"tag":103,"props":2051,"children":2052},{"class":105,"line":106},[2053],{"type":46,"tag":103,"props":2054,"children":2055},{},[2056],{"type":52,"value":2057},"grid = lambda META: (triton.cdiv(M, META['BLOCK_M']) * triton.cdiv(N, META['BLOCK_N']),)\n",{"type":46,"tag":103,"props":2059,"children":2060},{"class":105,"line":116},[2061],{"type":46,"tag":103,"props":2062,"children":2063},{},[2064],{"type":52,"value":2065},"# Inside kernel:\n",{"type":46,"tag":103,"props":2067,"children":2068},{"class":105,"line":137},[2069],{"type":46,"tag":103,"props":2070,"children":2071},{},[2072],{"type":52,"value":2073},"pid = tl.program_id(0)\n",{"type":46,"tag":103,"props":2075,"children":2076},{"class":105,"line":146},[2077],{"type":46,"tag":103,"props":2078,"children":2079},{},[2080],{"type":52,"value":2081},"num_pid_n = tl.cdiv(N, BLOCK_N)\n",{"type":46,"tag":103,"props":2083,"children":2084},{"class":105,"line":155},[2085],{"type":46,"tag":103,"props":2086,"children":2087},{},[2088],{"type":52,"value":2089},"group_id = pid \u002F\u002F (GROUP_SIZE_M * num_pid_n)\n",{"type":46,"tag":79,"props":2091,"children":2093},{"id":2092},"bf16-inputs-with-fp32-accumulation",[2094],{"type":52,"value":2095},"bf16 Inputs with fp32 Accumulation",{"type":46,"tag":91,"props":2097,"children":2099},{"className":1773,"code":2098,"language":123,"meta":96,"style":96},"a = tl.load(a_desc, [pid_m, k], boundary_check=(0, 1))\nb = tl.load(b_desc, [k, pid_n], boundary_check=(0, 1))\nacc += tl.dot(a.to(tl.bfloat16), b.to(tl.bfloat16), acc=acc)  # fp32 accumulator\n",[2100],{"type":46,"tag":99,"props":2101,"children":2102},{"__ignoreMap":96},[2103,2111,2119],{"type":46,"tag":103,"props":2104,"children":2105},{"class":105,"line":106},[2106],{"type":46,"tag":103,"props":2107,"children":2108},{},[2109],{"type":52,"value":2110},"a = tl.load(a_desc, [pid_m, k], boundary_check=(0, 1))\n",{"type":46,"tag":103,"props":2112,"children":2113},{"class":105,"line":116},[2114],{"type":46,"tag":103,"props":2115,"children":2116},{},[2117],{"type":52,"value":2118},"b = tl.load(b_desc, [k, pid_n], boundary_check=(0, 1))\n",{"type":46,"tag":103,"props":2120,"children":2121},{"class":105,"line":137},[2122],{"type":46,"tag":103,"props":2123,"children":2124},{},[2125],{"type":52,"value":2126},"acc += tl.dot(a.to(tl.bfloat16), b.to(tl.bfloat16), acc=acc)  # fp32 accumulator\n",{"type":46,"tag":72,"props":2128,"children":2130},{"id":2129},"critical-xpu-constraints",[2131],{"type":52,"value":2132},"Critical XPU Constraints",{"type":46,"tag":453,"props":2134,"children":2135},{},[2136,2154,2164,2186,2204,2214,2224,2234,2255],{"type":46,"tag":457,"props":2137,"children":2138},{},[2139,2144,2146,2152],{"type":46,"tag":393,"props":2140,"children":2141},{},[2142],{"type":52,"value":2143},"NO default values",{"type":52,"value":2145}," for ",{"type":46,"tag":99,"props":2147,"children":2149},{"className":2148},[],[2150],{"type":52,"value":2151},"@triton.autotune",{"type":52,"value":2153}," meta-parameters in kernel signature",{"type":46,"tag":457,"props":2155,"children":2156},{},[2157,2162],{"type":46,"tag":393,"props":2158,"children":2159},{},[2160],{"type":52,"value":2161},"1D grid",{"type":52,"value":2163}," when using tile swizzling (GROUP_SIZE_M)",{"type":46,"tag":457,"props":2165,"children":2166},{},[2167,2176,2178,2184],{"type":46,"tag":393,"props":2168,"children":2169},{},[2170],{"type":46,"tag":99,"props":2171,"children":2173},{"className":2172},[],[2174],{"type":52,"value":2175},"boundary_check",{"type":52,"value":2177}," uses dimension indices ",{"type":46,"tag":99,"props":2179,"children":2181},{"className":2180},[],[2182],{"type":52,"value":2183},"(0, 1)",{"type":52,"value":2185},", not booleans",{"type":46,"tag":457,"props":2187,"children":2188},{},[2189,2194,2196,2202],{"type":46,"tag":393,"props":2190,"children":2191},{},[2192],{"type":52,"value":2193},"Cast batch indices",{"type":52,"value":2195}," to ",{"type":46,"tag":99,"props":2197,"children":2199},{"className":2198},[],[2200],{"type":52,"value":2201},"int64",{"type":52,"value":2203}," before stride multiplication",{"type":46,"tag":457,"props":2205,"children":2206},{},[2207,2212],{"type":46,"tag":393,"props":2208,"children":2209},{},[2210],{"type":52,"value":2211},"Prefer tensor descriptors",{"type":52,"value":2213}," over block pointers for all new XPU kernels",{"type":46,"tag":457,"props":2215,"children":2216},{},[2217,2222],{"type":46,"tag":393,"props":2218,"children":2219},{},[2220],{"type":52,"value":2221},"Do NOT mix",{"type":52,"value":2223}," block pointer and tensor descriptor APIs on same operation",{"type":46,"tag":457,"props":2225,"children":2226},{},[2227,2232],{"type":46,"tag":393,"props":2228,"children":2229},{},[2230],{"type":52,"value":2231},"Pre-zero output buffers",{"type":52,"value":2233}," when using atomic accumulation",{"type":46,"tag":457,"props":2235,"children":2236},{},[2237,2239,2245,2247,2253],{"type":52,"value":2238},"Model class must be compatible with ai-bench (",{"type":46,"tag":99,"props":2240,"children":2242},{"className":2241},[],[2243],{"type":52,"value":2244},"nn.Module",{"type":52,"value":2246}," with ",{"type":46,"tag":99,"props":2248,"children":2250},{"className":2249},[],[2251],{"type":52,"value":2252},"nn.Linear",{"type":52,"value":2254},")",{"type":46,"tag":457,"props":2256,"children":2257},{},[2258,2260,2266,2267,2273,2275],{"type":52,"value":2259},"Match ",{"type":46,"tag":99,"props":2261,"children":2263},{"className":2262},[],[2264],{"type":52,"value":2265},"get_inputs()",{"type":52,"value":741},{"type":46,"tag":99,"props":2268,"children":2270},{"className":2269},[],[2271],{"type":52,"value":2272},"get_init_inputs()",{"type":52,"value":2274},", and module-level constants from ",{"type":46,"tag":99,"props":2276,"children":2278},{"className":2277},[],[2279],{"type":52,"value":2280},"*_pytorch.py",{"type":46,"tag":424,"props":2282,"children":2283},{},[2284],{"type":46,"tag":55,"props":2285,"children":2286},{},[2287,2289],{"type":52,"value":2288},"Full constraint list: ",{"type":46,"tag":61,"props":2290,"children":2291},{"href":1128},[2292],{"type":52,"value":2293},"correctness.yaml",{"type":46,"tag":72,"props":2295,"children":2297},{"id":2296},"performance-results",[2298],{"type":52,"value":2299},"Performance Results",{"type":46,"tag":55,"props":2301,"children":2302},{},[2303],{"type":52,"value":2304},"Measured on Intel Battlemage G21 \u002F Arc Pro B50 (128 XVEs). All runtimes are median of benchmark trials.",{"type":46,"tag":79,"props":2306,"children":2308},{"id":2307},"kernelbench-level-2-fused-kernels-bf16",[2309],{"type":52,"value":2310},"KernelBench Level 2 — Fused Kernels (bf16)",{"type":46,"tag":55,"props":2312,"children":2313},{},[2314],{"type":52,"value":2315},"Speedup is vs. PyTorch eager baseline. Includes GEMM+Sigmoid+Scaling, GEMM+GELU+Softmax, Conv+BatchNorm+ReLU, and other fused patterns.",{"type":46,"tag":79,"props":2317,"children":2319},{"id":2318},"flash-attention-forward-fp16",[2320],{"type":52,"value":2321},"Flash Attention Forward (fp16)",{"type":46,"tag":55,"props":2323,"children":2324},{},[2325],{"type":52,"value":2326},"Baseline is the flash attention kernel from the Intel XPU Triton backend; speedup is vs. that kernel across multiple sequence lengths.",{"type":46,"tag":424,"props":2328,"children":2329},{},[2330],{"type":46,"tag":55,"props":2331,"children":2332},{},[2333,2335,2341],{"type":52,"value":2334},"Full results: see the ",{"type":46,"tag":61,"props":2336,"children":2338},{"href":63,"rel":2337},[65],[2339],{"type":52,"value":2340},"Xe-Forge repository",{"type":52,"value":651},{"type":46,"tag":72,"props":2343,"children":2345},{"id":2344},"common-issues",[2346],{"type":52,"value":2347},"Common Issues",{"type":46,"tag":338,"props":2349,"children":2350},{},[2351,2372],{"type":46,"tag":342,"props":2352,"children":2353},{},[2354],{"type":46,"tag":346,"props":2355,"children":2356},{},[2357,2362,2367],{"type":46,"tag":350,"props":2358,"children":2359},{},[2360],{"type":52,"value":2361},"Issue",{"type":46,"tag":350,"props":2363,"children":2364},{},[2365],{"type":52,"value":2366},"Symptom",{"type":46,"tag":350,"props":2368,"children":2369},{},[2370],{"type":52,"value":2371},"Fix",{"type":46,"tag":382,"props":2373,"children":2374},{},[2375,2407],{"type":46,"tag":346,"props":2376,"children":2377},{},[2378,2386,2391],{"type":46,"tag":389,"props":2379,"children":2380},{},[2381],{"type":46,"tag":393,"props":2382,"children":2383},{},[2384],{"type":52,"value":2385},"Autotune BLOCK_D",{"type":46,"tag":389,"props":2387,"children":2388},{},[2389],{"type":52,"value":2390},"Wrong results (max_abs 4-8+)",{"type":46,"tag":389,"props":2392,"children":2393},{},[2394,2399,2401],{"type":46,"tag":393,"props":2395,"children":2396},{},[2397],{"type":52,"value":2398},"Never autotune BLOCK_D.",{"type":52,"value":2400}," Use ",{"type":46,"tag":99,"props":2402,"children":2404},{"className":2403},[],[2405],{"type":52,"value":2406},"triton.next_power_of_2(D)",{"type":46,"tag":346,"props":2408,"children":2409},{},[2410,2415,2420],{"type":46,"tag":389,"props":2411,"children":2412},{},[2413],{"type":52,"value":2414},"Python min\u002Fmax",{"type":46,"tag":389,"props":2416,"children":2417},{},[2418],{"type":52,"value":2419},"Runtime error",{"type":46,"tag":389,"props":2421,"children":2422},{},[2423,2429,2431],{"type":46,"tag":99,"props":2424,"children":2426},{"className":2425},[],[2427],{"type":52,"value":2428},"tl.minimum()",{"type":52,"value":2430},"\u002F",{"type":46,"tag":99,"props":2432,"children":2434},{"className":2433},[],[2435],{"type":52,"value":2436},"tl.maximum()",{"type":46,"tag":72,"props":2438,"children":2440},{"id":2439},"project-structure",[2441],{"type":52,"value":2442},"Project Structure",{"type":46,"tag":91,"props":2444,"children":2447},{"className":2445,"code":2446,"language":52},[1927],"xpu-kernels\u002F\n├── SKILL.md                                    # This file (skill definition + workflow)\n├── manifest.txt                                # Files included in this skill\n│\n├── scripts\u002F                                    # Standalone CLI tools\n│   ├── analyze_kernel.py                       # PyTorch → operations, shapes, fusion opportunities\n│   ├── validate_triton.py                      # Syntax + constraint checks\n│   ├── benchmark.py                            # Correctness + performance via ai-bench\n│   ├── trial_manager.py                        # Tree-structured trial management\n│   ├── xpu_profiler.py                         # VTune GPU hardware counters\n│   ├── config.py                               # Shared configuration loader\n│   ├── config.yaml                             # Session config (max_trials, vtune)\n│   └── requirements.txt                        # Python dependencies\n│\n└── references\u002F                                 # Knowledge base + integration guides\n    ├── correctness.yaml                        # Hard constraints for XPU Triton\n    ├── xpu_optimizations.yaml                  # Tensor descriptors, GRF, swizzling\n    ├── implementation_reference.md             # Code templates, Model class pattern\n    ├── implementation_reference.md             # Code templates, Model class pattern\n    ├── optimization_strategies.md              # Strategy reference + \"try harder\" tree\n    ├── optimization_levels.yaml                # Progressive L1-L5 optimization levels\n    ├── workflow_details.md                     # Detailed workflow and decision tree\n    ├── fusion_patterns.yaml                    # When to fuse vs split\n    ├── memory_patterns.yaml                    # Access patterns and coalescing\n    ├── dtype_optimizations.yaml                # Mixed precision choices\n    ├── persistent_kernel_patterns.yaml         # Stream K and persistent kernels\n    ├── kernel-templates.md                     # Triton kernel templates for XPU\n    └── kernelbench-classification.md           # KernelBench operator taxonomy\n",[2448],{"type":46,"tag":99,"props":2449,"children":2450},{"__ignoreMap":96},[2451],{"type":52,"value":2446},{"type":46,"tag":72,"props":2453,"children":2455},{"id":2454},"see-also",[2456],{"type":52,"value":2457},"See Also",{"type":46,"tag":79,"props":2459,"children":2461},{"id":2460},"xe-forge-tools",[2462],{"type":52,"value":2463},"Xe-Forge Tools",{"type":46,"tag":453,"props":2465,"children":2466},{},[2467,2477,2487,2496,2506],{"type":46,"tag":457,"props":2468,"children":2469},{},[2470,2475],{"type":46,"tag":61,"props":2471,"children":2473},{"href":2472},"scripts\u002Fanalyze_kernel.py",[2474],{"type":52,"value":739},{"type":52,"value":2476}," — Static analysis of PyTorch reference",{"type":46,"tag":457,"props":2478,"children":2479},{},[2480,2485],{"type":46,"tag":61,"props":2481,"children":2483},{"href":2482},"scripts\u002Fvalidate_triton.py",[2484],{"type":52,"value":747},{"type":52,"value":2486}," — Pre-benchmark constraint checks",{"type":46,"tag":457,"props":2488,"children":2489},{},[2490,2494],{"type":46,"tag":61,"props":2491,"children":2492},{"href":649},[2493],{"type":52,"value":723},{"type":52,"value":2495}," — Correctness + performance measurement",{"type":46,"tag":457,"props":2497,"children":2498},{},[2499,2504],{"type":46,"tag":61,"props":2500,"children":2502},{"href":2501},"scripts\u002Fxpu_profiler.py",[2503],{"type":52,"value":731},{"type":52,"value":2505}," — VTune GPU hardware counters",{"type":46,"tag":457,"props":2507,"children":2508},{},[2509,2514],{"type":46,"tag":61,"props":2510,"children":2512},{"href":2511},"scripts\u002Ftrial_manager.py",[2513],{"type":52,"value":754},{"type":52,"value":2515}," — Branching trial tree management",{"type":46,"tag":79,"props":2517,"children":2519},{"id":2518},"xpu-optimization-references",[2520],{"type":52,"value":2521},"XPU Optimization References",{"type":46,"tag":453,"props":2523,"children":2524},{},[2525,2534,2544,2554,2564],{"type":46,"tag":457,"props":2526,"children":2527},{},[2528,2532],{"type":46,"tag":61,"props":2529,"children":2530},{"href":1128},[2531],{"type":52,"value":2293},{"type":52,"value":2533}," — Critical constraints",{"type":46,"tag":457,"props":2535,"children":2536},{},[2537,2542],{"type":46,"tag":61,"props":2538,"children":2539},{"href":1135},[2540],{"type":52,"value":2541},"xpu_optimizations.yaml",{"type":52,"value":2543}," — Tensor descriptors, GRF, swizzling",{"type":46,"tag":457,"props":2545,"children":2546},{},[2547,2552],{"type":46,"tag":61,"props":2548,"children":2549},{"href":1510},[2550],{"type":52,"value":2551},"optimization_strategies.md",{"type":52,"value":2553}," — Strategy reference",{"type":46,"tag":457,"props":2555,"children":2556},{},[2557,2562],{"type":46,"tag":61,"props":2558,"children":2559},{"href":1494},[2560],{"type":52,"value":2561},"optimization_levels.yaml",{"type":52,"value":2563}," — Progressive L1-L5 levels",{"type":46,"tag":457,"props":2565,"children":2566},{},[2567,2572],{"type":46,"tag":61,"props":2568,"children":2569},{"href":1147},[2570],{"type":52,"value":2571},"implementation_reference.md",{"type":52,"value":2573}," — Code templates",{"type":46,"tag":79,"props":2575,"children":2577},{"id":2576},"other-references",[2578],{"type":52,"value":2579},"Other References",{"type":46,"tag":453,"props":2581,"children":2582},{},[2583],{"type":46,"tag":457,"props":2584,"children":2585},{},[2586,2592],{"type":46,"tag":61,"props":2587,"children":2589},{"href":2588},"references\u002Fkernelbench-classification.md",[2590],{"type":52,"value":2591},"kernelbench-classification.md",{"type":52,"value":2593}," — KernelBench operator taxonomy",{"type":46,"tag":79,"props":2595,"children":2597},{"id":2596},"external-resources",[2598],{"type":52,"value":2599},"External Resources",{"type":46,"tag":453,"props":2601,"children":2602},{},[2603,2612,2624,2632],{"type":46,"tag":457,"props":2604,"children":2605},{},[2606],{"type":46,"tag":61,"props":2607,"children":2609},{"href":63,"rel":2608},[65],[2610],{"type":52,"value":2611},"Xe-Forge Repository",{"type":46,"tag":457,"props":2613,"children":2614},{},[2615,2622],{"type":46,"tag":61,"props":2616,"children":2619},{"href":2617,"rel":2618},"https:\u002F\u002Fgithub.com\u002Flibxsmm\u002FAI-bench",[65],[2620],{"type":52,"value":2621},"AI-Bench",{"type":52,"value":2623}," — Benchmark harness for correctness + performance",{"type":46,"tag":457,"props":2625,"children":2626},{},[2627],{"type":46,"tag":61,"props":2628,"children":2630},{"href":434,"rel":2629},[65],[2631],{"type":52,"value":438},{"type":46,"tag":457,"props":2633,"children":2634},{},[2635],{"type":46,"tag":61,"props":2636,"children":2639},{"href":2637,"rel":2638},"https:\u002F\u002Ftriton-lang.org\u002F",[65],[2640],{"type":52,"value":2641},"Triton Language Guide",{"type":46,"tag":2643,"props":2644,"children":2645},"style",{},[2646],{"type":52,"value":2647},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":2649,"total":146},[2650,2666,2679,2693],{"slug":2651,"name":2651,"fn":2652,"description":2653,"org":2654,"tags":2655,"stars":25,"repoUrl":26,"updatedAt":2665},"cpu-kernels","optimize C++ CPU kernels for Hugging Face","Provides guidance for writing, optimizing, and benchmarking C++ CPU kernels with SIMD intrinsics (AVX2\u002FAVX512) for the Hugging Face kernels ecosystem. Includes a two-phase workflow: Phase 1 correctness (generic → AVX2) and Phase 2 performance exploration (AVX512 with branching trial loop), runtime CPU dispatch, OpenMP threading, and brgemm integration for GEMM-heavy kernels.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2656,2659,2662,2664],{"name":2657,"slug":2658,"type":15},"C#","c",{"name":2660,"slug":2661,"type":15},"Engineering","engineering",{"name":9,"slug":2663,"type":15},"hugging-face",{"name":13,"slug":14,"type":15},"2026-06-09T07:19:37.783356",{"slug":2667,"name":2667,"fn":2668,"description":2669,"org":2670,"tags":2671,"stars":25,"repoUrl":26,"updatedAt":2678},"cuda-kernels","write and benchmark optimized CUDA kernels","Provides guidance for writing and benchmarking optimized CUDA kernels for NVIDIA GPUs (H100, A100, T4) targeting HuggingFace diffusers and transformers libraries. Kernels must be kernel-builder\u002FABI3-compliant: no pybind11, no setup.py, TORCH_LIBRARY_EXPAND bindings only. Supports models like LTX-Video, Stable Diffusion, LLaMA, Mistral, and Qwen. Includes integration with HuggingFace Kernels Hub (get_kernel) for loading pre-compiled kernels. Includes benchmarking scripts to compare kernel performance against baseline implementations.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2672,2673,2674,2675,2676],{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"name":9,"slug":2663,"type":15},{"name":13,"slug":14,"type":15},{"name":2677,"slug":123,"type":15},"Python","2026-05-15T06:18:29.266429",{"slug":2680,"name":2680,"fn":2681,"description":2682,"org":2683,"tags":2684,"stars":25,"repoUrl":26,"updatedAt":2692},"rocm-kernels","build optimized Triton kernels for AMD GPUs","Provides guidance for writing and benchmarking optimized Triton kernels for AMD GPUs (MI355X, R9700) on ROCm, targeting HuggingFace diffusers (LTX-Video, SD3, FLUX) and transformers. Core kernels: RMSNorm, RoPE 3D, GEGLU, AdaLN. Includes XCD swizzle, autotune, diffusers integration patterns, and LTX-Video pipeline injection.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2685,2686,2687,2688,2691],{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"name":13,"slug":14,"type":15},{"name":2689,"slug":2690,"type":15},"ROCm","rocm",{"name":17,"slug":18,"type":15},"2026-04-16T05:06:54.179351",{"slug":4,"name":4,"fn":5,"description":6,"org":2694,"tags":2695,"stars":25,"repoUrl":26,"updatedAt":27},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2696,2697,2698,2699],{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"items":2701,"total":2868},[2702,2720,2734,2751,2765,2776,2789,2804,2818,2828,2841,2853],{"slug":2703,"name":2703,"fn":2704,"description":2705,"org":2706,"tags":2707,"stars":2717,"repoUrl":2718,"updatedAt":2719},"train-sentence-transformers","train sentence-transformers models","Train or fine-tune sentence-transformers models across `SentenceTransformer` (bi-encoder; dense or static embedding model; for retrieval, similarity, clustering, classification, paraphrase mining, dedup, multimodal), `CrossEncoder` (reranker; pair scoring for two-stage retrieval \u002F pair classification), and `SparseEncoder` (SPLADE, sparse embedding model; for learned-sparse retrieval). Covers loss selection, hard-negative mining, evaluators, distillation, LoRA, Matryoshka, and Hugging Face Hub publishing. Use for any sentence-transformers training task.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2708,2709,2710,2713,2714],{"name":20,"slug":21,"type":15},{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},"LLM","llm",{"name":2677,"slug":123,"type":15},{"name":2715,"slug":2716,"type":15},"Search","search",18914,"https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fsentence-transformers","2026-05-08T05:09:16.820066",{"slug":2721,"name":2721,"fn":2722,"description":2723,"org":2724,"tags":2725,"stars":2731,"repoUrl":2732,"updatedAt":2733},"trl-training","train and fine-tune LLMs with TRL","Train and fine-tune transformer language models using TRL (Transformers Reinforcement Learning). Supports SFT, DPO, GRPO, KTO, RLOO and Reward Model training via CLI commands.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2726,2727,2728,2729,2730],{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},{"name":2677,"slug":123,"type":15},18850,"https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftrl","2026-04-06T18:25:32.746828",{"slug":2735,"name":2735,"fn":2736,"description":2737,"org":2738,"tags":2739,"stars":2748,"repoUrl":2749,"updatedAt":2750},"hf-cli","manage Hugging Face Hub resources via CLI","Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and more on the Hugging Face Hub. Use when: handling authentication; managing local cache; managing Hugging Face Buckets; running or scheduling jobs on Hugging Face infrastructure; managing Hugging Face repos; discussions and pull requests; browsing models, datasets and spaces; reading, searching, or browsing academic papers; managing collections; querying datasets; configuring spaces; setting up webhooks; or deploying and managing HF Inference Endpoints. Make sure to use this skill whenever the user mentions 'hf', 'huggingface', 'Hugging Face', 'huggingface-cli', or 'hugging face cli', or wants to do anything related to the Hugging Face ecosystem and to AI and ML in general. Also use for cloud storage needs like training checkpoints, data pipelines, or agent traces. Use even if the user doesn't explicitly ask for a CLI command. Replaces the deprecated `huggingface-cli`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2740,2743,2746,2747],{"name":2741,"slug":2742,"type":15},"CLI","cli",{"name":2744,"slug":2745,"type":15},"Datasets","datasets",{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},10861,"https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fskills","2026-04-06T18:25:34.020855",{"slug":2752,"name":2752,"fn":2753,"description":2754,"org":2755,"tags":2756,"stars":2748,"repoUrl":2749,"updatedAt":2764},"hf-cloud-aws-context-discovery","discover local AWS environment context","Discover the user's local AWS context (active profile, region, account ID, caller identity) at the start of any AWS task. Use this skill before any other AWS work — deploying to SageMaker, creating resources, calling AWS APIs, or anything that touches an AWS account. Use it especially when the user has not specified a region or profile explicitly, when they say things like \"use my AWS account\", \"deploy to AWS\", \"use my profile\", or when about to make any AWS CLI or SDK call. Never guess the region or account ID — always use this skill to read it from the local configuration first.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2757,2760,2761],{"name":2758,"slug":2759,"type":15},"AWS","aws",{"name":2741,"slug":2742,"type":15},{"name":2762,"slug":2763,"type":15},"Configuration","configuration","2026-07-08T05:55:33.716099",{"slug":2766,"name":2766,"fn":2767,"description":2768,"org":2769,"tags":2770,"stars":2748,"repoUrl":2749,"updatedAt":2775},"hf-cloud-python-env-setup","set up Python environments for AWS","Set up an isolated Python environment for SageMaker \u002F AWS work, with the right Python version and current boto3. Use this skill whenever Python code will be executed for a SageMaker deployment, training job, or any AWS automation — including when about to run `pip install`, when about to invoke `boto3`, when creating or activating a virtualenv, or when the user asks to \"set up the environment\". Never use system Python and never `pip install` into it. Always isolate. This skill prevents the most common failure modes: wrong Python version, dependency conflicts, and stale SDKs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2771,2772,2773,2774],{"name":23,"slug":24,"type":15},{"name":2758,"slug":2759,"type":15},{"name":2660,"slug":2661,"type":15},{"name":2677,"slug":123,"type":15},"2026-07-08T05:55:32.505017",{"slug":2777,"name":2777,"fn":2778,"description":2779,"org":2780,"tags":2781,"stars":2748,"repoUrl":2749,"updatedAt":2788},"hf-cloud-sagemaker-deployment-planner","plan model deployments to Amazon SageMaker","Plan and coordinate the deployment of a model to Amazon SageMaker AI. Use this skill whenever the user wants to deploy, host, serve, or expose a model on SageMaker or AWS — including phrases like \"deploy a model\", \"host this LLM on AWS\", \"serve this embedding model\", \"deploy a reranker\", \"deploy a text-to-image \u002F diffusion model\", \"host this for async inference\", \"create an endpoint\", \"serve my fine-tuned model\", or any request that involves making a model available for inference on AWS. Use this even when the user is vague (e.g. \"I just want to get this running on AWS, you figure it out\"). Works for text-generation LLMs, embedding models, rerankers, classifiers, text-to-image \u002F diffusion models — picks the right serving stack and chooses between real-time and async inference. This is the entry-point skill for SageMaker deployment work — it asks clarifying questions, picks a deployment pathway, and coordinates the other deployment skills.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2782,2783,2784,2787],{"name":23,"slug":24,"type":15},{"name":2758,"slug":2759,"type":15},{"name":2785,"slug":2786,"type":15},"Deployment","deployment",{"name":9,"slug":2663,"type":15},"2026-07-08T05:55:37.387689",{"slug":2790,"name":2790,"fn":2791,"description":2792,"org":2793,"tags":2794,"stars":2748,"repoUrl":2749,"updatedAt":2803},"hf-cloud-sagemaker-iam-preflight","configure SageMaker IAM roles","Ensure a usable SageMaker execution role exists before deploying or training. Use this skill whenever about to create a SageMaker endpoint, model, training job, or any resource that requires an execution role. Use it especially when the user has not provided a role ARN explicitly, when scripts are about to call `iam:CreateRole`, or when an AccessDenied error mentions an IAM action. Never blindly call `iam:CreateRole` — always check for existing roles first. This skill prevents the most common SageMaker deployment failure: trying to create IAM resources from an SSO principal that has no IAM write permissions.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2795,2796,2797,2800],{"name":23,"slug":24,"type":15},{"name":2758,"slug":2759,"type":15},{"name":2798,"slug":2799,"type":15},"Permissions","permissions",{"name":2801,"slug":2802,"type":15},"Security","security","2026-07-08T05:55:34.948771",{"slug":2805,"name":2805,"fn":2806,"description":2807,"org":2808,"tags":2809,"stars":2748,"repoUrl":2749,"updatedAt":2817},"hf-cloud-sagemaker-production-defaults","create production-ready SageMaker endpoints","Create a SageMaker endpoint (real-time or async) with autoscaling, CloudWatch alarms, and tagging enabled by default. Use this skill whenever about to create a SageMaker endpoint, write deployment code that calls `create_endpoint`, or finalize a deployment after the image URI and IAM role are known. Provides deploy.py for real-time endpoints and deploy_async.py for async endpoints (with genuine scale-to-zero support). This is the last step in the SageMaker deployment workflow. Never generate a bare `create_endpoint` call without these defaults — endpoints without autoscaling or alarms are demos, not deployments.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2810,2811,2812,2813,2814],{"name":23,"slug":24,"type":15},{"name":2758,"slug":2759,"type":15},{"name":2785,"slug":2786,"type":15},{"name":9,"slug":2663,"type":15},{"name":2815,"slug":2816,"type":15},"Monitoring","monitoring","2026-07-08T05:55:38.664702",{"slug":2819,"name":2819,"fn":2820,"description":2821,"org":2822,"tags":2823,"stars":2748,"repoUrl":2749,"updatedAt":2827},"hf-cloud-serving-image-selection","select SageMaker serving containers","Pick the right serving container for a SageMaker model deployment and find its current image URI. Use this skill whenever about to deploy a model to a SageMaker endpoint and an image URI needs to be chosen — including when the user says \"deploy this LLM\", \"host this HuggingFace model\", \"serve this fine-tuned model\", \"deploy this embedding model\", \"host a reranker\", \"serve a sentence-transformers model\", or when about to hardcode any container URI in deployment code. HuggingFace-curated Deep Learning Containers are ALWAYS preferred: HuggingFace vLLM (LLMs and generative rerankers), HuggingFace vLLM-Omni (multimodal), TEI (embeddings\u002Fcross-encoder rerankers), HF Inference Toolkit (other transformers). Generic images (AWS vLLM, DJL-LMI, SGLang) are used only when no HuggingFace image is compatible — never merely because they carry a newer version. Never hardcode a container URI from memory and never default to TGI. Prevents stale-image failures and wrong-region URIs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2824,2825,2826],{"name":23,"slug":24,"type":15},{"name":2758,"slug":2759,"type":15},{"name":2785,"slug":2786,"type":15},"2026-07-08T05:55:36.173465",{"slug":2829,"name":2829,"fn":2830,"description":2831,"org":2832,"tags":2833,"stars":2748,"repoUrl":2749,"updatedAt":2840},"hf-mcp","access Hugging Face Hub via MCP","Use Hugging Face Hub via MCP server tools. Search models, datasets, Spaces, papers. Get repo details, fetch documentation, run compute jobs, and use Gradio Spaces as AI tools. Available when connected to the HF MCP server.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2834,2835,2836,2837],{"name":2744,"slug":2745,"type":15},{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},{"name":2838,"slug":2839,"type":15},"MCP","mcp","2026-04-06T18:25:50.364185",{"slug":2842,"name":2842,"fn":2843,"description":2844,"org":2845,"tags":2846,"stars":2748,"repoUrl":2749,"updatedAt":2852},"hf-mem","estimate memory for Hugging Face models","Hugging Face CLI to estimate the required memory to load Safetensors or GGUF model weights for inference from the Hugging Face Hub",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2847,2848,2849,2850,2851],{"name":23,"slug":24,"type":15},{"name":2741,"slug":2742,"type":15},{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},{"name":13,"slug":14,"type":15},"2026-06-13T07:23:57.101435",{"slug":2854,"name":2854,"fn":2855,"description":2856,"org":2857,"tags":2858,"stars":2748,"repoUrl":2749,"updatedAt":2867},"huggingface-best","find and compare Hugging Face models","Use when the user asks about finding the best, top, or recommended model for a task, wants to know what AI model to use, or wants to compare models by benchmark scores. Triggers on: \"best model for X\", \"what model should I use for\", \"top models for [task]\", \"which model runs on my laptop\u002Fmachine\u002Fdevice\", \"recommend a model for\", \"what LLM should I use for\", \"compare models for\", \"what's state of the art for\", or any question about choosing an AI model for a specific use case. Always use this skill when the user wants model recommendations or comparisons, even if they don't explicitly mention HuggingFace or benchmarks.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2859,2862,2863,2864],{"name":2860,"slug":2861,"type":15},"Analytics","analytics",{"name":9,"slug":2663,"type":15},{"name":2711,"slug":2712,"type":15},{"name":2865,"slug":2866,"type":15},"Research","research","2026-04-24T05:09:45.870658",37]