Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

cuda-auto-tunecuda 自动调整

Agent Skill

cuda-auto-tune 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

559

周安装

24

GitHub Stars

17

下载量

196
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cuda-auto-tune(cuda 自动调整)
来源仓库:https://github.com/bruce-lee-ly/cuda_auto_tune
仓库路径:skills/cuda-auto-tune
安装命令:
npx skills add https://github.com/bruce-lee-ly/cuda_auto_tune --skill cuda-auto-tune
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bruce-lee-ly/cuda_auto_tune --skill cuda-auto-tune

简介

用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词快速定位候选结果时使用。

  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 强制执行严格的配置→分析→更改→验证循环的 CUDA 性能优化工具。
  • 每个内核类型都有专用剧本,通过 NCU 指标到操作的映射进行优化验证。

SKILL.md

NCU-driven iterative kernel optimization (CUDA / CUTLASS / Triton / CuTe DSL)

GATE CHECK (enforce before any optimization)

STOP — Do you have NCU profile data for this kernel?
  NO  → Go to Step 1. Do NOT touch any kernel code.
  YES → Go to Step 2.

Hard rules — violation of any rule invalidates the entire optimization:

  • NEVER change kernel code, launch config, or template parameters without NCU data.
  • ALL recommendations MUST cite specific NCU metric values as evidence.
  • Each iteration MUST cover at minimum: roofline, memory hierarchy, warp stalls, occupancy.
  • The optimization playbook MUST match the kernel implementation type.
  • After EVERY code change, re-profile and compare with --diff.
  • Stop iterating when improvements plateau or metrics approach hardware ceiling.

Mandatory optimization loop

┌─────────────────────────────────────────────────────────────────────┐
│  Step 1: Profile (NCU --set full)                                   │
│      ↓                                                              │
│  Step 2: Multi-dimensional analysis + identify kernel type          │
│      ↓                                                              │
│  Step 3: Apply type-specific playbook (one change per iteration)    │
│      ↓                                                              │
│  Step 4: Re-profile + diff → improved? → loop or stop               │
│      ↑                                           │                  │
│      └───────────────────────────────────────────┘                  │
└─────────────────────────────────────────────────────────────────────┘

Step 1: Profile with NCU (REQUIRED — no data = no optimization)

Option A: Profiling script (recommended)

# Native CUDA / CUTLASS binaries
bash cuda-auto-tune/scripts/ncu_profile.sh ./kernel report_v1

# Triton / Python
bash cuda-auto-tune/scripts/ncu_profile.sh "python your_kernel.py" report_v1

# CuTe DSL / Python
bash cuda-auto-tune/scripts/ncu_profile.sh "python your_cutedsl_kernel.py" report_v1

The script collects --set full → exports CSV → runs deep analysis → generates reports.

Option B: Manual profiling

ncu --set full -o report_v1 --target-processes all ./your_kernel
ncu --import report_v1.ncu-rep --page raw --csv > report_v1.csv
python3 cuda-auto-tune/scripts/ncu_analyse.py report_v1.csv

Kernel-name filters (reduce noise)

# CUTLASS only
ncu --set full -o report_v1 --target-processes all \
    --kernel-name "cutlass_\|sm90_\|ampere_" ./cutlass_program

# Triton only
ncu --set full -o report_v1 --target-processes all \
    --kernel-name "triton_" "python triton_kernel.py"

# CuTe DSL (kernel name often generic — use --type override in analysis)
python3 cuda-auto-tune/scripts/ncu_analyse.py report_v1.csv --type cutedsl

Expected outputs

ncu_reports/
├── report_v1.ncu-rep           # Full binary report
├── report_v1.csv               # Raw metrics CSV
├── report_v1_analysis.md       # Deep analysis report
└── report_v1_summary.txt       # Per-kernel summary

Step 2: Multi-dimensional analysis

2.1 Identify implementation type

Determine the kernel type from NCU "Function Name" and source context:

TypeDetection signals
Native CUDANo library prefix; hand-written __global__ functions
CUTLASScutlass_ prefix, smXX_xmma_, contains tensorop or cutlass
Tritontriton_ prefix, contains triton, encoded suffixes (e.g. _0d1d...e)
CuTe DSLGeneric names from @cute.kernel; confirm via source imports (cutlass.cute, cute.compile) or --type cutedsl
Librarycublas*, cudnn* — baseline/reference only, not optimizable

2.2 Common diagnostics (ALL kernel types — always run)

DimensionKey NCU metricsOutput
RooflineSM throughput, memory throughputcompute-bound / memory-bound / latency-bound / balanced
Memory hierarchyL1/L2 hit rate, coalescing ratio, DRAM throughputcache efficiency + bandwidth sub-bottleneck (DRAM/L2/L1)
Warp stallsPC sampling stall reasons (long_scoreboard, wait, barrier,...)top stall reasons with percentages
Instruction mixpipe FMA/ALU/LSU/Tensor utilizationpipeline imbalance, Tensor Core usage
Occupancyactive warps %, limiter breakdown (register/smem/warp/block)limiting factor + register count + smem size
Memory hazardsbank conflicts, register spills (local store sectors)severity and root cause
Divergenceavg threads executed vs avg threads active (true)divergence percentage

2.3 Type-specific focus

TypeKey focus areas
Native CUDAlaunch config (block size, grid), memory access patterns, async copy (cp.async/TMA), Tensor Core opportunity
CUTLASSThreadblockShape, WarpShape, stages, alignment, schedule policy, epilogue fusion, CTA swizzle
Tritonnum_warps, num_stages, BLOCK_* sizes, compiler hints (tl.multiple_of, tl.max_contiguous), tl.dot config
CuTe DSLthreads_per_cta, elems_per_thread, CopyAtom (num_bits_per_copy), tiled_copy layout, smem staging, cta_reduce pattern

2.4 Bottleneck classification decision tree

SM% > MEM% + 20  →  COMPUTE_BOUND
MEM% > SM% + 20  →  MEMORY_BOUND
  ├─ DRAM throughput > 70%        → DRAM-Bound (near HBM ceiling)
  ├─ L2 hit < 50%, DRAM > 40%    → DRAM-Bound (L2 miss driven)
  ├─ L1 hit < 20%, L2 hit >= 50% → L2-Bound
  └─ L1 hit < 20%                → L1-Bound
SM% < 40 AND MEM% < 40           →  LATENCY_BOUND
SM% > 60 AND MEM% > 60           →  BALANCED (near peak)

2.5 Conclusion template (REQUIRED after every analysis)

=== Conclusion ===
Kernel:    {kernel_name}
Type:      {Native CUDA | CUTLASS | Triton | CuTe DSL}
Arch:      SM_{arch}
Overall:   {COMPUTE_BOUND | MEMORY_BOUND | LATENCY_BOUND | BALANCED}
Duration:  {duration_us} us
Roofline:  SM {sm}%, MEM {mem}%, DRAM {dram}%
Occupancy: {occ}% (theoretical: {theo}%), limited by {limiter}
Regs/Thread: {regs}, Smem/Block: {smem} KB

Findings (sorted by severity):
  [CRITICAL] {finding}: {NCU evidence with numbers} -> {specific action}
  [WARNING]  {finding}: {NCU evidence with numbers} -> {specific action}
  [INFO]     {finding}: {NCU evidence with numbers}

Optimization priorities:
  1. {highest_priority} (expected gain: Nx, evidence: {metric}={value})
  2. {second_priority}  (expected gain: Nx, evidence: {metric}={value})
  3. {third_priority}   (expected gain: Nx, evidence: {metric}={value})

Step 3: Apply type-specific playbook

No intuition-only edits. Every change MUST directly address an NCU finding. Apply ONE change per iteration, then re-profile (Step 4).


3.1 Playbook: Native CUDA

3.1.1 Launch configuration

NCU findingActionCode pattern
Occupancy < 50%, block size < 128Increase block size to 128–256kernel<<<grid, 256>>>
Registers are occupancy limiterCap registers via __launch_bounds____global__ void __launch_bounds__(256, 2) kernel()
Grid too small (< SM count)Ensure enough blocks for full SM coveragegrid = (N + block - 1) / block with sufficient N
Occupancy low, blocks limiterReduce block size to fit more blocks per SMTry 128 instead of 256

3.1.2 Memory access optimization

NCU findingActionCode pattern
Load coalescing ratio > 8Ensure warp-contiguous addressing, AoS→SoAdata[threadIdx.x + blockIdx.x * blockDim.x]
Store coalescing ratio > 8Use shared memory staging for scatter writesWrite to smem first, then coalesced writeback
L1 hit rate < 20%Use __shared__ for frequently reused dataTile into shared memory with __syncthreads()
L2 hit rate < 50%Use L2 persistence hints (Ampere+)cudaAccessPolicyWindow for hot data ranges
DRAM throughput > 80%Reduce data movement: mixed precision, compressionhalf / __nv_bfloat16 for bandwidth-sensitive ops
Bank conflicts > 100KPad shared memory or swizzle layout__shared__ float smem[32][33]; (pad +1)
Register spills > 0Reduce per-thread state, use __launch_bounds__Simplify accumulators, split into sub-kernels

3.1.3 Latency hiding and pipelining

NCU findingActionCode pattern
stall_long_scoreboard > 30% (SM>=80)Use cp.async + double buffering__pipeline_memcpy_async(&smem, &gmem, size)
stall_long_scoreboard > 30% (SM>=90)Use TMA for bulk async transferscute::copy(tma_load,...) or CuTe TMA atoms
stall_barrier > 25%Reduce sync frequency, use warp primitives__shfl_sync(), cooperative_groups
stall_wait > 30%, long_scoreboard < 15%Pipeline over-buffered, reduce depthRemove one buffer stage
stall_math_pipe_throttle > 20%Compute saturated (positive signal)Consider Tensor Core or reduce FLOPs

3.1.4 Tensor Core utilization

NCU findingAction
pipe_tensor < 5%, FP16/BF16 workload with GEMM-like patternUse WMMA (wmma::mma_sync) or inline PTX (mma.sync)
pipe_tensor < 5%, but data is FP32Use TF32 path via wmma::mma_sync with nvcuda::wmma::precision::tf32
pipe_fma_fp16 > 10%, pipe_tensor < 5%Switch from scalar FP16 FMA to Tensor Core path

3.1.5 Vectorized memory access

// NCU evidence: coalescing ratio > 4 for 32-bit loads
// Before: scalar loads
float val = input[idx];

// After: vectorized 128-bit load (4x float)
float4 val = reinterpret_cast<const float4*>(input)[idx / 4];

3.2 Playbook: CUTLASS

3.2.1 Kernel config parsing

CUTLASS kernel names encode configuration. Extract:

  • Architecture: sm80_, sm90_, ampere_, hopper_
  • Compute type: tensorop vs simt
  • Tile shape: 128x128x32, 256x128x64
  • Pipeline stages: trailing x3, x5
  • Alignment: align8
  • Schedule (3.x): WarpSpecialized, WarpSpecializedCooperative, WarpSpecializedPingpong

3.2.2 Tile shape and occupancy

NCU findingAction
Occupancy < 40%, smem is limiterReduce ThreadblockShape (e.g., 256x128→128x128) or reduce stages
Occupancy < 40%, registers are limiterUse smaller WarpShape (e.g., 64x64→32x32) to reduce per-thread regs
SM throughput < 30%, grid is smallIncrease ThreadblockShape to process more elements per CTA
SM throughput > 80%, MEM < 40%Already compute-bound; increase pipeline stages for more overlap

3.2.3 Pipeline stages

NCU findingAction
stall_long_scoreboard > 30%Increase stages (Ampere: 3→5, Hopper: 2→3)
stall_wait > 30%, long_scoreboard < 15%Pipeline over-buffered; reduce stages to save smem
Smem limiter + stages > 3Reduce stages to free smem for higher occupancy

3.2.4 Alignment and vectorization

NCU findingAction
Load coalescing > 4, alignment < 8Increase CUTLASS alignment to 8 (128 bytes); pad matrix leading dims to multiples of alignment
SIMT path used but data supports TensorOpSwitch to tensorop CUTLASS configuration (2–8x speedup)
TensorOp configured but pipe_tensor < 5%Check alignment requirements — LD must be multiple of InstructionShape::kK

3.2.5 Schedule and architecture

NCU findingAction
CUTLASS 2.x on SM>=90Upgrade to CUTLASS 3.x with WarpSpecialized + TMA (1.2–1.5x gain)
L2 hit rate < 50% on large GEMMAdd ThreadblockSwizzle (2.x: GemmIdentityThreadblockSwizzle<N>, 3.x: StreamK or tile swizzle)
stall_long_scoreboard > 30% on HopperSwitch to WarpSpecializedCooperative schedule with TMA loads

3.2.6 Epilogue fusion

NCU findingAction
Multiple CUTLASS kernels back-to-back (e.g., GEMM + bias + activation)Fuse into single kernel via CUTLASS epilogue visitor tree
High DRAM traffic (read+write GB > expected)Move post-GEMM ops into epilogue to eliminate intermediate tensors

3.3 Playbook: Triton

3.3.1 Kernel classification

Triton kernel subtypes (from kernel name):

  • triton_poi_: Inductor pointwise (auto-generated)
  • triton_red_: Inductor reduction (auto-generated)
  • triton_per_: Inductor persistent reduction (auto-generated)
  • Custom @triton.jit: hand-written kernel (fully tunable)

Inductor-generated kernels: optimize at PyTorch level (torch._inductor.config), or rewrite as custom @triton.jit if this is a hot path.

3.3.2 num_warps tuning

NCU findingAction
Registers >= 128, num_warps >= 8CRITICAL: reduce num_warps (try 4 or 2)
Registers >= 64, num_warps >= 8Reduce num_warps to 4
Occupancy < 40%, register-limitedReduce num_warps AND/OR reduce BLOCK_* tile sizes
SM throughput < 30%, few warpsIncrease num_warps to improve latency hiding

3.3.3 num_stages tuning

NCU findingAction
stall_long_scoreboard > 30%Increase num_stages (2→3→4 on Ampere, 2→3 on Hopper)
stall_wait > 30%, long_scoreboard < 15%Decrease num_stages (over-buffered) or increase tile work
Smem is occupancy limiterDecrease num_stages (each stage doubles smem buffer)
On Hopper + long_scoreboard highAlso consider tl.make_block_ptr() for TMA-based loads

3.3.4 BLOCK_* tile size tuning

NCU findingAction
Register pressure highReduce BLOCK_M, BLOCK_N, or BLOCK_K
SM throughput low, compute-bound opportunityIncrease BLOCK_M/BLOCK_N for more compute per tile
DRAM bandwidth near ceilingIncrease BLOCK_K for more data reuse before writeback

3.3.5 Memory access optimization

NCU findingActionCode pattern
Load coalescing > 8Add stride hintstl.multiple_of(stride, 16) and tl.max_contiguous(offsets, BLOCK)
Uncoalesced on transposed inputUse structured pointerstl.make_block_ptr(base, shape, strides, offsets, block_shape, order)
L1 hit rate lowVerify access pattern continuityEnsure innermost dim stride == 1

3.3.6 Tensor Core utilization

NCU findingAction
pipe_tensor < 5%, kernel uses tl.dot1) allow_tf32=True for fp32; 2) BLOCK_K multiple of 16; 3) check dtypes are fp16/bf16/tf32/fp8
pipe_tensor < 5%, no tl.dot in codeGEMM-like pattern missing — restructure to use tl.dot

3.3.7 Triton autotune integration

@triton.autotune(
    configs=[
        triton.Config({'BLOCK_M': 128, 'BLOCK_N': 128, 'BLOCK_K': 32}, num_warps=4, num_stages=3),
        triton.Config({'BLOCK_M': 64,  'BLOCK_N': 64,  'BLOCK_K': 64}, num_warps=4, num_stages=4),
        triton.Config({'BLOCK_M': 128, 'BLOCK_N': 64,  'BLOCK_K': 32}, num_warps=8, num_stages=3),
    ],
    key=['M', 'N', 'K'],
)
@triton.jit
def kernel(...):
    ...

When NCU reveals the bottleneck, narrow autotune configs to the promising region instead of blind search.


3.4 Playbook: CuTe DSL

3.4.1 Key tuning parameters

ParameterEffectTypical range
threads_per_ctaWarps per CTA; affects occupancy, barrier cost, reduce cost128–512
elems_per_threadElements per thread; affects register pressure, data reuse4–32
num_bits_per_copyCopyAtom width; affects vectorized load/store bandwidth32, 64, 128
Smem staging bufferPipeline depth × tile size; affects smem footprintMinimize for occupancy

3.4.2 Occupancy optimization

NCU findingAction
Occupancy < 40%, registers are limiterReduce elems_per_thread or reduce threads_per_cta; add --maxrregcount=128 to cute.compile()
Occupancy < 40%, smem is limiterReduce threads_per_cta (fewer warps → smaller reduce buffer) or reduce staging buffer count
Registers >= 128, warps >= 8CRITICAL: reduce threads_per_cta to 128 or 256

3.4.3 Memory access (TiledCopy)

NCU findingAction
Load coalescing > 81) Increase num_bits_per_copy to 128; 2) verify t_layout distributes threads along contiguous addresses; 3) ensure from_dlpack() uses assumed_align=16
stall_long_scoreboard > 30%1) Increase num_bits_per_copy to 128; 2) increase elems_per_thread for more reuse; 3) on SM>=80 use CpAsyncOp copy atom; 4) add double-buffering
stall_wait > 30%, long_scoreboard < 15%Pipeline over-buffered; increase elems_per_thread for more compute per stage or reduce pipeline depth

3.4.4 Synchronization and reduction

NCU findingAction
stall_barrier > 25%1) Reduce threads_per_cta (fewer warps at barrier); 2) replace second sync_threads with shuffle broadcast (if warps <= 32); 3) merge multiple cta_reduce calls
High barrier + small reductionUse warp-only reduce without smem for small element counts
Multiple sync_threads per iterationMinimize sync points; use async pipeline commit/wait patterns

3.4.5 Thread divergence

NCU findingAction
Divergence > 20%Adjust threads_per_cta * elems_per_thread to closely match problem dimension N, reducing predicated-off threads
Predicated copies show high divergenceEnsure N is divisible by threads_per_cta * elems_per_thread or use tail-handling strategy

3.4.6 Compute optimization

NCU findingAction
pipe_tensor < 5%, FP16 GEMM-like opsUse cute.make_mma_atom() with MmaOp for Tensor Core path
pipe_fma high but pipe_tensor low (non-GEMM ops like RMSNorm/LayerNorm)Tensor Core not applicable for reductions — focus on memory and barrier optimization instead

3.4.7 Cache invalidation for re-profiling

CuTe DSL compiles Python to CUDA via JIT. After code changes:

# Clear compilation cache to ensure re-compilation
rm -rf __pycache__/ .cache/ /tmp/cutlass_cute_cache/
# Then re-profile
bash cuda-auto-tune/scripts/ncu_profile.sh "python your_cutedsl_kernel.py" report_v2

Step 4: Re-profile and verify (REQUIRED after every change)

4.1 Re-profile

# Clear JIT caches first
rm -rf ~/.triton/cache            # Triton
rm -rf __pycache__/ .cache/       # CuTe DSL

# Profile updated version
bash cuda-auto-tune/scripts/ncu_profile.sh ./kernel_v2 report_v2
# or
bash cuda-auto-tune/scripts/ncu_profile.sh "python kernel_v2.py" report_v2

4.2 Compare against baseline

python3 cuda-auto-tune/scripts/ncu_analyse.py ncu_reports/report_v2.csv --diff ncu_reports/report_v1.csv

4.3 Verification checklist

CheckCriteria
Duration improved?gpu__time_duration.sum decreased
Target bottleneck improved?The specific metric that triggered the change improved
No new bottlenecks?No new CRITICAL findings in the diff report
At hardware ceiling?SM throughput > 80% or DRAM throughput > 85% means near peak

4.4 Iteration log template

Track each iteration for accountability:

=== Iteration {N} ===
Change:  {what was changed and why}
NCU evidence: {metric}={before_value} -> {finding}
Report: report_v{N}.csv

Result:
  Duration: {before} us -> {after} us ({delta}%)
  Target metric: {metric}={before} -> {after}
  New findings: {any new issues introduced}

Decision: {CONTINUE to next bottleneck | STOP — at ceiling | ROLLBACK — regression}

Quick reference: high-signal NCU metrics

MetricNCU key
Durationgpu__time_duration.sum [us]
SM throughputsm__throughput.avg.pct_of_peak_sustained_elapsed [%]
Memory throughputgpu__compute_memory_throughput.avg.pct_of_peak_sustained_elapsed [%]
DRAM throughputgpu__dram_throughput.avg.pct_of_peak_sustained_elapsed [%]
L1 hit ratel1tex__t_sector_hit_rate.pct [%]
L2 hit ratelts__t_sector_hit_rate.pct [%]
Load coalescingl1tex__t_sectors_pipe_lsu_mem_global_op_ld.sum / l1tex__t_requests_pipe_lsu_mem_global_op_ld.sum
Bank conflictsl1tex__data_bank_conflicts_pipe_lsu_mem_shared.sum
Register spillsl1tex__t_sectors_pipe_lsu_mem_local_op_st.sum [sector]
Occupancysm__warps_active.avg.pct_of_peak_sustained_active [%]
Warp eligibilitysmsp__warps_eligible.avg.per_cycle_active [warp]
Registers/threadlaunch__registers_per_thread [register/thread]
Smem/blocklaunch__shared_mem_per_block [Kbyte/block]

Summary

This skill enforces a strict profile → analyze → change → verify loop. No NCU data = no optimization. No metric evidence = no code change. Each kernel type (Native CUDA / CUTLASS / Triton / CuTe DSL) has a dedicated playbook with NCU-metric-to-action mappings. Every change is tracked and verified by re-profiling.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

32.56%
按下载量换算64

Claude

30.15%
按下载量换算59

Cursor

18.03%
按下载量换算35

Gemini CLI

9.84%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills