What problem does it solve?
Developing and optimizing Metal GPU kernels in the MNN inference engine involves many silent-failure traps: stale build artifacts, pipeline cache hits, macro alias conflicts, memory aliasing in fused dispatches, and misleading profiling data. This Skill routes engineers to the right sub-document so kernel changes, operator fusion, and runtime scheduling work are done correctly and verified with proper A/B methodology.
Core Features & Use Cases
- Kernel development standards: Naming conventions, shader string organization, preprocessor macro variants with four-point synchronization, Execution skeleton registration, and six common pitfalls (macro aliasing, dispatcher gaps, fp16 scratch buffer sizing).
- Optimization knowledge base: Documented GEMV, GEMM, and Attention optimizations with measured data (deferred dequant +28%, SPLIT_K_2, causal-tri dispatch, flash-attention routing) across M3/M4/M5 Apple GPUs.
- Operator fusion pipeline: Full chain from Python export declarations through converter passes to Metal single-dispatch leader/follower assembly, including memory aliasing checks and troubleshooting checklists.
- Runtime scheduling and verification: Fence, content-cache, H2D upload, encode replay guidance, plus a mandatory build/test/correctness matrix and an environment variable registry.
- Use Case: When adding a new quantized GEMV kernel for Qwen model decode on Apple Silicon, consult the kernel-dev sub-doc for naming and macro sync rules, then follow the build-and-test sub-doc's forced recompile and greedy byte-identical validation flow before trusting any performance numbers.
Quick Start
Ask the assistant to help you add or optimize a Metal kernel in the MNN backend, describing your target model, quantization bit width, and whether the workload is prefill or decode.