Skip to main content

universal_dtypes

License: MIT PyPI version Python

Status — early development. The repository is scaffolded and the design is settled (see docs/design.md); the NumPy dtype implementation has not started. The installation and usage snippets below describe the intended API — universal_dtypes is not yet published to PyPI.

universal_dtypes is a stand-alone Python package that registers the Stillwater Universal number systems as first-class NumPy dtypes, so alternative real-number formats can be used directly in NumPy (and pandas) arrays. It is modeled on ml_dtypes, which does the same for machine-learning float formats used by JAX and TensorFlow.

The following dtypes are planned:

  • posit8, posit16, posit32, posit64 — tapered-precision posits (Posit Standard, es = 2)
  • fp8, fp16 — configurable low-precision floats (Universal cfloat)
  • fixpnt8, fixpnt16 — fixed-point
  • lns16, lns32 — logarithmic number system

Linear algebra over these types (dense/sparse solvers, and the quire-based exact accumulation policy) lives in the sister package mtl5-python, which consumes these dtypes. See Relationship to MTL5.

Installation

universal_dtypes will be published to PyPI as universal-dtypes (PEP 503 normalizes the underscore to a hyphen; pip install universal_dtypes also resolves):

pip install universal_dtypes

To run the tests:

pip install universal_dtypes[dev]
pytest

To build from source (the build fetches the Universal C++ headers via CMake FetchContent; a C++20 compiler is required):

git clone https://github.com/stillwater-sc/universal_dtypes
cd universal_dtypes
pip install -e ".[dev]"

Example usage

import numpy as np
import universal_dtypes

a = np.array([1.0, 2.0, 3.0], dtype=universal_dtypes.posit16)
b = a * 2  # element-wise arithmetic, in posit16
c = np.sum(a)  # NumPy reductions (naive posit accumulation)
n = np.sqrt(a)  # NumPy ufuncs

The dtypes also register under their string names, so NumPy's usual APIs accept them:

np.dtype("posit16")
np.zeros(4, dtype="posit16")
np.arange(8, dtype="fp8")

Specifications of implemented number formats

Posits — posit8, posit16, posit32, posit64

A posit posit<nbits, es> encodes a real number with a sign bit, a run-length regime field, up to es exponent bits, and the remaining bits as fraction. Precision is tapered: it is highest for magnitudes near ±1 and decreases toward 0 and ±∞. Posits have no subnormals and no separate infinities or NaNs — a single exceptional value NaR ("Not a Real") represents overflow, division by zero, and other undefined results. The standard sizes use es = 2 (posit8 = posit<8,2>, posit16 = posit<16,2>, and so on).

Configurable floats — fp8, fp16

Universal's cfloat is a parameterized IEEE-754-style float (sign / exponent / fraction). fp8 and fp16 are low-precision configurations for mixed-precision work. Unlike posits, they follow the familiar exponent/mantissa layout and can carry subnormals, infinities, and NaN depending on the configuration.

Fixed-point — fixpnt8, fixpnt16

Fixed-point fixpnt<nbits, rbits> is a two's-complement integer interpreted as a value scaled by 2^-rbits — a fixed absolute resolution across its whole range (in contrast to floating formats), with configurable rounding and saturation/wrap-around on overflow.

Logarithmic number system — lns16, lns32

The logarithmic number system stores a sign and the base-2 logarithm of the magnitude. Multiplication and division become addition and subtraction of the stored logarithms (cheap and exact in the exponent), at the cost of more expensive addition and subtraction.

Encodings and exceptional values

Each type is a true NumPy dtype with a fixed item size — posit8/fixpnt8/fp8 occupy one byte, posit16/fixpnt16/fp16/lns16 two bytes, posit32/lns32 four, and posit64 eight. Exceptional values differ by family and are not interchangeable with IEEE semantics:

  • posits have a single NaR and no ±inf/NaN; overflow saturates toward the largest-magnitude finite posit rather than producing infinity.
  • cfloat (fp8/fp16) may expose ±inf and NaN per its configuration.
  • fixpnt has no non-finite values; out-of-range results saturate or wrap.
  • lns carries its own encodings for zero and its exceptional value.

Casts to and from float32/float64 (and the integer types) round to the target format; converting a non-finite IEEE value into a posit yields NaR.

Quirks of low-precision arithmetic

As with any low-precision format, naive accumulation loses information. Summing many values in posit16 rounds after every partial sum:

import numpy as np
import universal_dtypes

x = np.ones(4096, dtype=universal_dtypes.posit16)
np.sum(x)  # rounds each partial sum in posit16 — not 4096 exactly

The standard fix is to accumulate in higher precision. Universal's posits also provide the quire — a fixed-point accumulator wide enough to hold an exact sum of products, rounding only once at the end. The quire is an algorithm concern (how you accumulate), so it lives in the linear-algebra layer, not in the dtype: it is exposed by mtl5-python through accumulator= on dot, norm, and the other reduction-bearing operations. universal_dtypes deliberately gives ordinary NumPy semantics for the dtype; when you need an exact reduction, reach for MTL5:

import mtl5

# exact posit16 sum-of-products via the quire (single final rounding)
mtl5.dot(x, np.ones_like(x), accumulator="quire")

The two answers will differ on ill-conditioned data — by design.

Relationship to MTL5

universal_dtypes is the element type and its scalar / element-wise arithmetic. mtl5-python is what you do with arrays of them: dense/sparse linear algebra, and the quire / accumulator mixed-precision policy. mtl5-python depends on universal_dtypes for the dtypes; universal_dtypes does not depend on MTL5. See docs/design.md for the full rationale and the package boundary.

License

universal_dtypes is licensed under the MIT License — see LICENSE. Copyright © 2026 Stillwater Supercomputing, Inc.

It builds on Universal (MIT), whose header-only number-system implementations provide the arithmetic behind each dtype.

Metadata

Release files for universal-dtypes 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for universal-dtypes 0.1.2
File Size Uploaded
universal_dtypes-0.1.2.tar.gz 28.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for universal-dtypes 0.1.2
File
universal_dtypes-0.1.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
universal_dtypes-0.1.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
universal_dtypes-0.1.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
universal_dtypes-0.1.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
universal_dtypes-0.1.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
universal_dtypes-0.1.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
universal_dtypes-0.1.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
universal_dtypes-0.1.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
universal_dtypes-0.1.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 1.0 MB

Release files / universal_dtypes-0.1.2.tar.gz

Download URL universal_dtypes-0.1.2.tar.gz
Size 28.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c776d773b1fdb9a737a5d3bf214eac05c4b088ed27a9ae3e2bab029d68e6a303
BLAKE2b-256 checksum
How to use checksums
df28f12c704e1f53194ac433d2c1d1a9db5403962c6491248c2310b22433aa4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp312-cp312-win_amd64.whl

Download URL universal_dtypes-0.1.2-cp312-cp312-win_amd64.whl
Size 237.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
daa3a08f20e7b5050b83e1b063e69adb670c1f8cc9dbd939a11a0a451f136362
BLAKE2b-256 checksum
How to use checksums
91a8f8656d1329d1945c085c4aaaa5f61597ecacc479ec19162f89840e04fde1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.1.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 55.4 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2ed5f85d1fd8b27d33f3e6c4c6718d941cbe6a8bb13878b6adc891e074fe577a
BLAKE2b-256 checksum
How to use checksums
48bdbe03e84a2de186a49cd5205310b049faa349be7b64a206802bc8aedbe82a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Size 45.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b2f806e502f2a8f30686beda0f907ba8f5dfc886c5b6c290bd9ec43d385cb5a9
BLAKE2b-256 checksum
How to use checksums
a2a48daaa5d786ebddf4a2936bb98dc483c68c83092e66de8f17c731ee866225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp311-cp311-win_amd64.whl

Download URL universal_dtypes-0.1.2-cp311-cp311-win_amd64.whl
Size 237.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
35379e33fda14363f3d2d6f348372a27941ccdf9da3ed6f46074151585bad95d
BLAKE2b-256 checksum
How to use checksums
96df61f332eff833edcd71fb85c62919377bc27a709d15f55a0d92d750efee08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.1.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 55.9 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cd7b3a8eec4627a69d7ef7bdddee83d9bd984d31544e67e4e4b696c575b4c5c0
BLAKE2b-256 checksum
How to use checksums
7609cff7f90ddb270639d47fc3572a5e85f95ed33efd013a12bffe360ea378a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Size 46.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
57beb584741106b3968bcedecc7b7f538dd2ebe4bd226d7f96b28d8939d77a0e
BLAKE2b-256 checksum
How to use checksums
9152f0880607c4b75073cb0bebf09478ece6ec0a0eb4cc682eb64badadafdd09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp310-cp310-win_amd64.whl

Download URL universal_dtypes-0.1.2-cp310-cp310-win_amd64.whl
Size 237.4 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
08f43f3152f6fd744aae0cb58a6c6911186ff45a01f5c3df7dbe69d9d57b2c43
BLAKE2b-256 checksum
How to use checksums
9fd467b4ac74463ec283fcde8612848ffc4b95dac8448a05cab61282cb075e18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.1.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 55.9 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e2c54d3f703e641d7644fc8d11cad065ddf4770fd4476c58a29fe63d3f19f1e4
BLAKE2b-256 checksum
How to use checksums
9ab509dd58e9f49c9e0b24c9ff613ade9ba77bb44f5c98fbdeb8af952f4f2eb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / universal_dtypes-0.1.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Size 46.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d28610c268c129d965ac7cfbf664e0378c2d2ce4947dd612046481177afe8c66
BLAKE2b-256 checksum
How to use checksums
bdee32cddf958c34eaa2604910cc1187fe45ea916c3dd625ccfc63f487b957fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page