# Debug CUDA Crashes with FlashInfer Logging

CUDA crashes often hide the inputs and state that caused the failure. This skill uses FlashInfer logging and NVIDIA tools to expose actionable diagnostic evidence.

## Install

```bash
npx skillstore add flashinfer-ai/debug-cuda-crash
```

## Metadata

- Status: approved
- Slug: flashinfer-ai-debug-cuda-crash
- Skillstore revision: r2
- Version status: missing
- Tree hash: d71c5f4da773cd827668c253cee72b4cab1fa699d4d260945de692671f593c34
- Author: flashinfer-ai
- GitHub username: flashinfer-ai
- License: MIT
- Repository: https://github.com/flashinfer-ai/flashinfer/tree/main/.claude/skills/debug-cuda-crash
- Ref: c43861a65bb95efcae259cd161c9d6f4dc7eec6f
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/flashinfer-ai-debug-cuda-crash
- Manifest: https://skillstore.pages.dev/api/skills/flashinfer-ai-debug-cuda-crash/manifest

## Capabilities

- Configures FlashInfer API logging levels and destinations for crash reproduction.
- Explains how to inspect tensor shapes, dtypes, devices, strides, contiguity, and statistics.
- Maps common CUDA failures to focused checks in the captured API log.
- Separates logs by process for multi-GPU and distributed debugging.
- Combines API logging with compute-sanitizer and cuda-gdb workflows.
- Shows selective kernel printf, assertions, and synchronization for lower-level diagnosis.

## Use Cases

- Diagnose inference crashes: Inspect a failing inference workload and compare tensor shapes, dtypes, devices, and statistics before the crash.
- Isolate a failing rank: Separate logs by process to identify the first failing rank in a distributed FlashInfer workload.
- Trace kernel memory faults: Combine API logs with compute-sanitizer, cuda-gdb, and kernel printf output to isolate illegal memory writes.

## Prompt Templates

### Enable basic crash logging

```
Show me how to enable FlashInfer API logging at level 3 for my_script.py and save output to crash_log.txt. Explain what each setting captures.
```

### Analyze an illegal memory access

```
My FlashInfer run reports an illegal memory access. Help me inspect the final logged API call for shape, dtype, device, stride, and contiguity problems.
```

### Debug a multi-GPU failure

```
My eight-rank job fails on one GPU. Design a logging plan using per-process destinations, then explain how to compare successful and failed ranks.
```

### Build a kernel-level investigation

```
Create a debugging sequence for a persistent CUDA memory fault. Combine FlashInfer level 3 logs, compute-sanitizer, cuda-gdb, and selective kernel printf checks.
```

## Limitations

- Only FlashInfer APIs decorated with @flashinfer\_api produce API logs.
- Requires access to a reproducible CUDA workload and the relevant NVIDIA debugging tools.
- Logging identifies suspicious inputs but does not prove the root cause or repair code automatically.
- Level 5 statistics are skipped during CUDA graph capture.

## Best Practices

- Start with level 3 logging to capture useful metadata without expensive tensor statistics.
- Write crash logs to a protected file so output survives process termination.
- Reproduce with the smallest failing workload before adding sanitizer or kernel-level instrumentation.

## Anti Patterns

- Do not leave detailed logging enabled in production workloads.
- Do not assume the last successful API call caused the failure; inspect the first call without output.
- Do not use kernel printf from every thread because output volume can hide the relevant signal.

## Security Audit

- Audited at: 2026-07-23T17:47:05.941\+00:00
- Summary: All 127 static findings are false positives caused by Markdown code formatting, example commands, and benign CUDA terminology. The skill is a documentation-only tutorial, and no prompt injection, automatic execution, reconnaissance, or malicious intent was found.

## Stats

- Views: 156
- Downloads: 5
- Favorites: 0
- Popularity score: 0
