← Back to Leaderboard

The AI CUDA Engineer 👷

6_Matmul_with_large_K_dimension_6_matmul_stride_loops_base

Level 1 • Task 6
import torch
import torch.nn as nn
import torch.nn.functional as F


def module_fn(A, B):
    """
    Performs a single matrix multiplication (C = A * B) with a large K dimension.

    Args:
        A: Input tensor of shape (M, K)
        B: Input tensor of shape (K, N)

    Returns:
        Output tensor of shape (M, N)
    """
    return torch.matmul(A, B)


class Model(nn.Module):
    """
    Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension
    """

    def __init__(self):
        super(Model, self).__init__()

    def forward(self, A: torch.Tensor, B: torch.Tensor, fn=module_fn) -> torch.Tensor:
        return fn(A, B)


M = 256
N = 256
K = 131072


def get_inputs():
    A = torch.randn(M, K)
    B = torch.randn(K, N)
    return [A, B]


def get_init_inputs():
    return []  # No special initialization inputs needed
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension
    """
    def __init__(self):
        super(Model, self).__init__()
    
    def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:
        """
        Performs matrix multiplication of A and B.

        Args:
            A: Input tensor of shape (M, K)
            B: Input tensor of shape (K, N)

        Returns:
            Output tensor of shape (M, N)
        """
        return torch.matmul(A, B)

M = 256
N = 256
K = 131072

def get_inputs():
    A = torch.randn(M, K)
    B = torch.randn(K, N)
    return [A, B]

def get_init_inputs():
    return []  # No special initialization inputs needed

Kernel Information

Related Kernels (Level 1, Task 6 • 6_Matmul_with_large_K_dimension_)

Rank Kernel Name Runtime (ms) Speedup Native Speedup Compile
🥇 double_buffered_matmul_base 5.11 0.07 0.11
🥈 6_matmul_multi_stream_base 5.26 0.07 0.11
🥉 fewer_sync_matmul_edit_1_base 5.27 0.07 0.11
4 atomic_operations_matmul_edit_1 5.27 0.07 0.11
5 6_matmul_modular_refactored_base 5.30 0.06 0.11
6 modular_matmul_device_fn_edit_1 5.30 0.06 0.11
7 matmul_stream_ldg_base 5.31 0.06 0.11
8 6_matmul_modular_device_func_base 5.31 0.06 0.11
9 6_matmul_modular_device_base 5.32 0.06 0.11
10 6_matmul_no_divergence_base 5.32 0.06 0.11
11 6_matmul_ldg_base 5.33 0.06 0.11
12 optimized_streamed_tiled_matmul_base 5.33 0.06 0.11
12 6_matmul_even_workload_distribution_base 5.33 0.06 0.11
14 optimized_matmul_kernel_base 5.34 0.06 0.11
15 grid_stride_matmul_edit_1 5.34 0.06 0.11
16 6_matmul_stride_loops_base 5.34 0.06 0.11
17 6_matmul_ldg_128bit_aligned_base 5.35 0.06 0.11
18 optimized_matmul_kernel_base 5.35 0.06 0.11
19 unroll_loop_matmul_base 5.36 0.06 0.11
20 warp_divergence_optimized_matmul_base 5.37 0.06 0.11
#include <torch/extension.h>
#include <cuda.h>
#include <cuda_runtime.h>

#define TILE_WIDTH 16

// This kernel uses grid-stride loops to allow each block to compute multiple output tiles.
// Each block loads sub-tiles from matrix A and B into shared memory and iterates over the K dimension in tiles.
// The outer loops (over row_tile and col_tile) use stride loops to cover the entire matrix dimensions, ensuring proper boundary handling.

template <typename scalar_t>
__global__ void matmul_stride_kernel(const scalar_t* __restrict__ A, 
                                       const scalar_t* __restrict__ B, 
                                       scalar_t* __restrict__ C,
                                       int M, int K, int N) {
    // Thread indices
    int tx = threadIdx.x;
    int ty = threadIdx.y;

    // Loop over the output tiles using grid-stride loops in both row and column dimensions
    for (int row_tile = blockIdx.y * TILE_WIDTH; row_tile < M; row_tile += gridDim.y * TILE_WIDTH) {
        for (int col_tile = blockIdx.x * TILE_WIDTH; col_tile < N; col_tile += gridDim.x * TILE_WIDTH) {
            scalar_t value = 0;
            // Compute the global row and col for the current element computed by this thread
            int row = row_tile + ty;
            int col = col_tile + tx;

            // Number of tiles along the K dimension
            int numTiles = (K + TILE_WIDTH - 1) / TILE_WIDTH;
            
            for (int t = 0; t < numTiles; ++t) {
                // Allocate shared memory for tiles of A and B
                __shared__ scalar_t sA[TILE_WIDTH][TILE_WIDTH];
                __shared__ scalar_t sB[TILE_WIDTH][TILE_WIDTH];
                
                // Compute indices for the elements to load
                int A_row = row;
                int A_col = t * TILE_WIDTH + tx;
                int B_row = t * TILE_WIDTH + ty;
                int B_col = col;
                
                // Load tile from A into shared memory, with boundary check
                if (A_row < M && A_col < K)
                    sA[ty][tx] = A[A_row * K + A_col];
                else
                    sA[ty][tx] = static_cast<scalar_t>(0);
                
                // Load tile from B into shared memory, with boundary check
                if (B_row < K && B_col < N)
                    sB[ty][tx] = B[B_row * N + B_col];
                else
                    sB[ty][tx] = static_cast<scalar_t>(0);
                
                __syncthreads();
                
                // Compute partial product for this tile
                #pragma unroll
                for (int i = 0; i < TILE_WIDTH; ++i) {
                    value += sA[ty][i] * sB[i][tx];
                }
                
                __syncthreads();
            }
            
            // Write the result to C if within bounds
            if (row < M && col < N) {
                C[row * N + col] = value;
            }
        }
    }
}

// Host function exposed to Python via Pybind11

torch::Tensor module_fn(torch::Tensor A, torch::Tensor B) {
    TORCH_CHECK(A.is_cuda(), "Tensor A must be a CUDA tensor");
    TORCH_CHECK(B.is_cuda(), "Tensor B must be a CUDA tensor");

    int M = A.size(0);
    int K = A.size(1);
    int N = B.size(1);
    TORCH_CHECK(K == B.size(0), "Inner dimensions of A and B must match");
    
    auto C = torch::empty({M, N}, A.options());
    
    // Launch a modest grid size; the kernel uses stride loops to cover the entire output matrix
    dim3 threads(TILE_WIDTH, TILE_WIDTH);
    dim3 blocks( min((N + TILE_WIDTH - 1) / TILE_WIDTH, 32), 
                 min((M + TILE_WIDTH - 1) / TILE_WIDTH, 32) );
    
    AT_DISPATCH_FLOATING_TYPES(A.scalar_type(), "matmul_stride_kernel", ([&] {
        matmul_stride_kernel<scalar_t><<<blocks, threads>>>(
            A.data_ptr<scalar_t>(),
            B.data_ptr<scalar_t>(),
            C.data_ptr<scalar_t>(),
            M, K, N
        );
    }));
    
    cudaDeviceSynchronize();
    return C;
}

// Pybind11 binding
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
    m.def("forward", &module_fn, "Stride loop tiled matrix multiplication");
}
Performance Metrics
Metric Value Unit Variance Samples
Executed Ipc Active 0.820 inst/cycle 0.000 5
Executed Ipc Elapsed 0.810 inst/cycle 0.000 5
Issue Slots Busy 20.444 % 0.000 5
Issued Ipc Active 0.820 inst/cycle 0.000 5
SM Busy 20.444 % 0.000 5
Memory Throughput 46508969550.034 byte/second 3221855654662817.000 5
Mem Busy 41.896 % 0.001 5
Max Bandwidth 35.640 % 0.001 5
L1/TEX Hit Rate 0.422 % 0.005 5
L2 Hit Rate 83.316 % 0.021 5
Mem Pipes Busy 32.890 % 0.001 5
Warp Cycles Per Issued Instruction 18.910 cycle 0.000 5
Warp Cycles Per Executed Instruction 18.910 cycle 0.000 5
Avg. Active Threads Per Warp 32.000 0.000 5
Avg. Not Predicated Off Threads Per Warp 32.000 0.000 5
Max Active Clusters 0.000 cluster 0.000 5
Max Cluster Size 8.000 block 0.000 5
Overall GPU Occupancy 0.000 % 0.000 5
Cluster Occupancy 0.000 % 0.000 5
Block Limit SM 32.000 block 0.000 5
Block Limit Registers 8.000 block 0.000 5
Block Limit Shared Mem 21.000 block 0.000 5
Block Limit Warps 8.000 block 0.000 5
Theoretical Active Warps per SM 64.000 warp 0.000 5
Theoretical Occupancy 100.000 % 0.000 5
Achieved Occupancy 24.170 % 0.000 5
Achieved Active Warps Per SM 15.470 warp 0.000 5
Analysis Rules
Rule Description
WRN HighPipeUtilization All compute pipelines are under-utilized. Either this kernel is very small or it doesn't issue enough warps per scheduler. Check the Launch Statistics and Scheduler Statistics sections for further details.
INF CPIStall Check the Warp Stall Sampling (All Cycles) table for the top stall locations in your source based on sampling data. The Kernel Profiling Guide (https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html#metrics-reference) provides more details on each stall reason.
WRN Occupancy This kernel's theoretical occupancy is not impacted by any block limit. The difference between calculated theoretical (100.0%) and measured achieved occupancy (24.2%) can be the result of warp scheduling overheads or workload imbalances during the kernel execution. Load imbalances can occur between warps within a block as well as across blocks of the same kernel. See the CUDA Best Practices Guide (https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#occupancy) for more details on optimizing occupancy.
Operation / Metric Value Unit
aten::randn
CPU Time 295828.12 μs
Device Time 0.00 μs
Self CPU Time 101.35 μs
Self Device Time 0.00 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
aten::normal_
CPU Time 295670.06 μs
Device Time 0.00 μs
Self CPU Time 295670.06 μs
Self Device Time 0.00 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
aten::to
CPU Time 246668.92 μs
Device Time 27565.62 μs
Self CPU Time 45.67 μs
Self Device Time 0.00 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
aten::_to_copy
CPU Time 246623.25 μs
Device Time 27565.62 μs
Self CPU Time 132.74 μs
Self Device Time 0.00 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
void matmul_stride_kernel<float>(float const*, float const*, float*, int, int, int)
CPU Time 0.00 μs
Device Time 8099832.23 μs
Self CPU Time 0.00 μs
Self Device Time 8099832.23 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
cudaDeviceSynchronize
CPU Time 8199296.50 μs
Device Time 10245.36 μs
Self CPU Time 8199296.50 μs
Self Device Time 10245.36 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
aten::zero_
CPU Time 22290.67 μs
Device Time 117676.09 μs
Self CPU Time 3578.20 μs
Self Device Time 0.00 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
aten::fill_
CPU Time 18714.17 μs
Device Time 117676.09 μs
Self CPU Time 4996.31 μs
Self Device Time 117676.09 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
void at::native::vectorized_elementwise_kernel<4, at::native::FillFunctor<int>, at::detail::Array<char*, 1> >(int, at::native::FillFunctor<int>, at::detail::Array<char*, 1>)
CPU Time 0.00 μs
Device Time 117676.09 μs
Self CPU Time 0.00 μs
Self Device Time 117676.09 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
Status: Failed
45253 warnings and 2 errors generated when compiling for host.
Error while processing /home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu.
Suppressed 45287 warnings (45240 in non-user code, 47 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:12:38 bugprone-easily-swappable-parameters
12 | __global__ void matmul_stride_kernel(const scalar_t* __restrict__ A,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 | const scalar_t* __restrict__ B,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:12:67: note: the first parameter in the range is 'A'
12 | __global__ void matmul_stride_kernel(const scalar_t* __restrict__ A,
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:13:69: note: the last parameter in the range is 'B'
13 | const scalar_t* __restrict__ B,
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:17:14: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
17 | int tx = threadIdx.x;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:18:14: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
18 | int ty = threadIdx.y;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:21:25: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
21 | for (int row_tile = blockIdx.y * TILE_WIDTH; row_tile < M; row_tile += gridDim.y * TILE_WIDTH) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:21:76: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
21 | for (int row_tile = blockIdx.y * TILE_WIDTH; row_tile < M; row_tile += gridDim.y * TILE_WIDTH) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:22:29: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
22 | for (int col_tile = blockIdx.x * TILE_WIDTH; col_tile < N; col_tile += gridDim.x * TILE_WIDTH) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:22:80: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
22 | for (int col_tile = blockIdx.x * TILE_WIDTH; col_tile < N; col_tile += gridDim.x * TILE_WIDTH) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:79:13: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
79 | int M = A.size(0);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:80:13: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
80 | int K = A.size(1);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:81:13: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
81 | int N = B.size(1);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:88:18: error: no matching function for call to 'min' [clang-diagnostic-error]
88 | dim3 blocks( min((N + TILE_WIDTH - 1) / TILE_WIDTH, 32),
| ^~~
/home/common_modules/clang-tidy/20.0.0git/lib/clang/20/include/__clang_cuda_math.h:201:16: note: candidate function not viable: call to __device__ function from __host__ function
201 | __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
| ^
/usr/local/cuda/include/crt/math_functions.hpp:868:38: note: candidate function not viable: call to __device__ function from __host__ function
868 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const unsigned int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:873:38: note: candidate function not viable: call to __device__ function from __host__ function
873 | __MATH_FUNCTIONS_DECL__ unsigned int min(const int a, const unsigned int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:878:38: note: candidate function not viable: call to __device__ function from __host__ function
878 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:883:34: note: candidate function not viable: call to __device__ function from __host__ function
883 | __MATH_FUNCTIONS_DECL__ long int min(const long int a, const long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:902:43: note: candidate function not viable: call to __device__ function from __host__ function
902 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const unsigned long int a, const unsigned long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:919:43: note: candidate function not viable: call to __device__ function from __host__ function
919 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const long int a, const unsigned long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:936:43: note: candidate function not viable: call to __device__ function from __host__ function
936 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const unsigned long int a, const long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:953:39: note: candidate function not viable: call to __device__ function from __host__ function
953 | __MATH_FUNCTIONS_DECL__ long long int min(const long long int a, const long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:958:48: note: candidate function not viable: call to __device__ function from __host__ function
958 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const unsigned long long int a, const unsigned long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:963:48: note: candidate function not viable: call to __device__ function from __host__ function
963 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const long long int a, const unsigned long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:968:48: note: candidate function not viable: call to __device__ function from __host__ function
968 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const unsigned long long int a, const long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:973:31: note: candidate function not viable: call to __device__ function from __host__ function
973 | __MATH_FUNCTIONS_DECL__ float min(const float a, const float b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:978:32: note: candidate function not viable: call to __device__ function from __host__ function
978 | __MATH_FUNCTIONS_DECL__ double min(const double a, const double b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:983:32: note: candidate function not viable: call to __device__ function from __host__ function
983 | __MATH_FUNCTIONS_DECL__ double min(const float a, const double b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:988:32: note: candidate function not viable: call to __device__ function from __host__ function
988 | __MATH_FUNCTIONS_DECL__ double min(const double a, const float b)
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:89:18: error: no matching function for call to 'min' [clang-diagnostic-error]
89 | min((M + TILE_WIDTH - 1) / TILE_WIDTH, 32) );
| ^~~
/home/common_modules/clang-tidy/20.0.0git/lib/clang/20/include/__clang_cuda_math.h:201:16: note: candidate function not viable: call to __device__ function from __host__ function
201 | __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
| ^
/usr/local/cuda/include/crt/math_functions.hpp:868:38: note: candidate function not viable: call to __device__ function from __host__ function
868 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const unsigned int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:873:38: note: candidate function not viable: call to __device__ function from __host__ function
873 | __MATH_FUNCTIONS_DECL__ unsigned int min(const int a, const unsigned int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:878:38: note: candidate function not viable: call to __device__ function from __host__ function
878 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:883:34: note: candidate function not viable: call to __device__ function from __host__ function
883 | __MATH_FUNCTIONS_DECL__ long int min(const long int a, const long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:902:43: note: candidate function not viable: call to __device__ function from __host__ function
902 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const unsigned long int a, const unsigned long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:919:43: note: candidate function not viable: call to __device__ function from __host__ function
919 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const long int a, const unsigned long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:936:43: note: candidate function not viable: call to __device__ function from __host__ function
936 | __MATH_FUNCTIONS_DECL__ unsigned long int min(const unsigned long int a, const long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:953:39: note: candidate function not viable: call to __device__ function from __host__ function
953 | __MATH_FUNCTIONS_DECL__ long long int min(const long long int a, const long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:958:48: note: candidate function not viable: call to __device__ function from __host__ function
958 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const unsigned long long int a, const unsigned long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:963:48: note: candidate function not viable: call to __device__ function from __host__ function
963 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const long long int a, const unsigned long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:968:48: note: candidate function not viable: call to __device__ function from __host__ function
968 | __MATH_FUNCTIONS_DECL__ unsigned long long int min(const unsigned long long int a, const long long int b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:973:31: note: candidate function not viable: call to __device__ function from __host__ function
973 | __MATH_FUNCTIONS_DECL__ float min(const float a, const float b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:978:32: note: candidate function not viable: call to __device__ function from __host__ function
978 | __MATH_FUNCTIONS_DECL__ double min(const double a, const double b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:983:32: note: candidate function not viable: call to __device__ function from __host__ function
983 | __MATH_FUNCTIONS_DECL__ double min(const float a, const double b)
| ^
/usr/local/cuda/include/crt/math_functions.hpp:988:32: note: candidate function not viable: call to __device__ function from __host__ function
988 | __MATH_FUNCTIONS_DECL__ double min(const double a, const float b)
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_6/b7_s2_6_matmul_stride_loops/base/base.cu:91:5: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
91 | AT_DISPATCH_FLOATING_TYPES(A.scalar_type(), "matmul_stride_kernel", ([&] {
| ^
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/ATen/Dispatch.h:237:34: note: expanded from macro 'AT_DISPATCH_FLOATING_TYPES'
237 | AT_DISPATCH_SWITCH(TYPE, NAME, AT_DISPATCH_CASE_FLOATING_TYPES(__VA_ARGS__))
| ^
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/ATen/Dispatch.h:233:3: note: expanded from macro 'AT_DISPATCH_CASE_FLOATING_TYPES'
233 | AT_DISPATCH_CASE(at::ScalarType::Double, __VA_ARGS__) \
| ^
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/ATen/Dispatch.h:74:3: note: expanded from macro 'AT_DISPATCH_CASE'
74 | AT_PRIVATE_CASE_TYPE_USING_HINT(enum_type, scalar_t, __VA_ARGS__)
| ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/ATen/Dispatch.h:58:7: note: expanded from macro 'AT_PRIVATE_CHECK_SELECTIVE_BUILD'
58 | AT_ERROR( \
| ^
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/c10/util/Exception.h:711:32: note: expanded from macro 'AT_ERROR'
711 | C10_EXPAND_MSVC_WORKAROUND(TORCH_CHECK(false, ::c10::str(__VA_ARGS__))); \
| ^
/home/robert_sakana_ai/miniconda3/envs/llm2cuda/lib/python3.11/site-packages/torch/include/c10/util/Exception.h:536:9: note: expanded from macro 'TORCH_CHECK'
536 | __func__, \
| ^