Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/sgl-project/sglang/add-jit-kernelnpx skills add sgl-project/sglang --skill add-jit-kernelgit clone --depth 1 https://github.com/sgl-project/sglangWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00027 | $0.11289 |
| Opus 5 | $0.00014 | $0.05645 |
| Sonnet 5 | $0.00005 | $0.02258 |
| Haiku 4.5 | $0.00003 | $0.01129 |
Grade A, and why
add-jit-kernel scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 706 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Tutorial: Adding a New JIT Kernel to SGLang
This tutorial walks through adding a simple element-wise scale operation as a JIT kernel. We'll implement scale(x, factor) = x * factor to demonstrate the complete workflow.
Goal
Add a new operation that scales each element of a tensor by a scalar factor:
- Input: tensor
x(CUDA) and scalarfactor(float, passed at runtime) - Output:
x * factor(element-wise), allocated internally - Supported dtypes: FP16 (
torch.float16), BF16 (torch.bfloat16), FP32 (torch.float32)
When to use JIT vs AOT (sgl-kernel)
- JIT (
jit_kernel): prefer this first for kernels that do not depend on CUTLASS or another large C++ project. It is the default choice for lightweight kernels that benefit from rapid iteration and first-use compilation. - AOT (
sgl-kernel): prefer this when the kernel does depend on CUTLASS or another large C++ project, or when it should live inpython/sglang/kernels/aot/and participate in the wheel build / torch op registration flow. - Exception: kernels that depend on
flashinfer, or on CUTLASS that is already provided throughflashinfer, can still be implemented asjit_kernel.
Conventions
These hold for every step below.
namespace sglangis where JIT code lives. Open it after the include block and close it at the end of the file, with the device kernels, traits and host wrapper inside. The sharedhost::/device::helpers are nested in it too, so they resolve unqualified.load_jitemits theTVM_FFI_DLL_EXPORT_TYPED_FUNCwrapper insidenamespace sglangas well, so thekernel_nameyou pass from Python needs nosglang::prefix.- Check where the check is cheapest:
static_assert> C++ host check > cached Python > per-call Python. Anything fixed at compile time is astatic_assert. Anything about the tensors is aTensorMatcher/CHECK_HOSTin the C++ launcher, free next to a kernel launch. A check Python cannot delegate goes inside the@cache_oncemodule factory, where it runs once per specialisation. What remains in the per-call entry point costs interpreter time on every forward, so it should be nothing but picking the module and allocatingout. - Fixed-width integer types. Prefer
int32_t/int64_t/uint32_t/size_toverint,long, orlong long, so an index has the same width on both sides of the FFI boundary. Bareintis fine only where the width plainly cannot matter — an unrolled loop counter over aconstexprbound, a templateintparameter. Shapes arrive asint64_t(SymbolicSize::unwrap()); narrowing touint32_tfor in-kernel indexing is a deliberate act, so write thestatic_castexplicitly and only where the range is known. - Doxygen comments in C++. Document exported entities with
///or/** ... */blocks using\brief,\param,\tparam,\return, the wayinclude/sgl_kernel/does.python -m sglang.kernels.jitwritesCommentFormat: Doxygeninto.clangdwhen clangd is 21 or newer, so these render on hover in the editor. Plain//remains fine for implementation notes inside a function body. - ASCII only in C++ and CUDA sources. Write
--,->,<=instead of—,→,≤, including in comments.grep -nP '[^\x00-\x7F]' <file>before committing. const T* __restrict__for read-only pointers. This is whatcsrc/does throughout, and it lets the compiler emit non-coherent (LDG) loads.- Watch the register budget. For memory-bound kernels, keep to roughly 64 registers per thread so occupancy does not become the limit. Build once with
extra_cuda_cflags=["-Xptxas", "-v"]to see the actual count, and prefer recomputing a value over letting it spill.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 706 lines · 27 tokens per session scan A dce0427ee99d
add-jit-kernel is a skill published in the GitHub repository sgl-project/sglang (32,926 stars, last pushed yesterday), licensed Apache-2.0. It adds 27 tokens to every session and 11,289 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
perf-host-analysis
Analyze host/CPU overhead in TensorRT-LLM inference from nsys traces. Detect whether host overhead is the bottleneck using GPU idle ratio, host prep exposed ratio, and per-phase evidence. For regressions, isolate forward steps via allreduce/NVTX patterns, compare host operation breakdowns across versions, and identify…
perf-host-optimization
Profiles and optimizes TensorRT-LLM host/CPU overhead using lineprofiler (with nsys support planned). Runs iterative profile-analyze-optimize-validate rounds. Use when GPU utilization is low or optimizing PyExecutor throughput.
trtllm-codebase-exploration
Systematic approach to exploring the TensorRT-LLM codebase before implementing new features or optimizations. Teaches how to discover existing infrastructure, trace code paths, and avoid reimplementing what already exists. Derived from real mistakes where 250 lines of code were written and deleted because existing…
add-cuda-kernel
Step-by-step tutorial for adding new CUDA kernels to FlashInfer.
debug-cuda-crash
Tutorial for debugging CUDA crashes using API logging.
cuopt-skill-evolution
After solving a non-trivial problem, detect generalizable learnings and propose skill updates. Always active — applies to every interaction.