github jax-ml/ml_dtypes v0.7.0

2 hours ago
  • Added new 8-bit unsigned float type: ml_dtypes.float8_e5m3fnu
    (#407).
  • ml_dtypes types now use the NumPy 2 DType API
    (#374, #418, #424):
    • Fixed np.result_type and np.promote_types for ml_dtypes types and
      Python scalars. Mixed operations with Python int, float, and complex
      values now follow NumPy 2 (NEP 50) promotion rules instead of upcasting to
      float64 or complex128 (for example, bfloat16(2.0) + 1e-3 stays in
      bfloat16). Comparing a finite-only or unsigned float against an
      out-of-range Python float converts the Python float to the ml_dtypes type
      first (e.g., float8_e4m3fn(448.0) < 1000.0 is False because
      float8_e4m3fn(1000.0) overflows to NaN; use float(x) < 1000.0 for
      wider bounds).
    • Fixed np.can_cast so lossy casts between 1-byte types (such as
      float8_e4m3fn to float4_e2m1fn) are no longer reported as "safe", and
      widening intN casts to longlong and ulonglong are now "safe".
    • Added casts between all pairs of ml_dtypes types, including narrowing and
      mixed-sign intN casts, int4/uint4 <-> float6_e2m3fn, and casts
      involving float8_e8m0fnu.
    • Multi-axis and empty-array ufunc reductions now work across all ml_dtypes
      types.
    • Casting non-finite or out-of-range floats to integers now consistently
      returns 0 and emits an invalid warning; casting complex types to real or
      integer ml_dtypes types emits ComplexWarning; integer division by zero
      respects np.errstate; and np.ldexp supports 64-bit integer exponents on
      all platforms.
  • Registered byte-aligned ml_dtypes types with NumPy's DLPack support on
    NumPy 2.5+ (#402).
  • np.finfo now supports ml_dtypes float and complex types, ml_dtypes.finfo
    now accepts "complex32", and np.float_power is now supported for float and
    complex types (#395).
  • Changed np.dtype(complex32).kind from 'V' to 'c', and changed
    dtype.char for complex32 and bcomplex32 to 'J' and 'K'
    (#357).
  • arr.real and arr.imag now return correct results for bcomplex32 and
    complex32 arrays on NumPy 2.5+ (#383).
  • Fixed byte-swapping of bcomplex32 and complex32 arrays
    (#383).
  • Fixed NaN ordering for complex32 and bcomplex32 in np.sort and
    np.searchsorted (#429),
    casting purely imaginary values to bool
    (#395), and TypeError
    handling in two-argument complex32(real, imag) / bcomplex32(real, imag)
    (#439).
  • Fixed double rounding when converting to ml_dtypes float and complex types
    from float64, longdouble, complex128, clongdouble, 32- and 64-bit
    integers, and Python/NumPy scalars, and fixed a crash when constructing floats
    from invalid strings (#401).
  • Constructing a float or complex scalar from a Python int outside the int64
    range no longer raises OverflowError when the value fits in float64
    (#447).
  • Fixed int(x) on ml_dtypes float and complex scalars for large values,
    inf, and NaN (#444).
  • Constructing intN values from Python floats now truncates toward zero before
    range checking (e.g. int4(7.5) returns 7 instead of raising
    OverflowError) (#443), and
    out-of-range errors now name the actual intN type instead of "int4"
    (#403).
  • Casts to float8_e8m0fnu now round values between 2-127 and
    1.5 × 2-127 down to 2-127 instead of up to
    2-126
    (#434).
  • np.copysign of zero no longer returns NaN for *fnuz types, and
    np.sign and np.heaviside of the smallest float8_e8m0fnu value now
    return 1 (#408,
    #416).
  • Fixed spurious invalid value warnings when casting quiet NaNs on ARM64
    (#426,
    #428).
  • complex_types.h can now be included in C++ without Python or NumPy headers
    (#422).
  • float8.h no longer depends on Eigen::numext::get_integer_by_size, which is
    unavailable in Eigen 3.4.x
    (#414).

Don't miss a new ml_dtypes release

NewReleases is sending notifications on new releases.