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")

Worked, runnable problems — one per number-system family, showing where each type wins — live in examples/ (see its README).

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.22.1

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.22.1
File Size Uploaded
universal_dtypes-0.22.1.tar.gz 75.9 kB Details

Built distributions (wheels)

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

Total release size: 3.1 MB

Release files / universal_dtypes-0.22.1.tar.gz

Download URL universal_dtypes-0.22.1.tar.gz
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
59878e9363f7f16ec1fe7b413563398de332b06c34f84ec5b343964e9f8c80f5
BLAKE2b-256 checksum
How to use checksums
41e2f2438d11087977cbf013bf5de0e2f880b313c1354164a3253f834cec7557
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp312-cp312-win_amd64.whl
Size 451.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7e13c936def4dc4dc51c99ee24ccac26c4e24601c25457c0e4cebb37c3ec8e43
BLAKE2b-256 checksum
How to use checksums
e01bd7dfe137e77668d183c6eb8b61b811f257956efc3dbbb2d4b230244d1f9f
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 9, 2026.

Transparency log

Release files / universal_dtypes-0.22.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.22.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 297.0 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
78c8a72de9ccbf0ec791936d3ca9bbe3a859bd8d9e2ea90a5bc6eabeba0775b4
BLAKE2b-256 checksum
How to use checksums
23e48d5b223056ed63daa31859b8b496f41a22e73181257e7bea55de1041a26a
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp312-cp312-macosx_11_0_arm64.whl
Size 256.6 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c70bc9c5d6c02e27c9906e8ff38d939543d3d1b5d8830902785eccbe281d6599
BLAKE2b-256 checksum
How to use checksums
6ce676f87eb8458969aed25c5512e148667252f26d90b8ac4121af8aca65c6fe
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp311-cp311-win_amd64.whl
Size 451.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ed6d455fbf0604b9206af0dbb4dccc245e1a079aa13ff674aa1690b47410c63d
BLAKE2b-256 checksum
How to use checksums
baf3650f8d7f77da087c3b206668ddbe093fe2acb312d78b2f4d2d6a292499da
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 9, 2026.

Transparency log

Release files / universal_dtypes-0.22.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.22.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 294.5 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
45208677dbfc0b6aefd3cefebbad42a5fe3ef739c4fbd60e31f150ba0ce76b85
BLAKE2b-256 checksum
How to use checksums
3ed5e236d9ddc4eab6895f80d0d105ae79353e0961026279cb99b75458b53349
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp311-cp311-macosx_11_0_arm64.whl
Size 253.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0537aa69676dbed66943d48359b34d0e72a6b20b9583ac15bdbd51a14d6c998d
BLAKE2b-256 checksum
How to use checksums
cb53a8e09333b192bec253001e6b226790da26a6108d60723a0721724fdfaca5
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp310-cp310-win_amd64.whl
Size 450.9 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5f5cc9c22d7f14878a985d514daa9bc1e2d346badcbe293a1e31cee3cc6dd3c3
BLAKE2b-256 checksum
How to use checksums
a5866b107fec76916164bf8f7de58927e501bf6c79d982e74a4f97a1f8f0c003
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 9, 2026.

Transparency log

Release files / universal_dtypes-0.22.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.22.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 294.3 kB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fe32a4a7681de11eb84645c872fa2d7736cf96083204ef9e816f43755c0edf00
BLAKE2b-256 checksum
How to use checksums
a3f86464ec5801e7f8437ac4cd967822a054719bad4543c507fa365fc07f241b
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 9, 2026.

Transparency log

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

Download URL universal_dtypes-0.22.1-cp310-cp310-macosx_11_0_arm64.whl
Size 253.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28e670e87a71533ab49184f3005e20c907465130ea5439eb21061bce1e81549e
BLAKE2b-256 checksum
How to use checksums
2230e809eb38be42789278997848d0083e8fca35063ea0432f154cf3f41ee76f
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 9, 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