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.9.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.9.0
File Size Uploaded
universal_dtypes-0.9.0.tar.gz 49.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for universal-dtypes 0.9.0
File
universal_dtypes-0.9.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
universal_dtypes-0.9.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.9.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
universal_dtypes-0.9.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
universal_dtypes-0.9.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.9.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
universal_dtypes-0.9.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
universal_dtypes-0.9.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.9.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 2.3 MB

Release files / universal_dtypes-0.9.0.tar.gz

Download URL universal_dtypes-0.9.0.tar.gz
Size 49.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6e69ba71b99e3cdb6d251e641a1a575f846f51bb9ebd6a5ea2e25151e18efb78
BLAKE2b-256 checksum
How to use checksums
4ffaf2094742104394aef11cd7d188f5887eb13b5f47d5d2fd1dfa4ed41906af
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.9.0-cp312-cp312-win_amd64.whl

Download URL universal_dtypes-0.9.0-cp312-cp312-win_amd64.whl
Size 369.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
140e67228cd5a1cca85966b3c8214cc7fda28ac2dba390590cfda429599b8fa8
BLAKE2b-256 checksum
How to use checksums
ab22c45ddd4970ab4a64037840987849d0d0b02d4457dc0d4a8b7515b4df55d0
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.9.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.9.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 210.1 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
162c03b9a8c3673aa80947c9b7d378098f24ad35e4e29ae4b6ddd7467b777b66
BLAKE2b-256 checksum
How to use checksums
396cbdf25fbd431a70351d0c4c712cd4c5a37710a32db5c41c898523b7b185c7
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.9.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
Size 173.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b5b106010788215e1aa03af6a30b591f75e29d0c0f108c8b20fdcba9cb7a1ce7
BLAKE2b-256 checksum
How to use checksums
77510f503ecd16998b02985b0bdf3dd171cc7fdf8accbd0644ce3dc59cef6a88
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.9.0-cp311-cp311-win_amd64.whl

Download URL universal_dtypes-0.9.0-cp311-cp311-win_amd64.whl
Size 369.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
f7f8f2bf0bf0c2ba7094ce4f323f1a19eed2c5cdce2799162a8e6811e2e8af27
BLAKE2b-256 checksum
How to use checksums
9da050c912052c2d8dfa8d814c07e498d74515542f68101a6186a88f345bbf53
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.9.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.9.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 209.1 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c874fb5433b547c6ea1a51cd46f9159ede52d0140a928dd3a6c062027b0956cb
BLAKE2b-256 checksum
How to use checksums
b74ff98ec77d9d8dabc407c2c2196d4272e7565b2c22c5aebd8bfef49b538a2f
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.9.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Size 171.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4f66862bb61e305e6818457ae9f25e2b0214eb373baa2dc07c212b1dbb5e654f
BLAKE2b-256 checksum
How to use checksums
8464cd63b54cdc13b97a11c56102ae185a7ef1b78ac77e10c2a238f54a4551c1
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.9.0-cp310-cp310-win_amd64.whl

Download URL universal_dtypes-0.9.0-cp310-cp310-win_amd64.whl
Size 369.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
58441288ad0d2463ea08acd256ee8f2df86eed1f8fe08e178b99b2466707dede
BLAKE2b-256 checksum
How to use checksums
1ac025c6ac78498d0d435772423a31c84a218a96e06f249a73b211d1fc759eb5
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.9.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL universal_dtypes-0.9.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 209.2 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
52b8c3345ff503cd241a5a8dbfffa1280608c30fba9c48fb7720928b63aa8f3d
BLAKE2b-256 checksum
How to use checksums
0d538d35fac43ffae9049d13c7680ced0bae4bcef6b623623997eda5376ec028
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.9.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL universal_dtypes-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
Size 171.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
19b8ed520fa9c5d270d9add42696c8f1e6d0fc3c445830c6bce55588df132bb1
BLAKE2b-256 checksum
How to use checksums
5eba1426bb237b7d04c5eada0be0f9255047e8bd3fe106dd25f6c4727188239c
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