debug-cuda-crash

debug-cuda-crash is a skill for Claude Code, Codex from sgl-project/sglang. It costs 24 tokens per session (5,261 once invoked), scanned A, original, Apache-2.0.

A debugging workflow for CUDA crashes in SGLang using kernel API logging. CUDA is the software layer used to run work on NVIDIA GPUs; the logging records inputs before a GPU operation that may crash.

In plain words
What is it for?
Investigating illegal memory access, device-side assertions, out-of-bounds errors, and numerical problems at SGLang’s attention, linear, quantization, and custom GPU-operation boundaries.
Why use it?
GPU errors can terminate a process before ordinary debug output is written. Recording tensor shapes, data types, values, and possible NaN or infinity values preserves clues about the cause.

Skill for Claude CodeCodex

About the project

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.

sgl-project/sglang · 35,483 stars · on GitHub · sglang.io

Install

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.

agentmods
npx agentmods add skills/sgl-project/sglang/debug-cuda-crash
Any agent
npx skills add sgl-project/sglang --skill debug-cuda-crash
Clone the repo
git clone --depth 1 https://github.com/sgl-project/sglang

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for debug-cuda-crash

README.md
[![agentmods](https://agentmods.dev/badge/skills/sgl-project/sglang/debug-cuda-crash.svg)](https://agentmods.dev/skills/sgl-project/sglang/debug-cuda-crash)
Your own site
<a href="https://agentmods.dev/skills/sgl-project/sglang/debug-cuda-crash"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/debug-cuda-crash.svg" alt="Measured on agentmods" height="20"></a>
Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00024 $0.05261
Opus 5 $0.00012 $0.02631
Sonnet 5 $0.00005 $0.01052
Haiku 4.5 $0.00002 $0.00526

Measured 6d ago against content hash 748f8a4449b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

debug-cuda-crash 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 6d 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.

.claude/skills/debug-cuda-crash/SKILL.md · 658 lines

How it starts

The opening of the file, as written. The whole thing — 658 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tutorial: Debugging CUDA Crashes with Kernel API Logging

This tutorial shows you how to debug CUDA crashes and errors in SGLang using the @debug_kernel_api logging decorator.

Goal

When your code crashes with CUDA errors such as illegal memory access, device-side assert, out-of-bounds, or NaN/Inf, use kernel API logging to:

  • Capture input tensors BEFORE the crash occurs
  • Understand what data caused the problem
  • Track tensor shapes, dtypes, and values through the call boundary that triggered the crash
  • Detect numerical issues such as NaN, Inf, or obviously wrong shapes

Why Use Kernel API Logging?

Problem: CUDA errors often crash the program before normal debugging output is flushed.

Solution: SGLang's @debug_kernel_api decorator logs inputs before execution, so you can still see what caused the crash even after the program aborts.

What Is Covered?

The current logging coverage focuses on the highest-value kernel boundaries in SGLang:

  • Custom ops registered through register_custom_op(...)
  • External custom ops registered through register_custom_op_from_extern(...)
  • LLM attention, linear, quantization, and multi-platform wrapper entry points
  • Diffusion attention impl, linear, rotary, and custom-op wrapper entry points
  • Selected direct torch.ops.sglang.* hotspots and model-specific bypasses

This means the logging is useful for both LLM and diffusion kernel debugging, but it does not automatically cover every pure PyTorch call in the repository.

Step 1: Enable Kernel API Logging

Basic Logging (Function Names Only)

export SGLANG_KERNEL_API_LOGLEVEL=1
export SGLANG_KERNEL_API_LOGDEST=stdout

python my_script.py

Output:

================================================================================
[2026-03-19 00:47:06] SGLang Kernel API Call: RMSNorm.forward
================================================================================
[2026-03-19 00:47:06] SGLang Kernel API Call: sglang.quant_method.UnquantizedLinearMethod.apply
================================================================================
[2026-03-19 00:47:06] SGLang Kernel API Call: sglang.custom_op.fused_inplace_qknorm

Read the full file on GitHub · 658 lines

Changes

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.

  1. 6d ago First seen · 658 lines · 24 tokens per session scan A 748f8a4449b4

Subscribe to this mod's changes

debug-cuda-crash is a skill published in the GitHub repository sgl-project/sglang (35,483 stars, last pushed today), licensed Apache-2.0. It adds 24 tokens to every session and 5,261 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.

Related

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…

NVIDIA/TensorRT-LLM · 171 tokens

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.

NVIDIA/TensorRT-LLM · 52 tokens

llama-factory

Expert guidance for fine-tuning LLMs with LLaMA-Factory - WebUI no-code, 100+ models, 2/3/4/5/6/8-bit QLoRA, multimodal support.

davila7/claude-code-templates · 51 tokens

mooncake-api

Help users work with the Mooncake Python APIs for distributed storage and high-performance data transfer. Use when working with Mooncake Store (distributed KV cache), Transfer Engine (RDMA/TCP transfers), service setup (master, metadata server), PyTorch tensors in the Store, zero-copy/buffer management, batch…

kvcache-ai/Mooncake · 122 tokens

release-notes

Draft concise release notes.

ollama/ollama · 9 tokens

mooncake-ci-local

Run Mooncake pre-PR local validation through scripts/runcitest.sh. Use this skill whenever the user wants to validate a branch before opening or submitting a PR, run local CI, run ci test, check changes before PR, reproduce GitHub Actions locally, or force a full pre-submit verification. Trigger on phrases like "提交 PR…

kvcache-ai/Mooncake · 108 tokens