用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/microsoft/llm-42 --skill add-sgl-kernel命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | add-sgl-kernel |
| description | Step-by-step tutorial for adding a heavyweight AOT CUDA/C++ kernel to sgl-kernel (including tests & benchmarks) |
sgl-kernel (AOT / Heavyweight)This SKILL is a step-by-step guide for adding a heavyweight CUDA/C++ kernel to sgl-kernel/.
Typical characteristics:
sgl_kernel API and used by higher-level code (including torch.compile)sgl-kernel. If it depends on CUTLASS/FlashInfer/DeepGEMM (or similarly heavy stacks), implement it in sgl-kernel/.python/sglang/jit_kernel. If it is small, has few dependencies, and benefits from rapid iteration, implement it as a JIT kernel instead.In addition, every new kernel must ship with:
Add a new kernel end-to-end, including:
m.def schema + m.impl dispatch)You will typically touch these files/areas:
sgl-kernel/csrc/...sgl-kernel/include/sgl_kernel_ops.hsgl-kernel/csrc/common_extension.ccsgl-kernel/CMakeLists.txt (set(SOURCES ...))sgl-kernel/python/sgl_kernel/... and sgl-kernel/python/sgl_kernel/__init__.pysgl-kernel/tests/test_<op>.pysgl-kernel/benchmark/bench_<op>.pycsrc/csrc/elementwise/csrc/gemm/csrc/attention/csrc/moe/TORCH_CHECK(...))Key points:
include/sgl_kernel_ops.hEdit:
sgl-kernel/include/sgl_kernel_ops.hAdd your function declaration in the appropriate section.
csrc/common_extension.cc (schema + dispatch)Edit:
sgl-kernel/csrc/common_extension.ccInside TORCH_LIBRARY_FRAGMENT(sgl_kernel, m):
m.def(...) with a schema.m.impl(...) for CUDA dispatch.Key points:
torch.compile and for consistent call signatures.int, float), but PyTorch bindings expect int64_t / double, use the project’s recommended shim approach (see sgl-kernel/README.md).CMakeLists.txtEdit:
sgl-kernel/CMakeLists.txtAdd your new .cu / .cc file to the set(SOURCES ...) list.
Key points:
sgl-kernel/python/sgl_kernel/Goal: users can call sgl_kernel.<op>(...).
sgl-kernel/python/sgl_kernel/ (follow existing module organization).sgl-kernel/python/sgl_kernel/__init__.py.Create:
sgl-kernel/tests/test_<op>.pyMinimum coverage:
Skipping by architecture:
@pytest.mark.skipif(..., reason="...") when compute capability requirements apply.Run:
pytest sgl-kernel/tests/test_<op>.py -q
Create:
sgl-kernel/benchmark/bench_<op>.pyFollow the repository convention:
triton.testing.Benchmark + triton.testing.perf_reporttriton.testing.do_bench_cudagraph for timingMinimum benchmark requirements:
sgl_kernel implementationtorch.compile / Triton / FlashInfer)CI / GITHUB_ACTIONSRun:
python sgl-kernel/benchmark/bench_<op>.py
Build:
cd sgl-kernel
make build -j16
If you need to limit host resource usage:
cd sgl-kernel
make build -j1 MAX_JOBS=2 CMAKE_ARGS="-DSGL_KERNEL_COMPILE_THREADS=1"
Validate:
pytest sgl-kernel/tests/test_<op>.py -qpython sgl-kernel/benchmark/bench_<op>.pyCUDA_LAUNCH_BLOCKING=1compute-sanitizer --tool memcheck python ...MAX_JOBS and SGL_KERNEL_COMPILE_THREADSsgl-kernel/analyze_whl_kernel_sizes.pysgl-kernel/README.mdsgl-kernel/include/sgl_kernel_ops.hsgl-kernel/csrc/common_extension.ccsgl-kernel/CMakeLists.txt