一键导入
croq-dsl-cuda
DSL-specific tuning contract for CUDA kernels. Loaded by croq-tune when dsl=cuda.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
DSL-specific tuning contract for CUDA kernels. Loaded by croq-tune when dsl=cuda.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
DSL-specific tuning contract for CuTe DSL (Python JIT) kernels. Loaded by croq-tune when dsl=cute-dsl.
DSL-specific tuning contract for CuTe/CUTLASS C++ template kernels. Loaded by croq-tune when dsl=cute-cpp.
Launch an infinite AI-driven kernel optimization loop for GPU kernels. Use when the user asks to "tune", "ai-tune", "optimize", "auto-tune", or "perf-tune" a kernel. Profiles with ncu, iterates optimizations indefinitely until interrupted.
Cursor-only kernel tuning entrypoint for GPU kernels. Use when the user asks to /croq-tune, continue tuning, resume tuning, ai-tune, auto-tune, optimize, or perf-tune a kernel in this repository. Profiles with ncu, iterates optimizations indefinitely until interrupted.
Reference collection of Choreo GPU kernel implementations. Use when studying kernel patterns, tiling strategies, warp specialization, TMA/DMA forms, or pipeline staging before editing .co files.
Launch an infinite AI-driven kernel optimization loop for GPU kernels. Use when the user asks to "tune", "ai-tune", "optimize", or "auto-tune" a kernel. Profiles with ncu, iterates optimizations indefinitely until interrupted.
| name | croq-dsl-cuda |
| description | DSL-specific tuning contract for CUDA kernels. Loaded by croq-tune when dsl=cuda. |
Source extension: .cu | Compiler: nvcc -> static binary | Group: compiled-binary
No additional checks beyond the standard ncu/nvcc/GPU validation.
build_iter<NNN>.sh:
#!/usr/bin/env bash
set -e
nvcc -O3 -arch=sm_90 -std=c++17 -I/usr/local/cuda/include \
-o tuning/<gpu>/cuda/bin/<shape_key>/<model>/iter<NNN>_<tag> \
tuning/<gpu>/cuda/srcs/<shape_key>/<model>/iter<NNN>_<tag>.cu \
2>&1 | tee tuning/<gpu>/cuda/perf/<shape_key>/<model>/build_iter<NNN>.txt
run_iter<NNN>.sh:
#!/usr/bin/env bash
tuning/<gpu>/cuda/bin/<shape_key>/<model>/iter<NNN>_<tag> \
2>&1 | tee tuning/<gpu>/cuda/perf/<shape_key>/<model>/timing_iter<NNN>.txt
Binary must print: TFLOPS: <value> time_ms: <value>
ncu --set full \
--export tuning/<gpu>/cuda/perf/<shape_key>/<model>/ncu_iter<NNN>.ncu-rep \
--force-overwrite \
tuning/<gpu>/cuda/bin/<shape_key>/<model>/iter<NNN>_<tag> [args]
ncu --import tuning/<gpu>/cuda/perf/<shape_key>/<model>/ncu_iter<NNN>.ncu-rep \
--csv --page raw \
> tuning/<gpu>/cuda/perf/<shape_key>/<model>/ncu_iter<NNN>.csv
Allowed: Raw CUDA kernels, CUDA intrinsics (__shfl_sync, __ldg, etc.),
PTX inline asm (asm volatile), cooperative groups, CuTe/CUTLASS atoms only
(copy atoms, MMA atoms, layout algebra).
Forbidden: cublasSgemm, cublasGemmEx, cutlass::gemm::device::Gemm,
cuSPARSELt, cuDNN compute calls, PyTorch/TensorFlow ops.
| Bottleneck | Ideas |
|---|---|
| Memory-bound (DRAM) | Increase BM/BN/BK tiles; vectorize loads (float4/uint4); cp.async; __ldg; TMA (Hopper) |
| Compute-bound | Reduce smem; decrease register count (--maxrregcount); increase threads; split accumulator |
| Latency-bound | Add cp.async pipeline stages; tma.load on Hopper; interleave independent mem + compute |
| L2 locality | Threadblock swizzle (tile-ID remapping); change CTA launch order |
| Bank conflicts | Pad smem arrays (+4/+8 elements/row); swizzled shared layout |
| Warp divergence | Eliminate conditional branches in hot paths; predicate with masks |
Key levers: BM/BN/BK (multiples of 16, typically 64-256), warp count (blockDim),
pipeline stages (1-5), smem padding, register pressure (#pragma unroll N, --maxrregcount),
vectorized loads, warp primitives, PTX inline (ldmatrix, mma.sync), TMA.
The binary must accept --verify (or run verify by default) and:
VERIFY: PASS or VERIFY: FAIL max_abs_err=<v>Verification Tolerance:
| Precision | base_tol | rel_tol | Notes |
|---|---|---|---|
| FP16 input, FP32 accum | 1.0 | 0.01 | Standard |
| FP16 input, FP16 accum | 16.0 | 0.05 | Higher error from FP16 accumulation |
| FP8 E4M3 input, FP16 accum | 0.5 | 0.01 | FP8 inputs are lower magnitude |
NEVER print "Test Passed" without actual numerical comparison. Keep reference tensors alive in host code. Timing via CUDA events (10 warmup + 50 timed).
cuBLAS harness (.cu) — calls cublasGemmEx. Library calls allowed only in iter000.