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


_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 <cublas_v2.h>
#include <algorithm>
#include <climits>

__device__ __forceinline__ float activate(
    float x, float bias, float subtract_value, float multiply_value
) {
    x = __fadd_rn(x, bias);
    x = __fsub_rn(x, subtract_value);
    x = __fmul_rn(x, multiply_value);
    return x < 0.0f ? 0.0f : x;
}

__global__ void epilogue4(
    float4* __restrict__ output,
    const float4* __restrict__ bias,
    int64_t count,
    int columns,
    float subtract_value,
    float multiply_value
) {
    for (int64_t i = int64_t(blockIdx.x) * blockDim.x + threadIdx.x;
         i < count;
         i += int64_t(blockDim.x) * gridDim.x) {
        float4 v = output[i];
        const float4 b = bias[i % columns];
        v.x = activate(v.x, b.x, subtract_value, multiply_value);
        v.y = activate(v.y, b.y, subtract_value, multiply_value);
        v.z = activate(v.z, b.z, subtract_value, multiply_value);
        v.w = activate(v.w, b.w, subtract_value, multiply_value);
        output[i] = v;
    }
}

__global__ void epilogue1(
    float* __restrict__ output,
    const float* __restrict__ bias,
    int64_t count,
    int columns,
    float subtract_value,
    float multiply_value
) {
    for (int64_t i = int64_t(blockIdx.x) * blockDim.x + threadIdx.x;
         i < count;
         i += int64_t(blockDim.x) * gridDim.x) {
        output[i] = activate(
            output[i], bias[i % columns],
            subtract_value, multiply_value
        );
    }
}

torch::Tensor linear_activate_cuda(
    torch::Tensor x,
    torch::Tensor weight,
    torch::Tensor bias,
    double subtract_value,
    double multiply_value
) {
    TORCH_CHECK(x.is_cuda() && weight.is_cuda() && bias.is_cuda(),
                "Expected CUDA tensors");
    TORCH_CHECK(x.scalar_type() == at::kFloat &&
                weight.scalar_type() == at::kFloat &&
                bias.scalar_type() == at::kFloat,
                "Expected float32 tensors");
    TORCH_CHECK(x.device() == weight.device() &&
                x.device() == bias.device(),
                "Tensors must share a device");
    TORCH_CHECK(x.dim() == 2 && weight.dim() == 2 &&
                bias.dim() == 1 &&
                x.size(1) == weight.size(1) &&
                bias.numel() == weight.size(0),
                "Invalid tensor shapes");
    TORCH_CHECK(x.size(0) <= INT_MAX &&
                weight.size(0) <= INT_MAX &&
                x.size(1) <= INT_MAX,
                "Matrix dimensions exceed cuBLAS limits");

    const c10::cuda::CUDAGuard guard(x.device());
    x = x.contiguous();
    weight = weight.contiguous();
    bias = bias.contiguous();

    const int m = static_cast<int>(x.size(0));
    const int n = static_cast<int>(weight.size(0));
    const int k = static_cast<int>(x.size(1));
    auto output = torch::empty({m, n}, x.options());

    if (m == 0 || n == 0) {
        return output;
    }

    cudaStream_t stream = at::cuda::getCurrentCUDAStream();

    if (k == 0) {
        C10_CUDA_CHECK(cudaMemsetAsync(
            output.data_ptr<float>(), 0,
            output.numel() * sizeof(float), stream
        ));
    } else {
        cublasHandle_t handle = at::cuda::getCurrentCUDABlasHandle();

        cublasMath_t old_math;
        cublasPointerMode_t old_pointer_mode;
        TORCH_CHECK(cublasGetMathMode(handle, &old_math) ==
                    CUBLAS_STATUS_SUCCESS, "Could not get cuBLAS math mode");
        TORCH_CHECK(cublasGetPointerMode(handle, &old_pointer_mode) ==
                    CUBLAS_STATUS_SUCCESS, "Could not get cuBLAS pointer mode");

        TORCH_CHECK(cublasSetMathMode(handle, CUBLAS_TF32_TENSOR_OP_MATH) ==
                    CUBLAS_STATUS_SUCCESS, "Could not enable TF32");
        const cublasStatus_t pointer_status =
            cublasSetPointerMode(handle, CUBLAS_POINTER_MODE_HOST);
        if (pointer_status != CUBLAS_STATUS_SUCCESS) {
            cublasSetMathMode(handle, old_math);
            TORCH_CHECK(false, "Could not set cuBLAS pointer mode");
        }

        const float alpha = 1.0f;
        const float beta = 0.0f;

        // Row-major Y = X W^T is column-major Y^T = W X^T.
        const cublasStatus_t status = cublasGemmEx(
            handle,
            CUBLAS_OP_T,
            CUBLAS_OP_N,
            n, m, k,
            &alpha,
            weight.data_ptr<float>(), CUDA_R_32F, k,
            x.data_ptr<float>(), CUDA_R_32F, k,
            &beta,
            output.data_ptr<float>(), CUDA_R_32F, n,
            CUBLAS_COMPUTE_32F_FAST_TF32,
            CUBLAS_GEMM_DEFAULT_TENSOR_OP
        );

        const cublasStatus_t restore_pointer =
            cublasSetPointerMode(handle, old_pointer_mode);
        const cublasStatus_t restore_math =
            cublasSetMathMode(handle, old_math);

        TORCH_CHECK(status == CUBLAS_STATUS_SUCCESS,
                    "cuBLAS GEMM failed: ", static_cast<int>(status));
        TORCH_CHECK(restore_pointer == CUBLAS_STATUS_SUCCESS &&
                    restore_math == CUBLAS_STATUS_SUCCESS,
                    "Could not restore cuBLAS handle state");
    }

    constexpr int threads = 256;
    const int64_t count = output.numel();
    const bool vectorized =
        n % 4 == 0 &&
        reinterpret_cast<uintptr_t>(bias.data_ptr<float>()) % 16 == 0;

    if (vectorized) {
        const int64_t vectors = count / 4;
        const int blocks = static_cast<int>(
            std::min<int64_t>((vectors + threads - 1) / threads, 4096)
        );
        epilogue4<<<blocks, threads, 0, stream>>>(
            reinterpret_cast<float4*>(output.data_ptr<float>()),
            reinterpret_cast<const float4*>(bias.data_ptr<float>()),
            vectors, n / 4,
            static_cast<float>(subtract_value),
            static_cast<float>(multiply_value)
        );
    } else {
        const int blocks = static_cast<int>(
            std::min<int64_t>((count + threads - 1) / threads, 4096)
        );
        epilogue1<<<blocks, threads, 0, stream>>>(
            output.data_ptr<float>(), bias.data_ptr<float>(),
            count, n,
            static_cast<float>(subtract_value),
            static_cast<float>(multiply_value)
        );
    }

    C10_CUDA_KERNEL_LAUNCH_CHECK();
    return output;
}
"""

_extension = load_inline(
    name="linear_tf32_fused_activation_v2",
    cpp_sources=r"""
        torch::Tensor linear_activate_cuda(
            torch::Tensor x,
            torch::Tensor weight,
            torch::Tensor bias,
            double subtract_value,
            double multiply_value
        );
    """,
    cuda_sources=_cuda_source,
    functions=["linear_activate_cuda"],
    extra_cflags=["-O3"],
    extra_cuda_cflags=["-O3"],
    extra_ldflags=["-lcublas"],
    verbose=False,
)


class ModelNew(nn.Module):
    def __init__(
        self, in_features, out_features, subtract_value, multiply_value
    ):
        super().__init__()
        self.linear = nn.Linear(in_features, out_features)
        self.subtract_value = subtract_value
        self.multiply_value = multiply_value

    def forward(self, x):
        if (
            not x.is_cuda
            or x.dtype != torch.float32
            or self.linear.weight.dtype != torch.float32
            or self.linear.bias.dtype != torch.float32
            or torch.is_autocast_enabled()
        ):
            y = F.linear(x, self.linear.weight, self.linear.bias)
            return torch.relu(
                (y - self.subtract_value) * self.multiply_value
            )

        shape = (*x.shape[:-1], self.linear.out_features)
        rows = x.numel() // x.shape[-1] if x.shape[-1] else (
            x.shape[:-1].numel()
        )
        output = _extension.linear_activate_cuda(
            x.reshape(rows, self.linear.in_features),
            self.linear.weight,
            self.linear.bias,
            float(self.subtract_value),
            float(self.multiply_value),
        )
        return output.view(shape)
```