Write a custom CUDA kernel to optimize `Quantile Loss`.

Formula:
  diff = y_true - y_pred
  loss = (diff >= 0) ? q * diff : (q - 1) * diff

Mathematically equivalent and branchless: `loss = max(q * diff, (q - 1) * diff)`

Problem Analysis:
1. Memory Bound: The operation is element-wise and computationally cheap. Performance is limited by memory bandwidth.
2. Operator Chaining: Standard implementation using `torch.where` or boolean masking creates intermediate tensors for the difference, the mask, and the scaled components, leading to high memory traffic.

Optimization Strategy: Fused Element-wise Kernel with Vectorization

1. One-Thread-per-Element: Map each element pair (pred, target) to a CUDA thread.

2. Vectorized Loads (float4): Use `float4` to process 128 bits per memory transaction, maximizing throughput.

3. Fused Branchless Math:
   - Load `pred` and `target` into registers.
   - Compute `diff = target - pred`.
   - Compute `loss = fmaxf(q * diff, (q - 1.0f) * diff)`.
   - The `fmaxf` intrinsic compiles to a single, efficient instruction without warp divergence.

4. Reduction Handling: The kernel calculates element-wise losses. The final reduction (mean/sum) is handled by the C++ wrapper.
  
Here's an example to show you the syntax of inline embedding custom CUDA operators in torch: The example given architecture is:   
  
```python
import torch
import torch.nn as nn

BATCH_SIZE = 4096
HIDDEN_DIM = 4096
SHAPE = (BATCH_SIZE, HIDDEN_DIM)

Q_VALUE = 0.9

class QuantileLoss(nn.Module):
    """
    Quantile Loss. L_q = q*|e| if e>=0 else (1-q)*|e|
    """
    def __init__(self, quantile=0.9, reduction='mean'):
        super(QuantileLoss, self).__init__()
        self.quantile = quantile
        self.reduction = reduction

    def forward(self, pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
        error = target - pred
        
        loss = torch.where(error >= 0, 
                         self.quantile * error, 
                         (1 - self.quantile) * -error)
        
        if self.reduction == 'mean':
            return loss.mean()
        elif self.reduction == 'sum':
            return loss.sum()
        return loss

class Model(nn.Module):
    def __init__(self, quantile=0.9, reduction='none'):
        super(Model, self).__init__()
        self.loss_fn = QuantileLoss(quantile=quantile, reduction=reduction)
    
    def forward(self, pred, target):
        return self.loss_fn(pred, target)

def get_inputs():
    pred = torch.randn(SHAPE, dtype=torch.float32)
    target = torch.randn(SHAPE, dtype=torch.float32)
    return [pred.contiguous(), target.contiguous()]

def get_init_inputs():
    return [Q_VALUE, 'none']