debug-kernel-crash
Debug GPU kernel crashes in SGLang (CUDA and ROCm) using @debug_kernel_api logging — illegal memory access, device assert, NaN/Inf, wrong shapes.
Skill by yichiche
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/yichiche-debug-kernel-crash
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, testing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/debug-kernel-crash
What's inside
- Skill name
debug-kernel-crash- Description
- Debug GPU kernel crashes in SGLang (CUDA and ROCm) using @debug_kernel_api logging — illegal memory access, device assert, NaN/Inf, wrong shapes. Use when a server or kernel test crashes before normal debug output flushes.
- License
- MIT
- Instructions
- 119 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Debug Kernel Crashes with API Logging Adapted from upstream `debug-cuda-crash` skill. Works on both CUDA and ROCm (ROCm reports device as `cuda:N` in PyTorch). ## Goal When code crashes with illegal memory access, device-side assert, OOB, or NaN/Inf: - Capture input tensors **before** the crash - Track shapes, dtypes, values at the kernel boundary that triggered it - Detect NaN/Inf or obviously wrong shapes ## Why kernel API logging? CUDA/HIP errors often abort before stdout flushes. `@debug_kernel_api` logs inputs **before** execution. ## What is covered - Custom ops via `register_custom_op(...)` / `register_custom_op_from_extern(...)` - LLM attention, linear, quantization, multi-platform wrappers - Selected `torch.ops.sglang.*` hotspots Does **not** cover every pure PyTorch call — only decorated kernel boundaries. ## Step 1: Enable logging ### Level 1 — function names only ```bash export SGLANG_KERNEL_API_LOGLEVEL=1 export SGLANG_KERNEL_API_LOGDEST=stdout # launch server or run test bash run_qwen3.5_mxfp4.sh 2>&1 | tee /tmp/kernel_api.log ``` ### Level 3 — inputs with metadata (shapes, dtypes) ```bash export SGLANG_KERNEL_API_LOGLEVEL=3 export SGLANG_KERNEL_API_LOGDEST=/tmp/debug.log ``` ### Level 5 — tensor statistics (min/max/mean, nan_count, inf_count) ```bash export SGLANG_KERNEL_API_LOGLEVEL=5 export SGLANG_KERNEL_API_LOGDEST=/tmp/debug.log ``` Start at level 3. Escalate to 5 only on the last few calls before crash (level 5 is slow). ## Step 2: Reproduce minimally 1. Reduce to smallest repro: single request, conc=1, short prompt 2. Disable cuda graph if crash is graph-specific: ```bash --disable-cuda-graph --disable-prefill-cuda-graph ``` 3. On MI355, note which backend is active (`SGLANG_USE_AITER`, `_use_aiter` path) ## Step 3: Read the log Find the **last successful kernel call** before crash. Check: | Signal | Likely cause | |--------|-------------| | Wrong shape on last call | Dispatch bug, incorrect M/N/K | | `nan_count > 0` or `inf_count > 0` | Numerical instability upstream | | Shape jumps between calls | Batch composition change mid-forward | | Missing expected call | Wrong code path taken (check `_use_aiter` / `_is_hip` gates) | ## Step 4: Bisect the call chain If the crash is deep in aiter: ```bash # Run aiter op_test in isolation cd /sgl-workspace/aiter python op_tests/test_<op>.py -v ``` If in SGLang Triton: ```python # Minimal script at the failing M import torch # call kernel directly at M=1 and M=8 ``` Use `/kl-consistency-test` standalone repro pattern (M=1 vs M=288) for batch-invariance crashes. ## Step 5: ROCm-specific notes - HIP errors surface as `CUDA error` in PyTorch — same logging env vars work - `rocgdb` / `HSA_ENABLE_DEBUG=1` for native HIP crashes outside Python - Check `dmesg` for GPU page fault after hard crash - Container OOM vs GPU OOM: `rocm-smi` shows VRAM; host shows if process was killed ## Common crash patterns on MI355 | Pattern | Check | |---------|-------| | MoE dispatch shape mismatch | `topk_ids` shape vs expert count, EP size | | FP8 block scale wrong dims | `scale` tensor M/N alignment with CK kernel | | Attention workspace too small | `max_seq_len`, page size, batch size interaction | | aiter .so stale after rebuild | Re-run `python setup.py develop` in aiter | ## Related skills | Skill | Use when | |-------|----------| | `/kl-consistency-test` | Crash during KL repro; batch-invariance | | `/implement-kernel` | Fix identified after bisect | | `/validate-pr` | Re-validate after fix | Upstream reference: https://github.com/sgl-project/sglang/tree/main/.claude/skills/debug-cuda-crash
From yichiche/agent-box, MIT.
More from yichiche/agent-box
- 0.600score
gfx950-asm-development
yichiche
Develop, validate, and tune hand-written AMD gfx950 assembly kernels, with rocprof profiling.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
commit-push
yichiche
Commit (if needed) and push to the user's fork, with repo-aware remote selection and user confirmation before push.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
implement-kernel
yichiche
Implement a kernel optimization for SGLang on MI355/ROCm.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
gpu-status
yichiche
Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang.
SkillAFreshness: A★ 2Claude Code +9 - 0.595score
generate-profile
yichiche
Generate an e2e profiling trace of an SGLang server run.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
abox-live
yichiche
Monitor Claude agents running inside your containers, from the host or phone — the single entry point (absorbed the old `abox`).
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
pr-conflict-fix
yichiche
Resolve a conflicting GitHub PR inside a throwaway container built from an image you name.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
commit-push-pr
yichiche
Commit, push, and create a PR in one flow — checks state at each stage, confirms push target, collects accuracy/benchmark data, drafts PR in HackMD format for…
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
compare-kernels
yichiche
Compare kernel categories and timings between two trace analysis Excel files.
SkillAFreshness: A★ 2Claude Code +9 - 0.589score
ci-analysis
yichiche
Analyze GitHub Actions CI failures for a pull request: trace root-cause jobs vs fast-fail cascades (check-pr-test-health), fetch job logs with gh, attribute…
SkillAFreshness: A★ 2Claude Code +9 - 0.585score
pr-ci-watch
yichiche
Watch a list of sgl-project/sglang PRs on two cadences (daily, or high-priority every 2h) and babysit them — re-run red NVIDIA CI only after /ci-analysis…
SkillAFreshness: A★ 2Claude Code +9 - 0.557score
create-new-rc
yichiche
Start a persistent Claude Code Remote Control session on the GPU host (Command Center) for phone/laptop monitoring of container agents.
SkillBFreshness: B★ 2Claude Code +9
Signals
- Stars
- 2
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 21, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/yichiche/agent-box
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from yichiche
- 0.600score
gfx950-asm-development
yichiche
Develop, validate, and tune hand-written AMD gfx950 assembly kernels, with rocprof profiling.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
implement-kernel
yichiche
Implement a kernel optimization for SGLang on MI355/ROCm.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
commit-push
yichiche
Commit (if needed) and push to the user's fork, with repo-aware remote selection and user confirmation before push.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
gpu-status
yichiche
Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang.
SkillAFreshness: A★ 2Claude Code +9 - 0.595score
generate-profile
yichiche
Generate an e2e profiling trace of an SGLang server run.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
commit-push-pr
yichiche
Commit, push, and create a PR in one flow — checks state at each stage, confirms push target, collects accuracy/benchmark data, drafts PR in HackMD format for…
SkillAFreshness: A★ 2Claude Code +9
Cite this page
debug-kernel-crash skill. Agent Mart. https://agentmart.dev/skills/yichiche-debug-kernel-crash (last updated 2026-10-24)