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")
tack.set_default_device("metal")
tack.set_default_device("cuda")
cuLaunchKernel.
tack.set_default_device("hip")
#include — device syntax is shared.
tack.set_default_device("level_zero")
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¶
-
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.
-
Writing kernels, arrays and types, control flow, device functions, templates, atomics and shared memory, reductions and scans, alongside the data and visualization chapters.
-
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.
-
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.
-
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.
-
The capability table — codegen, runtime compiler, dispatch, buffer type and supported dtypes for each of the five.
-
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.