Enceladus v0.1.0 · alpha
Host APIReference pages
Language builtinsHost APIData types and tilesEnvironment variables

Reference

Host API

The functions and classes in the enceladus module that compile, launch, and tune kernels, allocate tensors, and exchange memory with other frameworks. To call them inside a kernel, use the language builtins instead.

Compile and launch

enceladus.jit(fn=None, *, interpret=None, do_not_specialize=(), math_mode='relaxed')

Decorates a kernel or helper. Launch a kernel with kernel[grid](*args, **constexprs, num_warps=4).

kernel.warmup(*args, grid=None, num_warps=4, dot_warps=None, dot_backend='auto', **constexprs)

Compiles one specialization without launching it. The result has msl, ir, num_warps, and threadgroup_memory_bytes.

kernel.explain(*args, grid=None, num_warps=4, dot_warps=None, dot_backend='auto', **constexprs)

Prints and returns the compiler's layout, register, and backend decisions.

enceladus.metal_kernel(source, name, language_version=None, math_mode='relaxed')

Compiles hand-written MSL. Launch with kernel[grid, threads_per_group](*args).

enceladus.cdiv(x, div)

Returns ceil(x / div), the number of blocks that cover x.

enceladus.next_power_of_2(n)

Returns the smallest power of two that is at least n.

Autotuning

enceladus.autotune(configs, key, prune_configs_by=None, reset_to_zero=None, restore_value=None, warmup_ms=50, rep=20)

Picks the fastest config for each distinct set of key values and argument dtypes.

enceladus.Config(kwargs, num_warps=4, dot_warps=None, dot_backend='auto', pre_hook=None)

One autotuning candidate: constexpr values plus launch options.

enceladus.heuristics(values)

Computes constexpr values from the kernel's arguments.

enceladus.configs.matmul_configs(dtype='float16')

Returns the shipped matmul candidates for float32, float16, or bfloat16.

enceladus.configs.attention_configs(dtype='float16', head_dim=64)

Returns the shipped flash attention candidates.

enceladus.testing.do_bench(fn, warmup_ms=50.0, rep=20, return_mode='median')

Times fn with GPU timestamps and returns milliseconds.

Streams and interop

enceladus.synchronize()

Waits for all work on the default stream.

enceladus.async_numpy(enabled=True)

Lets launches with NumPy arrays return before the GPU finishes.

enceladus.element_strides(obj)

Returns strides in elements for Enceladus, NumPy, PyTorch, or MLX arrays.

enceladus.element_dtype(obj)

Returns the element type of an Enceladus, NumPy, PyTorch, or MLX array as a NumPy dtype.

enceladus.new_empty(like, shape=None, dtype=None)

Allocates an array of the same framework and device as like. dtype can be a NumPy dtype.

enceladus.new_zeros(like, shape=None, dtype=None)

Like new_empty, and fills the array with zeros.

enceladus.get_device()

Returns the process-wide Metal device and its capabilities.

enceladus.capture(path)

A context manager that records GPU work to a .gputrace bundle.

Tensors

An enceladus.Tensor lives in memory that the CPU and GPU share. Slicing returns a view.

enceladus.empty(shape, dtype='float32')

Returns an uninitialized tensor.

enceladus.zeros(shape, dtype='float32'), enceladus.ones(shape, dtype='float32')

Returns a tensor filled with zeros or ones.

enceladus.full(shape, value, dtype='float32')

Returns a tensor filled with value.

enceladus.randn(*shape, dtype='float32', seed=None), enceladus.rand(*shape, dtype='float32', seed=None)

Returns standard normal or uniform [0, 1) samples.

enceladus.arange(start, end=None, step=1, dtype='int32')

Returns a range tensor, like np.arange.

enceladus.empty_like(t, dtype=None), enceladus.zeros_like(t, dtype=None)

Returns a tensor with the shape of t.

enceladus.from_numpy(a)

Shares a's memory when it's C-contiguous and 16 KB page-aligned, and copies otherwise.

Tensor.numpy(), Tensor.tolist()

Waits for pending GPU work and returns the data on the host.

Errors

enceladus.CompilationError

Raised for a construct that Enceladus can't compile, with the source location and a fix.

enceladus.DeviceAssertionError

An AssertionError subclass raised when tl.device_assert fails.

enceladus.MetalError

Raised for a Metal runtime error, such as a failed command buffer.