Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Expert integration with NVIDIA GPU-accelerated math libraries. Configure cuBLAS tensor core operations, generate cuBLAS GEMM calls, integrate cuDNN layers, handle algorithm selection, and support mixed-precision operations.
.claude/skills/a5c-ai-cublas-cudnn/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 377% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-23 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-03 | ✓→✗ | ▼ Worse | 122% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 80% | 0% |
You are cublas-cudnn - a specialized skill for NVIDIA GPU-accelerated math library integration. This skill provides expert capabilities for using cuBLAS, cuDNN, and related libraries.
This skill enables AI-powered GPU library operations including:
Matrix multiplication with cuBLAS:
c#include <cublas_v2.h> // Initialize cuBLAS cublasHandle_t handle; cublasCreate(&handle); // Standard SGEMM: C = alpha * A * B + beta * C float alpha = 1.0f, beta = 0.0f; cublasSgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, // No transpose M, N, K, // Dimensions &alpha, d_A, M, // A matrix and leading dimension d_B, K, // B matrix and leading dimension &beta, d_C, M); // C matrix and leading dimension // Batched GEMM for multiple matrices cublasSgemmBatched(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K, &alpha, d_Aarray, M, d_Barray, K, &beta, d_Carray, M, batchCount); // Strided batched GEMM (contiguous memory) cublasSgemmStridedBatched(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K, &alpha, d_A, M, strideA, d_B, K, strideB, &beta, d_C, M, strideC, batchCount);
Enable tensor cores for maximum performance:
c// Enable tensor cores (requires Volta+) cublasSetMathMode(handle, CUBLAS_TENSOR_OP_MATH); // For Ampere+, use TF32 cublasSetMathMode(handle, CUBLAS_TF32_TENSOR_OP_MATH); // Half precision GEMM with tensor cores cublasGemmEx(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K, &alpha, d_A, CUDA_R_16F, M, // FP16 input d_B, CUDA_R_16F, K, // FP16 input &beta, d_C, CUDA_R_16F, M, // FP16 output CUDA_R_16F, // Compute type CUBLAS_GEMM_DEFAULT_TENSOR_OP); // Mixed precision: FP16 inputs, FP32 accumulate cublasGemmEx(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K, &alpha, d_A, CUDA_R_16F, M, d_B, CUDA_R_16F, K, &beta, d_C, CUDA_R_32F, M, // FP32 output CUDA_R_32F, // FP32 compute CUBLAS_GEMM_DEFAULT_TENSOR_OP);
Deep learning convolutions:
c#include <cudnn.h> cudnnHandle_t cudnn; cudnnCreate(&cudnn); // Create tensor descriptors cudnnTensorDescriptor_t inputDesc, outputDesc; cudnnCreateTensorDescriptor(&inputDesc); cudnnCreateTensorDescriptor(&outputDesc); cudnnSetTensor4dDescriptor(inputDesc, CUDNN_TENSOR_NCHW, CUDNN_DATA_FLOAT, N, C, H, W); // Create filter descriptor cudnnFilterDescriptor_t filterDesc; cudnnCreateFilterDescriptor(&filterDesc); cudnnSetFilter4dDescriptor(filterDesc, CUDNN_DATA_FLOAT, CUDNN_TENSOR_NCHW, K, C, R, S); // Create convolution descriptor cudnnConvolutionDescriptor_t convDesc; cudnnCreateConvolutionDescriptor(&convDesc); cudnnSetConvolution2dDescriptor(convDesc, pad_h, pad_w, // Padding stride_h, stride_w, // Stride 1, 1, // Dilation CUDNN_CROSS_CORRELATION, CUDNN_DATA_FLOAT); // Enable tensor cores cudnnSetConvolutionMathType(convDesc, CUDNN_TENSOR_OP_MATH); // Find best algorithm cudnnConvolutionFwdAlgoPerf_t perfResults[8]; int returnedAlgoCount; cudnnFindConvolutionForwardAlgorithm(cudnn, inputDesc, filterDesc, convDesc, outputDesc, 8, &returnedAlgoCount, perfResults); cudnnConvolutionFwdAlgo_t algo = perfResults[0].algo; // Get workspace size size_t workspaceSize; cudnnGetConvolutionForwardWorkspaceSize(cudnn, inputDesc, filterDesc, convDesc, outputDesc, algo, &workspaceSize); void* workspace; cudaMalloc(&workspace, workspaceSize); // Execute convolution float alpha = 1.0f, beta = 0.0f; cudnnConvolutionForward(cudnn, &alpha, inputDesc, d_input, filterDesc, d_filter, convDesc, algo, workspace, workspaceSize, &beta, outputDesc, d_output);
ccudnnTensorDescriptor_t bnScaleBiasMeanVarDesc; cudnnCreateTensorDescriptor(&bnScaleBiasMeanVarDesc); cudnnDeriveBNTensorDescriptor(bnScaleBiasMeanVarDesc, inputDesc, CUDNN_BATCHNORM_SPATIAL); // Forward training cudnnBatchNormalizationForwardTraining(cudnn, CUDNN_BATCHNORM_SPATIAL, &alpha, &beta, inputDesc, d_input, outputDesc, d_output, bnScaleBiasMeanVarDesc, d_scale, d_bias, 0.1, // Exponential average factor d_runningMean, d_runningVariance, 1e-5, // Epsilon d_savedMean, d_savedInvVariance); // Forward inference cudnnBatchNormalizationForwardInference(cudnn, CUDNN_BATCHNORM_SPATIAL, &alpha, &beta, inputDesc, d_input, outputDesc, d_output, bnScaleBiasMeanVarDesc, d_scale, d_bias, d_runningMean, d_runningVariance, 1e-5);
c// Benchmark all algorithms cudnnConvolutionFwdAlgoPerf_t perfResults[CUDNN_CONVOLUTION_FWD_ALGO_COUNT]; int returnedCount; cudnnFindConvolutionForwardAlgorithmEx(cudnn, inputDesc, d_input, filterDesc, d_filter, convDesc, outputDesc, d_output, CUDNN_CONVOLUTION_FWD_ALGO_COUNT, &returnedCount, perfResults, workspace, workspaceSize); // Print benchmark results for (int i = 0; i < returnedCount; i++) { printf("Algorithm %d: %.3f ms, workspace: %zu bytes\n", perfResults[i].algo, perfResults[i].time, perfResults[i].memory); } // Select algorithm by heuristics cudnnConvolutionFwdAlgo_t algo; cudnnGetConvolutionForwardAlgorithm_v7(cudnn, inputDesc, filterDesc, convDesc, outputDesc, 8, &returnedCount, perfResults);
c// Query workspace for all operations size_t convWorkspace, bnWorkspace, poolWorkspace; cudnnGetConvolutionForwardWorkspaceSize(cudnn, ...); cudnnGetBatchNormalizationForwardTrainingExWorkspaceSize(cudnn, ...); // Allocate maximum needed size_t maxWorkspace = max(convWorkspace, max(bnWorkspace, poolWorkspace)); void* workspace; cudaMalloc(&workspace, maxWorkspace); // Reuse workspace across operations
c// FP16 convolution cudnnSetTensor4dDescriptor(inputDesc, CUDNN_TENSOR_NHWC, CUDNN_DATA_HALF, N, C, H, W); cudnnSetFilter4dDescriptor(filterDesc, CUDNN_DATA_HALF, CUDNN_TENSOR_NHWC, K, C, R, S); // INT8 convolution for inference cudnnSetTensor4dDescriptor(inputDesc, CUDNN_TENSOR_NHWC, CUDNN_DATA_INT8, N, C, H, W); cudnnSetConvolution2dDescriptor(convDesc, pad_h, pad_w, stride_h, stride_w, 1, 1, CUDNN_CROSS_CORRELATION, CUDNN_DATA_INT32); // INT32 accumulation
c#include <cusparse.h> cusparseHandle_t sparse; cusparseCreate(&sparse); // Create sparse matrix in CSR format cusparseSpMatDescr_t matA; cusparseCreateCsr(&matA, M, N, nnz, d_rowPtr, d_colIdx, d_values, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F); // Create dense vectors cusparseDnVecDescr_t vecX, vecY; cusparseCreateDnVec(&vecX, N, d_x, CUDA_R_32F); cusparseCreateDnVec(&vecY, M, d_y, CUDA_R_32F); // SpMV: y = alpha * A * x + beta * y size_t bufferSize; cusparseSpMV_bufferSize(sparse, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, matA, vecX, &beta, vecY, CUDA_R_32F, CUSPARSE_SPMV_ALG_DEFAULT, &bufferSize); void* buffer; cudaMalloc(&buffer, bufferSize); cusparseSpMV(sparse, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, matA, vecX, &beta, vecY, CUDA_R_32F, CUSPARSE_SPMV_ALG_DEFAULT, buffer);
This skill integrates with the following processes:
tensor-core-programming.js - Tensor core workflowsml-inference-optimization.js - ML inferencecustom-cuda-operator-development.js - Custom operatorsjson{ "operation": "gemm-benchmark", "library": "cuBLAS", "configuration": { "M": 4096, "N": 4096, "K": 4096, "datatype": "FP16", "math_mode": "TENSOR_OP_MATH" }, "performance": { "time_ms": 0.85, "tflops": 16.2, "efficiency_pct": 81.0 }, "recommendations": [ "Use CUBLAS_GEMM_DEFAULT_TENSOR_OP for tensor core path", "Ensure dimensions are multiples of 8 for optimal tensor core usage" ] }
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 21,711 | 23,617 | +9% | 1 | 1 | 0% | 4,427 | 6,705 | +51% | 0 | 0 | — |
case-02 | pass→pass | 20,815 | 15,005 | -28% | 1 | 1 | 0% | 3,399 | 6,127 | +80% | 0 | 0 | — |
case-03 | pass→fail | 14,733 | 14,207 | -4% | 1 | 1 | 0% | 2,539 | 5,640 | +122% | 0 | 0 | — |
case-04 | pass→pass | 11,086 | 10,530 | -5% | 1 | 1 | 0% | 1,724 | 4,670 | +171% | 0 | 0 | — |
case-05 | pass→pass | 24,403 | 24,584 | +1% | 1 | 1 | 0% | 3,596 | 6,821 | +90% | 0 | 0 | — |
case-06 | pass→pass | 10,704 | 7,331 | -32% | 1 | 1 | 0% | 1,812 | 4,412 | +143% | 0 | 0 | — |
case-07 | pass→pass | 9,919 | 18,454 | +86% | 1 | 1 | 0% | 1,548 | 4,293 | +177% | 0 | 0 | — |
case-08 | pass→pass | 9,390 | 7,117 | -24% | 1 | 1 | 0% | 1,375 | 4,511 | +228% | 0 | 0 | — |
case-09 | fail→pass | 4,662 | 5,570 | +19% | 1 | 1 | 0% | 853 | 4,065 | +377% | 0 | 0 | — |
case-10 | pass→pass | 22,460 | 20,210 | -10% | 1 | 1 | 0% | 3,237 | 6,041 | +87% | 0 | 0 | — |
case-11 | pass→pass | 11,198 | 15,267 | +36% | 1 | 1 | 0% | 1,842 | 5,383 | +192% | 0 | 0 | — |
case-12 | pass→pass | 16,746 | 17,212 | +3% | 1 | 1 | 0% | 2,757 | 5,958 | +116% | 0 | 0 | — |
case-13 | pass→pass | 7,009 | 5,994 | -14% | 1 | 1 | 0% | 1,237 | 3,945 | +219% | 0 | 0 | — |
case-14 | pass→pass | 23,731 | 14,283 | -40% | 1 | 1 | 0% | 2,629 | 5,827 | +122% | 0 | 0 | — |
case-15 | pass→pass | 10,019 | 8,765 | -13% | 1 | 1 | 0% | 2,071 | 4,806 | +132% | 0 | 0 | — |
case-16 | fail→pass | 17,187 | 8,281 | -52% | 1 | 1 | 0% | 3,537 | 4,726 | +34% | 0 | 0 | — |
case-17 | pass→pass | 12,130 | 12,196 | +1% | 1 | 1 | 0% | 2,183 | 5,215 | +139% | 0 | 0 | — |
case-18 | pass→pass | 7,904 | 14,982 | +90% | 1 | 1 | 0% | 1,401 | 5,378 | +284% | 0 | 0 | — |
case-19 | pass→pass | 6,889 | 8,131 | +18% | 1 | 1 | 0% | 1,183 | 4,231 | +258% | 0 | 0 | — |
case-20 | pass→pass | 8,059 | 10,954 | +36% | 1 | 1 | 0% | 1,226 | 4,563 | +272% | 0 | 0 | — |
case-21 | pass→pass | 3,552 | 5,730 | +61% | 1 | 1 | 0% | 602 | 3,825 | +535% | 0 | 0 | — |
case-22 | pass→pass | 5,906 | 5,334 | -10% | 1 | 1 | 0% | 713 | 3,629 | +409% | 0 | 0 | — |
case-23 | fail→pass | 12,179 | 2,236 | -82% | 1 | 1 | 0% | 2,012 | 3,283 | +63% | 0 | 0 | — |
case-24 | pass→pass | 9,350 | 8,093 | -13% | 1 | 1 | 0% | 2,007 | 4,655 | +132% | 0 | 0 | — |
case-25 | fail→fail | 17,294 | 13,827 | -20% | 1 | 1 | 0% | 3,561 | 5,656 | +59% | 0 | 0 | — |
case-26 | pass→pass | 16,386 | 10,173 | -38% | 1 | 1 | 0% | 2,521 | 5,040 | +100% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 26 cases were attempted. The headline lift of +8 percentage points is the difference between those two pass rates over the 26 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.