avoid-warp-divergence

avoid-warp-divergence is a skill for Claude Code, Codex from tensormux/kernel-skills. It costs 0 tokens per session (3,187 once invoked), scanned A, original, MIT.

A guide to handling warp divergence in CUDA kernels. CUDA kernels are programs that run many GPU threads at once, while a warp is a group of those threads executing together.

In plain words
What is it for?
Investigating data-dependent branches, irregular loops, early exits, and masked or sparse GPU computations, then deciding whether restructuring is worthwhile.
Why use it?
It helps identify when threads take different code paths, which can make some threads wait and reduce GPU efficiency.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Investigating data-dependent branches, irregular loops, early exits, and masked or sparse GPU computations, then deciding whether restructuring is worthwhile.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tensormux/kernel-skills/avoid-warp-divergence
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.

Any agent
npx skills add tensormux/kernel-skills --skill avoid-warp-divergence
Clone the repo
git clone --depth 1 https://github.com/tensormux/kernel-skills

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 avoid-warp-divergence

README.md
[![agentmods](https://agentmods.dev/badge/skills/tensormux/kernel-skills/avoid-warp-divergence.svg)](https://agentmods.dev/skills/tensormux/kernel-skills/avoid-warp-divergence)
Your own site
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/avoid-warp-divergence"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/avoid-warp-divergence.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,187 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00000 $0.03187
Opus 5 $0.00000 $0.01594
Sonnet 5 $0.00000 $0.00637
Haiku 4.5 $0.00000 $0.00319

Measured 8d ago against content hash 84404333e5c6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

avoid-warp-divergence 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 8d 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.

skills/cuda/avoid-warp-divergence/SKILL.md · 99 lines

How it starts

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

Skill: Avoid Warp Divergence

Purpose

Guide the agent through identifying, classifying, and restructuring warp divergence in CUDA kernels — distinguishing avoidable from unavoidable divergence, applying correct restructuring strategies, and assessing the real performance impact before spending engineering effort.

Use this when

  • Profiling shows a high sm__thread_inst_executed_pipe_alu_pred_on_pct / sm__inst_executed ratio indicating significant predicated-off execution, or Nsight Compute's branch_efficiency is notably below 100%
  • The kernel contains data-dependent branches where different threads in a warp take different paths based on their input data
  • The kernel has irregular loop bounds or early-exit conditions that vary per thread
  • Sparse or masked computation (e.g., attention masks, pruning masks) introduces branches that not all threads in a warp satisfy

Do not use this when

  • The branches are on values that are uniform across the entire warp (e.g., checking a kernel argument or a loop bound that all threads compute identically): these do not cause divergence
  • The divergent code is only at the boundary of the input (e.g., the last partial tile): this is unavoidable boundary divergence, and the performance impact is typically negligible for large inputs
  • The kernel is memory-bandwidth-bound: eliminating divergence in a memory-bound kernel may not improve throughput because the bottleneck is not instruction throughput
  • The divergence restructuring would require significant data reorganization that introduces worse memory access patterns: weigh the tradeoff explicitly

Inputs the agent should gather first

  • The divergent code region: what is the branch condition? Is it a simple if/else, a loop with data-dependent bounds, or an early exit?
  • What determines the branch: is it a function of thread index only (geometry-based), a function of input data values (data-dependent), or a function of a uniform warp-level value?
  • Warp occupancy of each branch path: roughly what fraction of threads in a warp are expected to take each path? If 31 out of 32 threads take the same path and 1 takes the other, the impact is low. If 16 take each path, the serialization cost is highest.
  • Branch body complexity: how many instructions are in the divergent region? A 2-instruction divergent branch has negligible cost even with full serialization. A 100-instruction divergent loop body is expensive.
  • Hardware target: SM architecture. All current NVIDIA GPUs use the same 32-thread warp SIMT model.
  • Whether the divergence is data-dependent or geometry-based: this determines which restructuring strategies apply.

Read the full file on GitHub · 99 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 99 lines · 0 tokens per session scan A 84404333e5c6

Subscribe to this mod's changes

avoid-warp-divergence is a skill published in the GitHub repository tensormux/kernel-skills (73 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,187 tokens. 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

diagnose

Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.

MagicKidd/Rokid-agentic-workflow · 66 tokens

agenttrace-session-audit

Audit local AI coding-agent sessions with agenttrace for cost, tool failures, latency, anomalies, health, diffs, and CI gates.

sickn33/agentic-awesome-skills · 34 tokens

sglang-diffusion-benchmark-profile

Use when benchmarking denoise latency or profiling a diffusion bottleneck in SGLang.

sgl-project/sglang · 26 tokens

systematic-debugging

A step-by-step method for finding the underlying cause of technical problems before changing code. It covers reading errors, reproducing failures, checking recent changes, and tracing data across system components.

jnMetaCode/superpowers-zh · 24 tokens

investigate

Systematic debugging with root cause investigation. Four phases: investigate, analyze, hypothesize, implement. Iron Law: no fixes without root cause. Use when asked to "debug this", "fix this bug", "why is this broken", "investigate this error", or "root cause analysis". Proactively invoke this skill (do NOT debug…

GCWing/BitFun · 112 tokens

anti-entropy-governance

Use when touching retiring old logic, collapsing duplicate owners, removing fallbacks, or schema/persistence/source-of-truth boundaries; identify opportunities automatically; destructive execution requires explicit confirmation.

GanyuanRan/Aegis · 42 tokens