mcpField
O
optimization-catalog

optimization-catalog

github.com/pepperu96Development082 installsUpdated 31w ago
Repository

About optimization-catalog

optimization-catalog is a dispatcher skill for reusable cuTile kernel optimization knowledge. It directs kernel designers to shared algorithmic guidance and then to the language-specific catalog and overlays relevant to their implementation.

Key features

  1. 01Routes to shared optimization and anti-pattern catalogs
  2. 02Selects language-specific catalog skills
  3. 03Separates reusable patterns from DSL details
  4. 04Indexes optimizations by profiling conditions
  5. 05Connects metrics to optimization candidates

Use cases

  1. 01Finding kernel optimizations from profiling results
  2. 02Choosing guidance for cutile-dsl or cute-dsl
  3. 03Recording reusable optimization patterns and anti-patterns

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pepperu96/hyper-mla --skill optimization-catalog

After installing, type/optimization-catalogin Claude Code to confirm it loaded.

Details

From the project README

Optimization Catalog Router

Use this skill as a dispatcher. The shared root knowledge base remains the canonical location for algorithmic patterns that transfer across implementation languages. Language-specific overlays capture implementation details tied to a specific DSL or programming model.

Load Order

  1. Read the shared root knowledge under docs/knowledge/optimizations/ and docs/knowledge/anti-patterns/ when the pattern is algorithmic.
  2. Load the language-specific optimization catalog skill for the chosen implementation language.
  3. Read language overlays in docs/knowledge/languages/<language>/... only when the implementation details depend on that surface.

Language-Specific Catalog Skills

Language keyLoad this skillLanguage-specific knowledge root
cutile-dsl/optimization-catalog-cutile-dsldocs/knowledge/languages/cutile-dsl/
cute-dsl/optimization-catalog-cute-dsldocs/knowledge/languages/cute-dsl/

Classification Rule

  • Shared root catalogs are for algorithmic patterns, workload-shape rules, and anti-patterns that transfer across DSLs.
  • Language overlays are for implementation details that depend on a specific API, compiler behavior, code-generation surface, or scheduling model.
  • When in doubt, keep the reusable mechanism in the shared root and add a language-specific overlay only for the implementation surface.

Current Migration State

  • The shared root catalogs in docs/knowledge/optimizations/ and docs/knowledge/anti-patterns/ remain the compatibility-preserving baseline.
  • New language-specific overlays are being added under docs/knowledge/languages/.
  • Existing references to the legacy root paths continue to work during the migration.

Knowledge Base Principles

The goal of this catalog is to build reusable cuTile kernel design knowledge, not to accumulate device folklore.

Every entry must therefore be written as:

  • a pattern or anti-pattern that can transfer across kernels,
  • with a clear context describing when it applies,
  • with explicit performance metrics affected,
  • with evidence separated into local validation, and generalized takeaway when relevant.

Device and architecture facts are encouraged when they sharpen the rule:

  • architecture families such as Blackwell or Hopper,
  • architecture capabilities such as Tensor Cores, TMA, thread block clusters, scheduler behavior, or shared-memory limits,
  • device-level specs such as peak FP16/BF16 TFLOP/s, peak memory bandwidth, ridge point, SM count, registers/SM, or SMEM capacity.

But those facts must be converted into reusable guidance. Entries should avoid collapsing into "kernel X on device Y liked config Z" unless that observation is only being used as evidence for a broader pattern.

How This Catalog Works

  1. Index below maps trigger conditions → optimization → detail file
  2. Orchestrator reads index to pick optimizations based on profiling results
  3. Kernel designer reads detail files to implement specific optimizations
  4. New optimizations: create detail file in docs/knowledge/optimizations/ + add row to index
  5. Failed optimizations: create anti-pattern in docs/knowledge/anti-patterns/ + add row below

Optimization Index

IDOptimizationTrigger ConditionsEst. ImpactPitfallsDetail File
O1Split-KV proportional block allocationDual-path kernel has strongly unbalanced latent vs decompressed work; equal block split leaves one path starvedVery HighRequires a reduction kernel and intermediate tensorsdocs/knowledge/optimizations/split-kv.md
O2Head grouping for shared-operand reuseSame operand is reused across heads (for example latent Z) and Bh=1 produces skinny per-head MMAs or near-zero TC utilizationVery HighRaises register pressure; not appropriate for per-head-only operands like decompressed K/Vdocs/knowledge/optimizations/head-grouping.md
O3Independent path schedulingAfter Split-KV, the latent and decompressed paths still want different streaming granularities or load schedulingLow-MedGains are modest if register pressure and occupancy do not improvedocs/knowledge/optimizations/independent-tiles.md
O4Swizzle schedulingTiled kernel reuses one operand across neighboring CTAs and block order measurably affects L2 localityLowCompute-bound kernels may see only marginal benefit; 1D remap adds index overheaddocs/knowledge/optimizations/swizzle.md
O5Latency hintsLoad/compute overlap tuning is needed after the kernel structure is already sound, and the per-path DRAM pressure differs enough that compiler guidance may help schedulingLowDifficult to isolate; hints are suggestions rather than guaranteesdocs/knowledge/optimizations/latency-hints.md
O6CGA thread block clustersHopper+ kernel has genuine cross-CTA data sharing opportunity or needs to reason correctly about num_ctas semantics and cluster launch behaviorMediumHardware-specific and easy to misuse when there is no real sharing benefitdocs/knowledge/optimizations/cga.md
O7Fast math for online softmaxOnline-softmax loop is heavy on exp2/division, larger tiles collapse compute throughput, and reduced-precision inference math is acceptableHighNot a substitute for sane tiling; gains shrink if spills or bandwidth dominatedocs/knowledge/optimizations/fast-math-online-softmax.md
O8Causal K-loop splitCausal attention has many fully unmasked K-tiles, only diagonal/tail tiles need mask logic, and future tiles can be skippedMedium-HighCan be neutral or negative if masking is no longer material on the target bottleneckdocs/knowledge/optimizations/causal-k-loop-split.md
O9Causal ProgramId remapTriangular work causes wave-tail imbalance across CTAs and a simple launch-order reversal is availableLow-MedSmall gain if work distribution is already uniform or the grid is tinydocs/knowledge/optimizations/causal-program-id-remap.md
O10Adaptive tile and occupancy autotuningBest tile/occupancy point changes with sequence length or device envelope; fixed manual choice underfills short shapes or overcommits long onesHighSearch space can explode if not curated; cannot rescue a structurally broken kerneldocs/knowledge/optimizations/adaptive-tile-autotuning.md
O11Pipeline-driven low-occupancy schedulingLarge unavoidable per-CTA state forces one CTA/SM or very low occupancy, and the kernel must win via overlap and scheduling rather than more resident warpsHighRequires architecture/DSL support for fine-grained scheduling; cannot be faked with a monolithic CTAdocs/knowledge/optimizations/pipeline-driven-low-occupancy.md

Anti-Pattern Index

IDAnti-PatternFailure ModeSourceDetail File
A1Equal block split across heterogeneous paths50/50 block allocation for unequal latent vs decompressed work produces sequential bottlenecks instead of overlapMLA-var6+ V0docs/knowledge/anti-patterns/equal-block-split.md
A2TILE_M=1 combine/decompressionSingle-row combine GEMMs disable Tensor Cores and leave a persistent tail at small sMLA-var6+ V0/V2/V3docs/knowledge/anti-patterns/tile-m-one-combine.md
A3Underfilled persistent concurrencyResident block budgets below the SM count leave the GPU idle and make overlap ineffectiveMLA-var6+ V4docs/knowledge/anti-patterns/underfilled-persistent.md
A4Register-ceiling persistent stagePersistent kernel lands at the register ceiling (255 regs/thread), collapses occupancy, and becomes latency-boundMLA-var6+ V4docs/knowledge/anti-patterns/spill-heavy-persistent.md
A5Blind large-tile portCopying a tile shape from another device without revalidating registers, SMEM, local-memory traffic, and grid size crosses a resource cliffFlashAttention learning chaindocs/knowledge/anti-patterns/blind-large-tile-port.md
A6Uniform causal maskingPaying full causal-mask logic on every K-tile wastes work even though most tiles are fully valid or fully skippedFlashAttention learning chaindocs/knowledge/anti-patterns/uniform-causal-masking.md
A7Sub-16 MMA dimensionShrinking any effective MMA dimension (M, N, or K) below 16 usually breaks Tensor Core coverage and explodes latency instead of fixing occupancyFlashMLA V1 manual probes + Tensor Core shape constraintsdocs/knowledge/anti-patterns/sub-16-mma-dimension.md
A8Blind dataflow flipRewriting a resource-sensitive Tensor Core kernel into an algebraically equivalent operand orientation changes codegen enough to reintroduce spills or worsen SMEM behaviorFlashMLA V1 → V2docs/knowledge/anti-patterns/blind-dataflow-flip.md

Cross-Referencing: Metrics → Optimizations

Profiling Metric StateLikely Optimizations
Equal-duration kernels with obviously unequal workO1 (Split-KV proportional block allocation)
Bh=1 or per-head skinny MMAs on a shared operandO2 (Head grouping)
Dual-path kernel plateaus near the ridge point after Split-KVO3 (Independent path scheduling)
L2 hit < 90% and neighboring CTAs reload the same operand tilesO4 (Swizzle scheduling)
Same kernel structure but different path-level memory pressure suggests compiler scheduling changes may matterO5 (Latency hints)
Cross-CTA data sharing on Hopper+ or confusion about what num_ctas actually controlsO6 (CGA thread block clusters)
Tensor Core/MMA structure is sound, but online-softmax special functions dominate the hot loopO7 (Fast math for online softmax)
Causal kernel still spends meaningful time in mask/control flow because many K-tiles are fully valid and future tiles are fully skippedO8 (Causal K-loop split)
Causal/triangular workload shows tail imbalance across CTAs or waves finish unevenlyO9 (Causal ProgramId remap)
Short shapes underfill the GPU while long shapes prefer different tiles or occupancy hintsO10 (Adaptive tile and occupancy autotuning)
Registers/SMEM force one CTA/SM, eligible warps stay very low, and the kernel is compute-bound but still under-utilizes Tensor CoresO11 (Pipeline-driven low-occupancy scheduling)
Combine stage has TILE_M=1 and TC Util = 0%A2 (TILE_M=1 combine/decompression)
Persistent resident blocks < SM count or waves/SM < 1A3 (Underfilled persistent concurrency)
Persistent stage at 255 regs/thread with single-digit occupancyA4 (Register-ceiling persistent stage)
Imported large tile causes register/SMEM cliffs, local-memory traffic, or abrupt grid shrinkage on the target deviceA5 (Blind large-tile port)
Causal masking logic is paid uniformly across all K-tiles despite obvious fully-valid and fully-skipped regionsA6 (Uniform causal masking)
Candidate tile drives any effective MMA dimension below 16, or Tensor Core FLOPs collapse far below algorithmic FLOPs after a "smaller tile" changeA7 (Sub-16 MMA dimension)
Proposed optimization is only an algebraic operand/dataflow flip, especially near a register or SMEM cliffA8 (Blind dataflow flip)

Knowledge Base Update Protocol

For the full update protocol, detail file template, and step-by-step instructions, load the /orchestration-workflow skill.

Comments

Markdown supported