triton-kernel-writing

为 vLLM 编写或审查 Triton 内核的实用指导。涵盖生成代码检查、启动网格、索引与特化、调优流程,以及进行代表性性能验证的建议性步骤。

仓库最近推送
GitHub Stars
97,308
Forks
25,102
Issues / PRs
2,972

预览截图

来自skillπ 实验室的展示

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "triton-kernel-writing":https://skillpi.com/zh/skills/deepskill-450e684b07fe146cd422204ab3a1edd144d8ef27d00ec4511c8b6a9a9efc2601。安装前核对上游来源和版本:https://github.com/vllm-project/vllm。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 vLLM 编写或审查 Triton 内核的实用指导。涵盖生成代码检查、启动网格、索引与特化、调优流程,以及进行代表性性能验证的建议性步骤。

5 下载

介绍来源: third_party · vllm-project · 0.0.1 参考来源

SkillPi 解读

能完成的任务
编写或复核vLLM的Triton内核,同时提供生成码检查,发射网格,索引编制,专业化,调试,以及代表性性能验证等实用指导.
适合谁
来源文档未说明。
输入和输出
来源文档未说明。
软件、账号及付费要求
来源文档未说明。
限制与区别
来源文档未说明。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: triton-kernel-writing
description: Write or review Triton kernels for vLLM, with practical guidance for generated-code inspection, launch grids, indexing, specialization, tuning, and representative performance validation.

Triton Kernel Writing

Implementation

  • Follow the official Triton semantics. Check it when behavior may differ from Python or NumPy, especially type promotion, integer division and modulo, casts, broadcasting, and variable scoping.
  • Use the Triton kernel generated by torch.compile as a possible implementation to inspect. Print Inductor's generated code with TORCH_LOGS="output_code" .venv/bin/python <script> or enable torch._logging.set_logs(output_code=True) before the compiled function runs. Treat generated code as a reference, not as proof of correctness or optimality.
  • Find reasonable defaults for compile-time knobs such as BLOCK_SIZE, or use a small, legible heuristic when workloads need different choices. Use triton.autotune only when tuning is critical to performance, such as for a matrix multiplication. Otherwise prioritize simple code and fast startup.
  • Avoid unintended runtime JIT compilation. Put unimportant runtime integer scalars in do_not_specialize, especially values that alternate between 0 and 1. Pointer alignment also affects specialization: an offset tensor view can trigger a new variant after warmup used an aligned allocation. For scalar-only pointers whose alignment provides no useful optimization, use @triton.jit(do_not_specialize_on_alignment=["end_ptr"]). Retain alignment specialization when vectorized accesses benefit from it. See the Triton JIT options.
  • The Triton compiler does not guarantee safe ordering when a kernel writes to a pointer and subsequently reads from the same pointer. This pattern must have a tl.debug_barrier() between the write and read. The barrier synchronizes threads in the block; it does not synchronize separate program instances.

Launch and Indexing

  • grid[1] and grid[2] must be at most 65,535. Choose or flatten the grid order so those dimensions cannot exceed the limit for supported shapes. For example, num_tokens is commonly 8K or 16K, but users may configure 32K or more. If num_tokens is a grid dimension, it is safe to put it in grid[0] (or tile it).
  • Use int64 for offset arithmetic when an index can exceed 32-bit range, especially for KV-cache addressing. Cast operands before multiplication or addition so an intermediate does not overflow in 32-bit arithmetic.
  • A [num_tokens, num_heads] grid can be a good low-latency mapping for decode, but it can be very slow for prefill. If the kernel serves prefill, consider tiling tokens or otherwise increasing the work and locality per program.

Validation

  • Check correctness at boundary shapes and at sizes that exercise masks and large offsets. Include offset tensor views, not only fresh allocations. Warm aligned buffers, then exercise offset views with vLLM's --jit-monitor-mode error --jit-monitor-verbose to catch missing variants.
  • Choose accumulation and intermediate dtypes explicitly. Test numerically difficult inputs, not only random, well-scaled tensors.
  • Use $kernel-microbenchmark for benchmark construction, measurement, and interpretation.
  • Benchmark a sweep of num_tokens covering decode and representative prefill workloads. Include relevant head counts and dimensions when they affect the launch shape, and do not select an implementation or tuning heuristic from a single setup.
  • Include compilation or autotuning overhead when evaluating startup behavior; report steady-state kernel performance separately.

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 针对vLLM Triton内核编写与审查,解决高性能推理中的核心优化问题
  • 提供生成代码检查、启动网格、索引、特化、调优及性能验证的完整指导
  • 覆盖边界形状验证、数值精度测试和代表性工作负载基准测试
触发精准85/100

亮点

  • 触发词精准覆盖Triton内核编写、审查及性能验证场景
  • description明确指向vLLM特定需求,边界清晰
结构规范90/100

亮点

  • Implementation、Launch and Indexing、Validation三大模块划分清晰
  • 每个模块包含具体指导原则和最佳实践
  • frontmatter完整,文档结构规范
执行可靠88/100

亮点

  • 引用官方Triton语义文档,工具来源明确
  • 覆盖主要异常情况(如JIT编译、指针同步、网格限制)
  • 提供具体验证方法和基准测试指导
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • triton-lang.org

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

来源文档未说明。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。