SGLang is a framework for running inference for large language models and multimodal models, meaning it processes inputs to produce model outputs such as text or other media. It is used to serve and accelerate open AI models and related workloads.
Borrowing it
Nothing to install: this file belongs to sgl-project/sglang. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/sgl-project/sglang/main/.agents/skills/add-jit-kernel/SKILL.mdgit clone --depth 1 https://github.com/sgl-project/sglangWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel)<a href="https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-jit-kernel/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-jit-kernel.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- Snyk pass
- NVIDIA SkillSpector warn
SkillSpector: 1 finding, up to medium
These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →
- medium Prompt Injection · line 42 Subtle instructions detected that may alter agent decision-making or introduce hidden biases.Fix: Review content for implicit steering or bias. Ensure instructions are explicit and align with the skill's stated purpose.
What 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.1 | $0.00032 | $0.13856 |
| Opus 5.5 | $0.00013 | $0.05542 |
| Sonnet 5.5 | $0.00006 | $0.02771 |
| Haiku 4.5 | $0.00003 | $0.01386 |
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 8d ago.
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 — 775 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
Apply kernel-organization for the public operator namespace, logical grouping, lazy registry metadata, and test placement. The implementation tutorial below does not replace that API contract.
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.- Tuning policy belongs in Python; C++ gets the answer, not the decision. For a hyperparameter — split factor, threads per item, block size, vector width, an algorithm variant — prefer (not required) making it a template parameter and letting the
@cache_oncemodule factory choose the value, over a runtimeif/switchin the launcher that picks among pre-instantiated kernels. The kernel then compiles exactly one specialisation and asserts its own preconditions withstatic_assert, while the heuristic that produced the value sits in Python where it is readable, adjustable, and inspectable without recompiling CUDA.store_cache'snum_threadsis the worked example: aget_kernel(num_split)ladder guarded by byte-alignmentif constexprs became one template argument plus a heuristic in_jit_kvcache_module. The exception is a knob that genuinely varies per call with the runtime shape — that has to stay a kernel argument. - 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. namespace detailsis private. Anything inside one is an implementation detail of its own header, free to change without notice. Do not namedetails::from another module, and neverusing namespace details. If you find yourself wanting something in there, that is the signal to promote it to a documented name instead.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; prefer recomputing a value over letting it spill. Run
SGLANG_JIT_LOG_RESOURCE_USAGE=1 SGLANG_JIT_FORCE_RECOMPILE=1to log per-kernel registers, spills and shared memory at INFO. Both halves are load-bearing: a cache hit has no compiler output to report, and passing-Xptxas -vby hand does nothing on its own because the build captures compiler output and replays it only on failure. - Alignment is a contract you enforce, not a property you hope for. A vectorized copy derives its access width from the row size (
load_bytespicks 16B for a 1024B row), but the address it lands on isbase + index * row_stride— and a stride is not constrained by the size.TensorMatcheradmits any stride unless you say otherwise, so a padded cache row silently producesmisaligned address. Every kernel that vectorizes is highly recommended to end its validation with.ensure_alignment(w), wherewis the width the kernel actually uses.
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.
- 8d ago Changed b2366f54cd9c
- 1mo ago Changed · +2 lines 2494ad3d7b9f
- 1mo ago Changed · +30 lines · +5 tokens per session f634ff541bc9
- 1mo ago Changed · +37 lines a33f75c1066a
- 2mo ago 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 (38,324 stars, last pushed today), licensed Apache-2.0. It adds 32 tokens to every session and 13,856 once invoked, about $0.0001 per session on Opus 5.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
running-openmed-ondevice
Run OpenMed models fully on-device with the MLX (Apple Silicon), CoreML (iOS/macOS), or ONNX/WebGPU (cross-platform/browser) backends, including convert-quantize-run workflows. Use when the user wants to deploy OpenMed at the edge, run NER/de-id on Apple Silicon, target iPhone/iPad/Mac, export to ONNX or WebGPU…
opentrons-integration
Official Opentrons Protocol API for OT-2 and Flex robots. Use when writing protocols specifically for Opentrons hardware with full access to Protocol API v2 features. Best for production Opentrons protocols, official API compatibility. For multi-vendor automation or broader equipment control use pylabrobot.
groq-inference
Ultra-fast LLM inference on custom LPU hardware. OpenAI-compatible API at api.groq.com. Lowest latency in the industry (500-1000+ tok/s). Supports chat completions, vision, audio (Whisper STT + TTS), tool calling, JSON mode, and streaming. Free tier available. Inference only — no training.
pylabrobot
Vendor-agnostic lab automation framework. Use when controlling multiple equipment types (Hamilton, Tecan, Opentrons, plate readers, pumps) or needing unified programming across different vendors. Best for complex workflows, multi-vendor setups, simulation. For Opentrons-only protocols with official API…
openhue
Control Philips Hue lights, rooms, and scenes via the OpenHue CLI. Turn lights on/off, adjust brightness, color, color temperature, and activate scenes.
eightctl
Control Eight Sleep pods (status, temperature, alarms, schedules).