← Back to Leaderboard

The AI CUDA Engineer 👷

39_L2Norm_39_l2norm_atomic_opt_base

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


def module_fn(x: torch.Tensor) -> torch.Tensor:
    """
    Applies L2 normalization to the input tensor.

    Args:
        x (torch.Tensor): Input tensor of shape (*, dim, *).

    Returns:
        torch.Tensor: Output tensor with L2 normalization applied, same shape as input.
    """
    return F.normalize(x, p=2, dim=1)


class Model(nn.Module):
    """
    Simple model that performs L2 normalization.
    """

    def __init__(self):
        """
        Initializes the L2Norm layer.
        """
        super(Model, self).__init__()

    def forward(self, x: torch.Tensor, fn=module_fn) -> torch.Tensor:
        """
        Applies L2 normalization to the input tensor.

        Args:
            x (torch.Tensor): Input tensor of shape (*, dim, *).

        Returns:
            torch.Tensor: Output tensor with L2 normalization applied, same shape as input.
        """
        return fn(x)


batch_size = 16
dim = 16384


def get_inputs():
    x = torch.randn(batch_size, dim)
    return [x]


def get_init_inputs():
    return []
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Simple model that performs L2 normalization.
    """
    def __init__(self):
        """
        Initializes the L2Norm layer.

        Args:
            dim (int): Dimension along which to normalize.
        """
        super(Model, self).__init__()

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        """
        Applies L2 normalization to the input tensor.

        Args:
            x (torch.Tensor): Input tensor of shape (*, dim, *).

        Returns:
            torch.Tensor: Output tensor with L2 normalization applied, same shape as input.
        """
        return x / torch.norm(x, p=2, dim=1, keepdim=True)

batch_size = 16
dim = 16384

def get_inputs():
    x = torch.randn(batch_size, dim)
    return [x]

def get_init_inputs():
    return []

Kernel Information

Related Kernels (Level 1, Task 39 • 39_L2Norm_)

Rank Kernel Name Runtime (ms) Speedup Native Speedup Compile
🥇 l2norm_strided_optimized_base_base 0.01 1.89 5.60
🥈 l2_norm_combined_base 0.01 1.55 4.58
🥉 l2_norm_unroll_optimized_base 0.01 1.42 4.20
🥉 39_l2norm_modular_edit_1 0.01 1.42 4.20
🥉 39_l2norm_blocksize_experiment_base 0.01 1.42 4.20
6 39_l2norm_atomic_opt_base 0.01 1.31 3.87
6 l2norm_block_tuned_base 0.01 1.31 3.87
6 l2_norm_block_size_tuning_base 0.01 1.31 3.87
6 l2_norm_atomic_minimized_base_base 0.01 1.31 3.87
6 l2norm_stride_optimized_base 0.01 1.31 3.87
6 39_l2norm_coalesced_base 0.01 1.31 3.87
6 39_l2norm_memory_coalescing_base 0.01 1.31 3.87
6 39_l2norm_modular_refactored_edit_1 0.01 1.31 3.87
6 39_l2norm_optimized_indexing_edit_1 0.01 1.31 3.87
6 39_l2norm_sync_optimized_edit_1 0.01 1.31 3.87
6 39_l2norm_blocksize_experiment_edit_1 0.01 1.31 3.87
6 39_l2norm_memory_coalescing_edit_1 0.01 1.31 3.87
6 39_l2norm_modular_refactored_base 0.01 1.31 3.87
6 l2norm_even_workload_base 0.01 1.31 3.87
6 39_l2norm_atomic_edit_1 0.01 1.31 3.87
#include <torch/extension.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cmath>

// Kernel 1: Compute partial sum of squares for each vector using multiple blocks per vector.
// Each block computes a partial sum over a segment of the vector and adds it atomically to a global sum array.

template <typename scalar_t>
__global__ void l2_norm_partial_kernel(
    const scalar_t* __restrict__ input,
    scalar_t* __restrict__ global_sum,
    const int C,
    const int total_vectors,
    const int stride_C,
    const int outer_stride,
    const int blocks_per_vector) {

    // Determine which vector and segment this block is responsible for
    int vector_idx = blockIdx.x / blocks_per_vector;
    int seg_idx = blockIdx.x % blocks_per_vector;
    if (vector_idx >= total_vectors) return;

    // Compute segment boundaries for the current vector
    int segment_length = (C + blocks_per_vector - 1) / blocks_per_vector;  // ceil division
    int start = seg_idx * segment_length;
    int end = start + segment_length;
    if (end > C) end = C;

    int base_offset = vector_idx * outer_stride;

    // Each thread computes a partial sum over its assigned indices in the segment
    scalar_t partial = 0;
    for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
        scalar_t val = input[base_offset + k * stride_C];
        partial += val * val;
    }

    // Reduce partial sums within the block using shared memory
    __shared__ scalar_t sdata[256];
    int tid = threadIdx.x;
    sdata[tid] = partial;
    __syncthreads();
    
    for (int s = blockDim.x / 2; s > 0; s >>= 1) {
        if (tid < s) {
            sdata[tid] += sdata[tid + s];
        }
        __syncthreads();
    }

    // The first thread in the block atomically adds the block's sum to the global sum
    if (tid == 0) {
        atomicAdd(&global_sum[vector_idx], sdata[0]);
    }
}

// Kernel 2: Normalize each vector using the computed L2 norm.
// The grid is organized similarly to kernel 1 to cover all elements of each vector.

template <typename scalar_t>
__global__ void l2_normalize_kernel_phase2(
    const scalar_t* __restrict__ input,
    scalar_t* __restrict__ output,
    const scalar_t* __restrict__ global_sum,
    const int C,
    const int total_vectors,
    const int stride_C,
    const int outer_stride,
    const int blocks_per_vector_norm) {

    int vector_idx = blockIdx.x / blocks_per_vector_norm;
    int seg_idx = blockIdx.x % blocks_per_vector_norm;
    if (vector_idx >= total_vectors) return;

    int segment_length = (C + blocks_per_vector_norm - 1) / blocks_per_vector_norm;
    int start = seg_idx * segment_length;
    int end = start + segment_length;
    if (end > C) end = C;

    int base_offset = vector_idx * outer_stride;

    // Each block computes the normalization factor (redundantly, but cheaply) from the global sum
    scalar_t norm = sqrt(global_sum[vector_idx]) + 1e-12;
    scalar_t inv_norm = (scalar_t)1.0 / norm;

    // Normalize the elements in the segment
    for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
        output[base_offset + k * stride_C] = input[base_offset + k * stride_C] * inv_norm;
    }
}


// The forward function orchestrates the two kernels to perform L2 normalization along dim=1.

torch::Tensor forward(torch::Tensor input) {
    TORCH_CHECK(input.is_cuda(), "Input must be a CUDA tensor");
    TORCH_CHECK(input.dim() >= 1, "Input must have at least 1 dimension");

    // Assume input shape is [N, C] or contiguous equivalent
    const int C = input.size(1);
    const int total_vectors = input.numel() / C;
    const int stride_C = input.stride(1);
    const int outer_stride = input.stride(0);

    auto output = torch::empty_like(input);
    auto global_sum = torch::zeros({total_vectors}, input.options());

    // Decide on the number of blocks per vector based on a segment size (e.g., 1024 elements per block)
    int seg_size = 1024;
    int blocks_per_vector = (C + seg_size - 1) / seg_size;
    if (blocks_per_vector < 1) blocks_per_vector = 1;
    int total_blocks = total_vectors * blocks_per_vector;

    const int threads = 256;

    AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "l2_norm_partial", ([&] {
        l2_norm_partial_kernel<scalar_t><<<total_blocks, threads>>>(
            input.data_ptr<scalar_t>(),
            global_sum.data_ptr<scalar_t>(),
            C,
            total_vectors,
            stride_C,
            outer_stride,
            blocks_per_vector
        );
    }));
    
    // Launch normalization kernel with the same grid configuration for simplicity
    int total_blocks_norm = total_vectors * blocks_per_vector;
    AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "l2_normalize_phase2", ([&] {
        l2_normalize_kernel_phase2<scalar_t><<<total_blocks_norm, threads>>>(
            input.data_ptr<scalar_t>(),
            output.data_ptr<scalar_t>(),
            global_sum.data_ptr<scalar_t>(),
            C,
            total_vectors,
            stride_C,
            outer_stride,
            blocks_per_vector
        );
    }));

    return output;
}

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
    m.def("forward", &forward, "L2 normalization along dim=1 with atomic operations only where necessary");
}
Performance Metrics
Metric Value Unit Variance Samples
Executed Ipc Active 0.394 inst/cycle 0.000 5
Executed Ipc Elapsed 0.216 inst/cycle 0.000 5
Issue Slots Busy 10.202 % 0.058 5
Issued Ipc Active 0.406 inst/cycle 0.000 5
SM Busy 10.202 % 0.058 5
Memory Throughput 196258496291.822 byte/second 5718532912446111744.000 5
Mem Busy 9.426 % 0.015 5
Max Bandwidth 8.696 % 0.013 5
L1/TEX Hit Rate 2.650 % 0.000 5
L2 Hit Rate 67.018 % 0.054 5
Mem Pipes Busy 3.300 % 0.002 5
Warp Cycles Per Issued Instruction 35.944 cycle 1.488 5
Warp Cycles Per Executed Instruction 37.474 cycle 1.624 5
Avg. Active Threads Per Warp 32.000 0.000 5
Avg. Not Predicated Off Threads Per Warp 29.020 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 10.000 block 0.000 5
Block Limit Shared Mem 32.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 22.416 % 0.019 5
Achieved Active Warps Per SM 14.346 warp 0.008 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 (22.4%) 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::empty_strided
CPU Time 468982.82 μs
Device Time 0.00 μs
Self CPU Time 228603.12 μ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::zeros
CPU Time 5247112.40 μs
Device Time 227780.45 μs
Self CPU Time 117898.57 μ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::zero_
CPU Time 5580446.35 μs
Device Time 7573921.73 μs
Self CPU Time 275670.40 μ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 5304780.98 μs
Device Time 7573921.73 μs
Self CPU Time 394538.11 μs
Self Device Time 7573921.73 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
cudaLaunchKernel
CPU Time 5553060.75 μs
Device Time 362810.03 μs
Self CPU Time 5553060.75 μs
Self Device Time 362810.03 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
void l2_norm_partial_kernel<float>(float const*, float*, int, int, int, int, int)
CPU Time 0.00 μs
Device Time 441121.42 μs
Self CPU Time 0.00 μs
Self Device Time 441121.42 μ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 7346456.83 μs
Self CPU Time 0.00 μs
Self Device Time 7346456.83 μs
CPU Memory Usage 0 B
Device Memory Usage 0 B
Self CPU Memory Usage 0 B
Self Device Memory Usage 0 B
Status: Completed
45296 warnings generated when compiling for host.
Suppressed 45321 warnings (45274 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.
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:13:5 bugprone-easily-swappable-parameters
13 | const int C,
| ^~~~~~~~~~~~
14 | const int total_vectors,
| ~~~~~~~~~~~~~~~~~~~~~~~~
15 | const int stride_C,
| ~~~~~~~~~~~~~~~~~~~
16 | const int outer_stride,
| ~~~~~~~~~~~~~~~~~~~~~~
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:13:15: note: the first parameter in the range is 'C'
13 | const int C,
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:16:15: note: the last parameter in the range is 'outer_stride'
16 | const int outer_stride,
| ^~~~~~~~~~~~
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:20:22: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
20 | int vector_idx = blockIdx.x / blocks_per_vector;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:21:19: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
21 | int seg_idx = blockIdx.x % blocks_per_vector;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:34:18: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
34 | for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:34:53: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
34 | for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:41:15: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
41 | int tid = threadIdx.x;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:45:18: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
45 | for (int s = blockDim.x / 2; s > 0; s >>= 1) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:66:5: warning: 4 adjacent parameters of 'l2_normalize_kernel_phase2' of similar type ('const int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
66 | const int C,
| ^~~~~~~~~~~~
67 | const int total_vectors,
| ~~~~~~~~~~~~~~~~~~~~~~~~
68 | const int stride_C,
| ~~~~~~~~~~~~~~~~~~~
69 | const int outer_stride,
| ~~~~~~~~~~~~~~~~~~~~~~
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:66:15: note: the first parameter in the range is 'C'
66 | const int C,
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:69:15: note: the last parameter in the range is 'outer_stride'
69 | const int outer_stride,
| ^~~~~~~~~~~~
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:72:22: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
72 | int vector_idx = blockIdx.x / blocks_per_vector_norm;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:73:19: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
73 | int seg_idx = blockIdx.x % blocks_per_vector_norm;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:88:18: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
88 | for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:88:53: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
88 | for (int k = start + threadIdx.x; k < end; k += blockDim.x) {
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:101:19: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
101 | const int C = input.size(1);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:102:31: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
102 | const int total_vectors = input.numel() / C;
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:103:26: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
103 | const int stride_C = input.stride(1);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:104:30: warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
104 | const int outer_stride = input.stride(0);
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:117: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]
117 | AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "l2_norm_partial", ([&] {
| ^
/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__, \
| ^
/home/robert_sakana_ai/llm_cuda/experiments/20250202_optimize_b10_s4_e0_sweep/level_1/task_39/b3_s1_39_l2norm_atomic_opt/base/base.cu:131: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]
131 | AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "l2_normalize_phase2", ([&] {
| ^
/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__, \
| ^