hawk

Contents

hawk

hawk#

One kernel, two machines. hawk is a Python DSL (domain-specific language) for writing a numerical kernel once and running it, unchanged, on CPU or GPU.

A kernel is a plain Python function decorated @hawk.kernel. hawk turns it into a small typed representation of what it computes, derives its forward- and reverse-mode derivatives from that representation, and compiles it for the eagle runtime to run.

import hawk
from hawk import Mutable, Param, Scalar

@hawk.kernel
def scale(x: Scalar, a: Param, b: Param, y: Mutable[Scalar]):
    y = a * x + b

That is the whole authoring surface: a declared vocabulary of planes — a plane is the role one argument plays for every sample, such as a per-sample input, a shared constant, or an output — and each parameter’s type says which plane it fills (Scalar a per-sample input, Param a uniform constant, Mutable[...] an output plane; defined in full in the first tutorial, next), plus an ordinary arithmetic body. hawk.artifact.build compiles it for host and device in one call — pip install raptor-hawk (the CPU route; for a GPU add the [cuda12] or [cuda13] extra, see the full install guide) is all it takes to try it.

Start here

Write, build and run a kernel in about five minutes — then run the same one on a GPU with the same call.

Run your first kernel
Tutorials

Arguments and shapes, stopping conditions, gradients backward and forward, lookups and sums.

Tutorials
Vocabulary

Write your own vocabulary and pair it to a new kernel kind: inheritance, a custom derivative, and a capstone running the whole stack through PyTorch.

Vocabulary
Reference

Every public name in hawk, hawk.math, hawk.ext, hawk.diff, hawk.compile and hawk.runtime.

API reference

New to the whole RAPTOR family? The landing page’s Start here walks through one kernel, a million samples and a PyTorch fit in ten minutes, across every repo at once.

Where hawk sits#

hawk is the kernel-authoring layer of the RAPTOR family. It writes and compiles kernels, and hawk.runtime runs a host build directly; it never launches a DEVICE artifact itself — that is deployed and run by eagle, the family’s GPU execution layer, over the protocol raptor defines and aether provides the vector-algebra vocabulary for.

aether (numerics core)  --->  eagle (execution)  <---  raptor (contracts)  --->  hawk (kernel authoring)

aether lays out arrays and provides the device-safe vector-algebra vocabulary; eagle launches and captures what runs on top of it; raptor is the dependency-free foundation that defines the manifest and protocol contracts eagle and hawk both build to without depending on each other; hawk authors and compiles the kernels eagle deploys.