kernel-triton-writing

Create verifiable Triton GPU kernels for deep learning compute patterns.

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill kernel-triton-writing-yo-steven
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kernel-triton-writing
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/TensorRT-LLM/kernel-triton-writing
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill kernel-triton-writing-yo-steven

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and scripts (resource) components.

What problem does it solve?

Helps you design, implement, and verify high-correctness Triton (@triton.jit) GPU kernels for common deep-learning compute patterns.

Core Features & Use Cases

  • Triton-specific correctness guardrails: enforced rules for masking, dtype casting (especially FP16/BF16 + fp32 requirements for transcendentals), and safe integer semantics (C-style // and %).
  • Workflow-driven kernel development: operator routing guidance plus phased instructions (design → implement → verify → optional benchmark) tuned for Triton-only use cases.
  • Production-oriented kernel contract: requires companion exports like kernel_fn, reference_fn, and get_inputs(), and mandates running scripts/verify_kernel.py for correctness.

Quick Start

Ask for a Triton implementation by specifying the operator in your request, for example: "Write a Triton kernel for fused softmax + LayerNorm over a 2D tensor and include correctness verification against a PyTorch reference."

Frequently Asked Questions about kernel-triton-writing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Triton kernel that handles FP16 and BF16 mixed precision correctly?

To write correct Triton kernels with mixed precision, you must enforce FP16/BF16 casting rules and use fp32 accumulators for transcendentals. This ensures numerical correctness while maintaining GPU kernel performance across deep learning compute patterns.

What is the best way to verify Triton GPU kernel numerical correctness against PyTorch?

The best way to verify Triton GPU kernel correctness is to run a validation script against a PyTorch reference implementation. This requires exporting a kernel_fn, reference_fn, and get_inputs() to test real tensor shapes and dtypes for numerical and boundary correctness.

How do I implement safe masking and integer indexing in Triton kernels?

To implement safe masking and integer indexing in Triton kernels, apply proper masking for loads and stores, and use C-style semantics for integer operations like floor division (//) and modulo (%). This prevents out-of-bounds memory access during GPU kernel execution.

Does this workflow support writing flash attention and tiled GEMM kernels in Triton?

Yes, this workflow supports writing and verifying flash attention and tiled GEMM kernels with autotune in Triton. It provides specific guidance for these deep learning compute patterns alongside fused elementwise ops and reductions.

When should I use Triton kernels instead of CUDA C++ or higher-level library calls?

You should use Triton kernels when you explicitly need @triton.jit kernel code for fused deep learning operations rather than CUDA C++ or higher-level library calls. This approach is ideal when you must ensure numerical correctness for real tensor shapes and dtypes.