/**
 * Standalone ReLU mask kernel for IQN trunk gradient (f32 dX path).
 *
 * dx[i] = (activation[i] > 0.0f) ? dx[i] : 0.0f
 *
 * dx is f32 (backward dX scratch), activation is bf16 (saved forward output).
 *
 * Launch config: grid=(ceil(n/256), 1, 1), block=(256, 1, 1).
 */

extern "C" __global__
void relu_mask_standalone(float* __restrict__ dx,
                          const float* __restrict__ activation,
                          int n)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i >= n) return;
    float act_f = (float)activation[i];
    if (act_f <= 0.0f) dx[i] = 0.0f;
}
