Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A stand-alone implementation of several NumPy dtype extensions used in machine learning.
| Date | Stars |
|---|---|
| 2026-07-31 | 354 |
| 2026-08-05 | 356 |
| 2026-08-06 | 357 |
Today
+1 stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# ml_dtypes
[](https://github.com/jax-ml/ml_dtypes/actions/workflows/test.yml)
[](https://github.com/jax-ml/ml_dtypes/actions/workflows/wheels.yml)
[](https://badge.fury.io/py/ml_dtypes)
`ml_dtypes` is a stand-alone implementation of several NumPy dtype extensions used in machine learning libraries, including:
- [`bfloat16`](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format):
an alternative to the standard [`float16`](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) format
- 8-bit floating point representations, parameterized by number of exponent and
mantissa bits, as well as the bias (if any) and representability of infinity,
NaN, and signed zero.
* `float8_e3m4`
* `float8_e4m3`
* `float8_e4m3b11fnuz`
* `float8_e4m3fn`
* `float8_e4m3fnuz`
* `float8_e5m2`
* `float8_e5m2fnuz`
* `float8_e8m0fnu`
- Microscaling (MX) sub-byte floating point representations:
* `float4_e2m1fn`
* `float6_e2m3fn`
* `float6_e3m2fn`
- Narrow integer encodings:
* `int1`
* `int2`
* `int4`
* `uint1`
* `uint2`
* `uint4`
See below for specifications of these number formats.
## Installation
The `ml_dtypes` package is tested with Python versions 3.9-3.12, and can be installed
with the following command:
```
pip install ml_dtypes
```
To test your installation, you can run the following:
```
pip install absl-py pytest
pytest --pyargs ml_dtypes
```
To build from source, clone the repository and run:
```
git submodule init
git submodule update
pip install .
```
## Example Usage
```python
>>> from ml_dtypes import bfloat16
>>> import numpy as np
>>> np.zeros(4, dtype=bfloat16)
array([0, 0, 0, 0], dtype=bfloat16)
```
Importing `ml_dtypes` also registers the data types with numpy, so that they may
be referred to by their string name:
```python
>>> np.dtype('bfloat16')
dtype(bfloat16)
>>> np.dtype('float8_e5m2')
dtype(float8_e5m2)
```
## Specifications of implemented floating point formats
### `bfloat16`
A `bfloat16` number is a single-precision float truncated at 16 bits.
Exponent: 8, Mantissa: 7, exponent bias: 127. IEEE 754, with NaN and inf.
### `float4_e2m1fn`
Exponent: 2, Mantissa: 1, bias: 1.
Extended range: no inf, no NaN.
Microscaling format, 4 bits (encoding: `0bSEEM`) using byte storage (higher 4
bits are unused). NaN representation is undefined.
Possible absolute values: [`0`, `0.5`, `1`, `1.5`, `2`, `3`, `4`, `6`]
### `float6_e2m3fn`
Exponent: 2, Mantissa: 3, bias: 1.
Extended range: no inf, no NaN.
Microscaling format, 6 bits (encoding: `0bSEEMMM`) using byte storage (higher 2
bits are unused). NaN representation is undefined.
Possible values range: [`-7.5`; `7.5`]
### `float6_e3m2fn`
Exponent: 3, Mantissa: 2, bias: 3.
Extended range: no inf, no NaN.
Microscaling format, 4 bits (encoding: `0bSEEEMM`) using byte storage (higher 2
bits are unused). NaN representation is undefined.
Possible values range: [`-28`; `28`]
### `float8_e3m4`
Exponent: 3, Mantissa: 4, bias: 3. IEEE 754, with NaN and inf.
### `float8_e4m3`
Exponent: 4, Mantissa: 3, bias: 7. IEEE 754, with NaN and inf.
### `float8_e4m3b11fnuz`
Exponent: 4, Mantissa: 3, bias: 11.
Extended range: no inf, NaN represented by 0b1000'0000.
### `float8_e4m3fn`
Exponent: 4, Mantissa: 3, bias: 7.
Extended range: no inf, NaN represented by 0bS111'1111.
The `fn` suffix is for consistency with the corresponding LLVM/MLIR type, signaling this type is not consistent with IEEE-754. The `f` indicates it is finite values only. The `n` indicates it includes NaNs, but only at the outer range.
### `float8_e4m3fnuz`
8-bit floating point with 3 bit mantissa.
An 8-bit floating point type with 1 sign bit, 4 bits exponent and 3 bits mantissa. The suffix `fnuz` is consistent with LLVM/MExcerpt of 7,822 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:061e888a45515d4d, llm:description: 'A stand-alone implementation of several NumPy dtype extensions used in machine learning.' language: C++
matched fp:061e888a45515d4d, llm:description: 'A stand-alone implementation of several NumPy dtype extensions used in machine learning.' language: C++