Skip to content

Tack

A Python framework for scientific data analysis, visualization and GPU compute. Build pipelines over structured grids, mixed meshes and polyhedra: associate arrays, derive quantities, extract surfaces, sample solutions and render results, on one dataset or on one cut into pieces with ghost cells. The dataset algorithms are Tack kernels, and you can write your own as decorated Python functions. The same supported kernel source runs on five backends, within each backend's capabilities. Metal has no f64, for example, and the CPU has no workgroup primitives.

Start with the Visualization Guide for a mesh-to-image workflow, or Getting Started to write a first kernel. A small compute example is:

import tack, numpy as np

tack.set_default_device("cpu")          # or metal, cuda, hip, level_zero

@tack.kernel
def vector_add(x, y, out):
    for i in range(x.shape[0]):   # the outermost loop maps to thread parallelism
        out[i] = x[i] + y[i]

n = 1_000_000
x = tack.empty((n,))
y = tack.empty((n,))
out = tack.empty((n,))
tack.copyto(x, np.arange(n, dtype=np.float32))
tack.copyto(y, np.ones(n, dtype=np.float32))

vector_add(x, y, out)
print(out.numpy()[:4])         # [1. 2. 3. 4.]

Only the tack.set_default_device() line changes between backends:

tack.set_default_device("cpu")
LLVM IR through llvmlite, dispatched with ctypes. Threads are used only when a measurement says they pay — see Backends.

tack.set_default_device("metal")
MSL compiled by the Metal API. Buffers are shared memory on Apple silicon, so host and device see the same allocation.

tack.set_default_device("cuda")
CUDA C through NVRTC to PTX, launched with cuLaunchKernel.

tack.set_default_device("hip")
HIP C through hipRTC. The code generator is the CUDA one with a different #include — device syntax is shared.

tack.set_default_device("level_zero")
OpenCL C compiled to SPIR-V by libocloc, launched through Level Zero.

Install

Tack is not on PyPI yet; install it from a clone of the repository:

git clone https://github.com/berkgeveci/tack.git && cd tack
pip install -e 'packages/tack-core[cpu]'      # CPU only
pip install -e 'packages/tack-core[metal]'    # ...or Apple silicon
pip install -e 'packages/tack-core[cuda]'     # ...or NVIDIA
pip install -e packages/tack-vis              # datasets and visualization

See Backends for what each extra pulls in and which scalar types each backend supports.

Where to go next

  • Visualization Guide

    Meshes, point clouds and field spaces, scientific filters, custom cell and face kernels, probing and streamlines, data in pieces, then simulation and rendering pipelines. Start with complete programs whose results are checked independently.

  • User's Guide

    Writing kernels, arrays and types, control flow, device functions, templates, atomics and shared memory, reductions and scans, alongside the data and visualization chapters.

  • Developer's Guide

    How a decorated function becomes machine code: the AST transform, the IR and its passes, the five code generators, and the runtime that caches and dispatches them.

  • Design and Implementation

    Why Tack is built the way it is: the principles, the compilation pipeline, specialization and caching, numerical semantics, parallel execution, memory and aliasing, and interoperability.

  • Contracts

    What Tack promises and what callers must ensure: the kernel language contract, backend capabilities, the runtime API and its errors, and how conformance is tested and validated.

  • Backends

    The capability table — codegen, runtime compiler, dispatch, buffer type and supported dtypes for each of the five.

  • API

    The public surface, generated from the source.

What Tack is not

It is not a drop-in numpy replacement and not an autograd framework. Kernels are written in a restricted subset of Python that is read as source and compiled — the User's Guide covers what that subset includes.