     // NumPy behavior: NaN is always chosen!
     if (isnan(a)) {return a;}
     else if (isnan(b)) {return b;}
-    #ifndef CUPY_USE_HIP
-    else {return CUB_MAX(a, b);}
-    #else
-    else {return max(a, b);}
-    #endif
+    else {return a < b ? b : a;}
 }
 
 // specialization for double for handling NaNs

    // - isnan() and max() are defined in cupy/complex.cuh
    if (isnan(a)) {return a;}
    else if (isnan(b)) {return b;}
    else {return max(a, b);}
}

// specialization for complex<double> for handling NaNs

    // NumPy behavior: NaN is always chosen!
    if (half_isnan(a)) {return a;}
    else if (half_isnan(b)) {return b;}
    else { return half_less(a, b) ? a : b; }
}
#endif

