gpu-mode/popcorn-cli/load-inline-native-code
Claude Code and agent skill by gpu-mode/popcorn-cli
- community
Checking that the SKILL.md file is still in the repository.
Helps write CUDA and HIP kernels using torch.utils.cpp_extension.load_inline(). Use when users want to write native GPU code (CUDA/HIP) inside a Python submission file.
Install
npx vskill@latest install gpu-mode/popcorn-cli/load-inline-native-codeSKILL.md
Writing Native GPU Kernels with load_inline()
Use this skill when the user wants to write a custom CUDA or HIP kernel inside their Python submission file using torch.utils.cpp_extension.load_inline().
Overview
load_inline() compiles C++/CUDA/HIP source code at runtime and loads it as a Python module. This lets you write raw GPU kernels directly in your submission.py without a separate build system.
CUDA Template (NVIDIA GPUs)
HIP Template (AMD GPUs)
Key Points
- cpp_sources: C++ header declaring the functions you want to call from Python. These are the bindings.
- cuda_sources: The actual CUDA/HIP kernel code and the C++ wrapper that launches it.
- functions: List of function names to expose to Python. Must match the C++ function signatures exactly.
- verbose=True: Prints compilation output so you can debug build errors.
- extra_cuda_cflags: Pass extra compiler flags. Needed for AMD HIP (
--offload-arch=gfx942) or C++ standard selection.
Common Patterns
- Use
AT_DISPATCH_FLOATING_TYPES_AND_HALFto handle multiple dtypes in CUDA kernels. - For AMD/HIP, set
PYTORCH_ROCM_ARCHandCXXenv vars before importing torch. - Always check
cudaGetLastError()after kernel launches for NVIDIA targets. - The
load_inlinecall compiles on first run and caches the result. Subsequent runs reuse the cache unless the source changes. - Keep the module-level
load_inline()call outsidecustom_kernel()so compilation happens once at import time, not on every call.
Guardrails
- The
custom_kernelfunction signature must matchdef custom_kernel(data: input_t) -> output_t:. - The module is compiled at import time. Do not call
load_inline()insidecustom_kernel(). - For AMD GPUs, always set
PYTORCH_ROCM_ARCHbefore any torch import. - Use
torch::Tensorin C++ signatures for seamless Python-C++ tensor passing.
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 repositoryCheckingtemplates/setup/skills/load-inline-native-code/SKILL.md
Popularity
- Repository stars
- 110
- Repository forks
- 18
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
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/gpu-mode/popcorn-cli/load-inline-native-code)