```python
import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline

_cpp_source = r"""
#include <torch/extension.h>

torch::Tensor split_gemv_cuda(torch::Tensor A, torch::Tensor B);
"""

_cuda_source = r"""
#include <torch/extension.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <c10/cuda/CUDAException.h>
#include <cuda_runtime.h>
#include <cstdint>

constexpr int THREADS = 256;
constexpr int CHUNK = 16384;

__device__ __forceinline__ float warp_sum(float value) {
    #pragma unroll
    for (int offset = 16; offset > 0; offset >>= 1)
        value += __shfl_down_sync(0xffffffff, value, offset);
    return value;
}

template<bool VECTORIZED>
__global__ void partial_gemv(
    const float* __restrict__ A,
    const float* __restrict__ B,
    float* __restrict__ partial,
    int64_t K,
    int splits
) {
    const int64_t row = static_cast<int64_t>(blockIdx.x) / splits;
    const int split = blockIdx.x % splits;
    const int64_t begin = static_cast<int64_t>(split) * CHUNK;
    const float* matrix_row = A + row * K;
    const int tid = threadIdx.x;

    float s0 = 0.0f;
    float s1 = 0.0f;
    float s2 = 0.0f;
    float s3 = 0.0f;

    if constexpr (VECTORIZED) {
        #pragma unroll
        for (int offset = tid * 4; offset < CHUNK; offset += THREADS * 4) {
            const int64_t k = begin + offset;
            if (k < K) {
                const float4 a =
                    *reinterpret_cast<const float4*>(matrix_row + k);
                const float4 b =
                    *reinterpret_cast<const float4*>(B + k);
                s0 = fmaf(a.x, b.x, s0);
                s1 = fmaf(a.y, b.y, s1);
                s2 = fmaf(a.z, b.z, s2);
                s3 = fmaf(a.w, b.w, s3);
            }
        }
    } else {
        #pragma unroll
        for (int offset = tid; offset < CHUNK; offset += THREADS * 4) {
            const int64_t k = begin + offset;
            if (k < K)
                s0 = fmaf(matrix_row[k], B[k], s0);
            if (k + THREADS < K)
                s1 = fmaf(matrix_row[k + THREADS], B[k + THREADS], s1);
            if (k + 2 * THREADS < K)
                s2 = fmaf(
                    matrix_row[k + 2 * THREADS], B[k + 2 * THREADS], s2);
            if (k + 3 * THREADS < K)
                s3 = fmaf(
                    matrix_row[k + 3 * THREADS], B[k + 3 * THREADS], s3);
        }
    }

    float sum = warp_sum((s0 + s1) + (s2 + s3));
    __shared__ float warp_sums[THREADS / 32];

    const int lane = tid & 31;
    const int warp = tid >> 5;

    if (lane == 0)
        warp_sums[warp] = sum;
    __syncthreads();

    if (warp == 0) {
        sum = lane < THREADS / 32 ? warp_sums[lane] : 0.0f;
        sum = warp_sum(sum);
        if (lane == 0)
            partial[row * splits + split] = sum;
    }
}

__global__ void finish_gemv(
    const float* __restrict__ partial,
    float* __restrict__ output,
    int64_t M,
    int splits
) {
    const int lane = threadIdx.x & 31;
    const int64_t row =
        static_cast<int64_t>(blockIdx.x) * (THREADS / 32)
        + (threadIdx.x >> 5);

    if (row >= M)
        return;

    float sum = 0.0f;
    for (int split = lane; split < splits; split += 32)
        sum += partial[row * splits + split];

    sum = warp_sum(sum);
    if (lane == 0)
        output[row] = sum;
}

torch::Tensor split_gemv_cuda(torch::Tensor A, torch::Tensor B) {
    const c10::cuda::CUDAGuard guard(A.device());

    A = A.contiguous();
    B = B.contiguous();

    const int64_t M = A.size(0);
    const int64_t K = A.size(1);
    const int splits = static_cast<int>((K + CHUNK - 1) / CHUNK);

    auto partial = torch::empty({M, splits}, A.options());
    auto output = torch::empty({M, 1}, A.options());

    const float* a = A.data_ptr<float>();
    const float* b = B.data_ptr<float>();
    const bool vectorized =
        (K % 4 == 0) &&
        (reinterpret_cast<uintptr_t>(a) % 16 == 0) &&
        (reinterpret_cast<uintptr_t>(b) % 16 == 0);

    const auto stream = at::cuda::getCurrentCUDAStream(A.get_device());
    const unsigned int blocks = static_cast<unsigned int>(M * splits);

    if (vectorized) {
        partial_gemv<true><<<blocks, THREADS, 0, stream>>>(
            a, b, partial.data_ptr<float>(), K, splits);
    } else {
        partial_gemv<false><<<blocks, THREADS, 0, stream>>>(
            a, b, partial.data_ptr<float>(), K, splits);
    }
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    finish_gemv<<<
        static_cast<unsigned int>((M + THREADS / 32 - 1) / (THREADS / 32)),
        THREADS, 0, stream
    >>>(partial.data_ptr<float>(), output.data_ptr<float>(), M, splits);
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    return output;
}
"""

_gemv = load_inline(
    name="split_gemv_16384_v1",
    cpp_sources=_cpp_source,
    cuda_sources=_cuda_source,
    functions=["split_gemv_cuda"],
    extra_cflags=["-O3", "-std=c++17"],
    extra_cuda_cflags=["-O3", "-std=c++17"],
    verbose=False,
)


class ModelNew(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:
        if (
            A.is_cuda
            and B.is_cuda
            and A.device == B.device
            and A.dtype == torch.float32
            and B.dtype == torch.float32
            and A.layout == torch.strided
            and B.layout == torch.strided
            and A.ndim == 2
            and B.ndim == 2
            and B.shape[1] == 1
            and A.shape[1] == B.shape[0]
            and A.shape[0] > 0
            and A.shape[1] > 0
            and not (torch.is_grad_enabled() and (A.requires_grad or B.requires_grad))
        ):
            return _gemv.split_gemv_cuda(A, B)
        return torch.matmul(A, B)
```