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

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.17.0
File Size Uploaded
universal_dtypes-0.17.0.tar.gz 61.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for universal-dtypes 0.17.0
File
universal_dtypes-0.17.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
universal_dtypes-0.17.0-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.17.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
universal_dtypes-0.17.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
universal_dtypes-0.17.0-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.17.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
universal_dtypes-0.17.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
universal_dtypes-0.17.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
universal_dtypes-0.17.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 2.7 MB

Release files / universal_dtypes-0.17.0.tar.gz

Download URL universal_dtypes-0.17.0.tar.gz
Size 61.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c6855c09c5c72e48e4bf777cf495478c8ac321404dcfd797873f8a11e10226f4
BLAKE2b-256 checksum
How to use checksums
37cc702d63341e8e251c7d0d949747acdec9477eb46210c755435181fbcb08c6
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.17.0-cp312-cp312-win_amd64.whl

Download URL universal_dtypes-0.17.0-cp312-cp312-win_amd64.whl
Size 413.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7de00d95a7fcda3fc262fb2f9b3ceb65528f6b8719463865d3d283df2e735088
BLAKE2b-256 checksum
How to use checksums
4f828685bf3bb5fbf6f25192837eab36b9d05d562811b001759c1e0d8a8e564d
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.17.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.17.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 253.8 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ca8591eeab010596a126a28a01e7e9b27e093da41d23f248bd46455515855838
BLAKE2b-256 checksum
How to use checksums
45eb247e92c75a783ce6d991cb91782d396d0f4df5ec76a9c325d46d36b4adcf
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.17.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.17.0-cp312-cp312-macosx_11_0_arm64.whl
Size 211.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fc72ebc0fb85ebcaf9ae00bbc61480ca97dac62ad1dc02b7a4b46ce6f5e3ee63
BLAKE2b-256 checksum
How to use checksums
e42182f748e2dc934a3a544f4272dd884cd1986aaadd8a9901ad04909520deef
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.17.0-cp311-cp311-win_amd64.whl

Download URL universal_dtypes-0.17.0-cp311-cp311-win_amd64.whl
Size 413.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
89fcad7c25d86207f74b175175bb892521d31bee4dd57617e2698010128663e2
BLAKE2b-256 checksum
How to use checksums
252e935d0d6b10d25079dd3033210b780f1d3a6a044c3f26dca026d7ac179b8d
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.17.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.17.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 252.7 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4bab5c9e96197f1f0fdac501fe8ee180064c971e9cd485231522a334196ffd26
BLAKE2b-256 checksum
How to use checksums
738b0056e5c5091607eb4727b361ed3333c4cabf0843168d1b39dd166c381dca
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.17.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.17.0-cp311-cp311-macosx_11_0_arm64.whl
Size 208.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1a7361a75ef03d9646676dee266009f52c1a5dc99c9dc2d10abb91376a39d79d
BLAKE2b-256 checksum
How to use checksums
601ddc607845d7d77e36725babc4711307e68843c4a1288dd0198ac71ad9c5a6
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.17.0-cp310-cp310-win_amd64.whl

Download URL universal_dtypes-0.17.0-cp310-cp310-win_amd64.whl
Size 413.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
e7889eec07a3f561a5935309879f8643769b5f2aa77e272a548baa89dfa473c7
BLAKE2b-256 checksum
How to use checksums
f9436bb301b0821ba6bd779fb6fc4fccdc30170ea10090d0b2fadd542c0fcfb1
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.17.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.17.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 252.8 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
468d83f7a6d003e34a35a1e3289c10a78e51ad3573f29f577fab55a58e8f4e13
BLAKE2b-256 checksum
How to use checksums
d95423207cf5140dd8012248a39063e09d5e51e0955f392488f63a38ef68e1e2
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.17.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.17.0-cp310-cp310-macosx_11_0_arm64.whl
Size 208.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b4f440b489080dbeec4f492e32a46426edf393ed5191ffa05892f31ba0a7a65
BLAKE2b-256 checksum
How to use checksums
b9322b1a7e4719eef24dd355b219d40c6eb49415320afd52553614e7838ced49
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