Skip to main content

What is Quadrants Typing?

A typing layer for the quadrants, plus PEP 561 type stubs for the quadrants package itself. Installing this one package gives quadrants users both:

  • quadrants_typing — generic Vec, Mat, NDArray, dimension, and dtype types for annotating quadrants kernels. Import it under the conventional alias:

    import quadrants_typing as qdt
    import quadrants as qd
    
    @qd.kernel
    def add(
        x: qdt.NDArray[qd.i32, qdt.Dim1], 
        y: qdt.NDArray[qd.i32, qdt.Dim1],
    ) -> None:
        for i in range(x.shape[0]):
            x[i] = y[i]
    
  • Automatic quadrants stubs — type checkers (pyright, mypy) discover the bundled quadrants-stubs package via PEP 561 with no configuration, so import quadrants is fully typed.

Quadrants Replacements

Type annotations replaces directly some quadrants functions, mostly from qd.types. Here is a full table:

  • N,R,C in {1,2,3,4,5,6,7,8}
  • dtype n {qd.u8, qd.u16, qd.u32, ... etc.}
Description qdt version qd version Example
Concrete tensor type qdt.NDArray[qd.<dtype>, Dim<N>] qd.types.NDArray[qd.<dtype>, <N>] qdt.NDArray[qd.i32, Dim3]
Templated tensor type qdt.NDArray[T, DimAny] qd.types.ndarray(dtype=None, ndim=None) def f[T: (qd.i32, qd.f32)](arr: qdt.NDArray[T, DimAny])
Vector type qdt.Vec[qd.<dtype>, Dim<N>] qd.types.vector(<N>, qd.<dtype>) qdt.Vec[qd.f32, Dim3]
Matrix type qdt.Mat[qd.<dtype>, Dim<R>, Dim<C>] qd.types.matrix(<R>, <C>, qd.<dtype>) qdt.Mat[qd.f32, Dim3, Dim4]
Compile-time value qdt.Template[T] qd.template() qdt.Template[bool]

If you would like to construct tensors with a rank greater than 8, or vectors and matrices with any dimension longer than 8, you can. See weird_hacks example for how to create the annotation, or use qd.types.vector or qd.types.matrix if you only need a constructor (e.g. for a local array).

Examples

Runnable, annotated example programs live in examples/. Run one by name:

pixi run example init_ndarray

How Finished is This?

Not at all! There's lots of work still to be done :P. Please help!

Omissions

Names present in quadrants that we intentionally do not stub in qdt, with the reason / recommended alternative:

Intentional

  • qd.types.struct: use dataclasses.dataclass
  • qd.types.NDArray: superseded by qdt.NDArray[qd.<dtype>, Dim<N>]
  • qd.types.ndarray: superseded by qdt.NDArray[T, DimAny]
  • qd.types.Template: superseded by qdt.Template[T]
  • qd.template: superseded by qdt.Template[T]

Todo

  • qd.types.ref: todo(real_func)
  • qd.types.quant.* (int, float, fixed): todo(field)
  • qd.types.sparse_matrix_builder: todo(sparse_matrix)
  • quadrants.lang.simt.grid, .tile_slicing: todo(simt) — simt.block, .warp, .subgroup (incl. its reductions/sorting re-exports) are stubbed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quadrants_typing-0.2.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quadrants_typing-0.2.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file quadrants_typing-0.2.0.tar.gz.

File metadata

  • Download URL: quadrants_typing-0.2.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quadrants_typing-0.2.0.tar.gz
Algorithm Hash digest
SHA256 39d901772166caae78e18a1e4681e4a2b5e80d3baf73a66350c513538e59e53c
MD5 f9e28ea7675a88c121ae3b30ceba930e
BLAKE2b-256 43808578222cccafd4eabf6f4eb0b876b6b77d90e89f94203dab3a28c5b59c01

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadrants_typing-0.2.0.tar.gz:

Publisher: publish.yml on D0liphin/quadrants-typing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quadrants_typing-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quadrants_typing-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4271df584d823a70034c8c119dd6e95f8fc4568487500f2c3064bb2fa621dab0
MD5 d741b61bffc94dd18cc45d940fc004ed
BLAKE2b-256 082bcd5f5f8eaa6d46a0f0676dfb2b65c6b34d385df206e3bd8a05d55b8c8e77

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadrants_typing-0.2.0-py3-none-any.whl:

Publisher: publish.yml on D0liphin/quadrants-typing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

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