rh-runninghub/minimax-h3-multigpu-lightning/debug-cuda-crash
Claude Code and agent skill by rh-runninghub/minimax-h3-multigpu-lightning
- community
Checking that the SKILL.md file is still in the repository.
Call this skill when you need to debug CUDA crashes in SGLang using kernel API logging
Install
npx vskill@latest install rh-runninghub/minimax-h3-multigpu-lightning/debug-cuda-crashSKILL.md
The same SKILL.md was published earlier as rh-runninghub/minimax-h3-multigpu-lightning/debug-cuda-crash.
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)
Output:
This is a real level-1 excerpt captured from Qwen/Qwen3-0.6B.
Detailed Logging (Inputs with Metadata)
Output in debug.log:
This is a real level-3 excerpt captured from Qwen/Qwen3-0.6B.
Full Logging (With Tensor Statistics)
Additional output:
This is a real level-5 excerpt captured from black-forest-labs/FLUX.1-dev.
Crash-Safe Dumps (Inputs Saved Before Execution)
At level 10, SGLang saves the inputs before execution. If the kernel crashes, the dump directory still contains the inputs and exception metadata.
If CUDA graph capture is active, tensor dumps are skipped automatically to avoid capture-time CUDA errors. In that case, you still get the kernel API call log, but not inputs.pt / outputs.pt.
Level-10 dumps are best understood as crash-safe call snapshots. They always preserve the observed call boundary. They do not guarantee one-click replay for every method, because some methods depend on module state that is not serialized into the dump.
Real level-10 dump layout from Qwen/Qwen3-0.6B:
Real metadata.json excerpt:
Step 2: Reproduce an LLM CUDA Crash
Create a temporary reproducer:
What to expect:
- The script exits with a CUDA
device-side assert - The log still contains the last API boundary before the crash
Try the same example at level 3:
Now the log shows tensor metadata before the crash.
Try level 10:
Now you should see:
- A log entry for
sglang.custom_op.mock_llm_cuda_crash - A dump directory with
inputs.pt metadata.jsonshowingexecution_status: "exception"- No
outputs.pt, because the kernel crashed before producing output
For real-model success-path level-10 dumps, it is often easier to temporarily disable CUDA graph and piecewise CUDA graph for the debug run.
Step 3: Reproduce a Diffusion CUDA Crash
Create a temporary diffusion-side reproducer:
Try level 3:
Try level 10:
If your local environment has unrelated FlashInfer import issues, resolve them in the shell before running the example. The example itself does not set any FLASHINFER_* environment variable.
Step 4: Multi-Process Debugging
When running with multiple GPUs or worker processes, use %i in the log path:
This creates separate logs such as:
debug_rank_12345.logdebug_rank_12346.logdebug_rank_12347.logdebug_rank_12348.log
Real multi-process example from a 2-GPU Qwen/Qwen2.5-0.5B-Instruct run:
You should usually do the same for level-10 dump directories:
This avoids multiple ranks writing into the same dump directory tree.
Step 5: Filter Level-10 Dumps
If level 10 is too noisy, restrict dumps to specific APIs:
SGLANG_KERNEL_API_DUMP_INCLUDE and SGLANG_KERNEL_API_DUMP_EXCLUDE use shell-style wildcard matching.
Step 6: Common CUDA Errors and What to Check
Illegal Memory Access or Device-Side Assert
Typical errors:
Use:
Check in the logs:
- ✅ Tensor shapes
- ✅ Tensor dtypes
- ✅ CUDA vs CPU device placement
- ✅ Tensor stride / contiguity
- ✅ Whether the failing call has inputs logged but no outputs logged
Typical shape-mismatch pattern:
This often points to head-dim, hidden-dim, or cache-layout mismatch rather than a random CUDA failure.
NaN or Inf
Use:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsglang/.claude/skills/debug-cuda-crash/SKILL.md
Popularity
- Repository stars
- 99
- Repository forks
- 13
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rh-runninghub/minimax-h3-multigpu-lightning/debug-cuda-crash)