2026-11-26 15:40 UTC

zk4x releases compact Blackhole kernel compiler and driver

state: seedheat: mediumuncertainty: mediumrelevance: highai-infrastructure tenstorrent open-source-driverszk4xTenstorrent

What is this?

Skamandros is an open-source driver and kernel compiler by developer zk4x, released in November 2026 for Tenstorrent Blackhole accelerators. The project describes a roughly 1 MB library with a PTX-like kernel language and C ABI, intended to compile and dispatch kernels without requiring callers to work directly with many hardware details. The author reports end-to-end support for operations including copies, elementwise math, reductions and matrix multiplication, and says tests pass in Tenstorrent’s functional simulator; RMS normalization is reported as working in simulation but failing on the card. Multi-device operation and multicast are not working yet. It requires Linux and Tenstorrent’s kernel driver, and targets a Blackhole p100a card or simulator. Evidence is mainly the author’s repository and launch post; independent validation or adoption is not established by the supplied sources.

Why it matters

A compact, lower-level software path could make it easier for independent developers to experiment with Tenstorrent hardware and write kernels without adopting its more unwieldy existing software stack, as the author characterizes it. The PTX-like interface and C ABI may also let other compilers or languages use it as a backend. If it matures, this could widen access to accelerator programming and support alternative tooling—but the reported capabilities are early, the card-testing caveat matters, and there is no evidence here of broader adoption or production readiness.

Current assessment

New: zk4x has published Skamandros as an available Apache-2.0 project, with source, build instructions, examples and a generated C header. The project says its compiler turns a PTX-like assembly into programs for Tenstorrent cores, handling scheduling and allocation, and packages firmware and compiler in `libskamandros.so` (about 1 MB according to the README). The ABI covers device initialization, memory allocation and transfer, compilation, synchronous launch and cleanup. The README lists end-to-end operations including matmul and a gate-projection-shaped GEMM test, but these are author-reported results; its own status says RMS normalization is green in simulation and red on the card, and multi-device and multicast do not work. Hardware use requires Linux, `tt-kmd` and a Blackhole p100a; simulator use requires a separate Tenstorrent simulator. The source does not establish performance versus Tenstorrent’s software stack, compatibility beyond the stated target, independent verification, or uptake. Significance is potential rather than demonstrated: a small C-accessible compiler/driver could lower friction for custom kernels and become a backend for higher-level tools, while current evidence supports treating it as an experimental developer project, not a mature alternative stack.

Measured heat

now 0 pts/hpeak 5 pts/hcomments 0/hpeers p10momentum: steady2 platformsage 260h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

11-15 19:22 (minted)⭐ origin echo-reconstructedA Tenstorrent Blackhole driver and kernel compiler, packaged as a small library, with a PTX-like assembly and C ABI; the author describes it
zk4x on github (echo) · attributed from hn.story.50509698 · published time unknown
—
11-15 19:09first on hacker news · published · lag ?Show HN: 1MB Tenstorrent driver with ptx like kernels
zk4x
—
11-15 19:09amplified on hacker news 👑hn.story.50509698
zk4x
peak 1 · 0 comments · 103% of case engagement
11-15 19:20our radar first saw it · lag ?discovery anchor: hn.story.50509698—
pace: p13 vs 2096 stories at the 168h mark (now 260h old) — behind adobe-max-ai-agents-creative-tools-mcp (0.5x)

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnShow HN: 1MB Tenstorrent driver with ptx like kernels
Retrieved article excerpt

Open article · Retrieved 2026-11-15T19:21:30.688577+00:00

# skamandros

[crates.io](https://crates.io/crates/skamandros)

A kernel compiler and driver for Tenstorrent Blackhole, shipped as
`libskamandros.so` and `skamandros.h`.

```
"since he was engaged on the left, by the banks of Skamandros,
 where the death-toll was highest and the war-cries rose"
```

## Why?

Tenstorrent has amazing and powerful hardware, but the software is a bit unwieldy. This library grew
over ~5 months of working on the zyx Tenstorrent backend and my failures to utilize tt-metal.

## How?

A PTX-like assembly gets compiled and dispatched to all the Tenstorrent baby cores. Firmware and compiler are both
inside one `libskamandros.so`, about 1 MB on the disk.

A simple matmul, distributed over a grid of Tensix cores, with symbolic dims:

```
version 9
%nx = param i32 0
%ny = param i32 0
%ntiles = param i32 0
%ktiles = param i32 0
%ncols = param i32 0
%pa = param bf16 16384
%pw = param bf16 245760
%pc = param f32 245760

%ba = buffer bf16 32,32
%bb = buffer bf16 32,32
%bc = buffer f32 32,32
%acc = acc f32 32,32
%zero = const f32 0
%tile = const i32 1
%x = grid.x
%y = grid.y
%nsites = mul %nx %ny
%sitey = mul %y %nx
%site = add %sitey %x
%per = div %ntiles %nsites
%i = loop %per
  %step = mul %i %nsites
  %t = add %site %step
  %m = div %t %ncols
  %n = mod %t %ncols
  %arow = mul %m %ktiles
  %brow = mul %n %ktiles
  store 32,32 %acc = %zero
  %j = loop %ktiles
    %ka = add %arow %j
    %kb = add %brow %j
    %oa = mul %ka %tile
    %ob = mul %kb %tile
    copy 32,32 %ba [0] = %pa [%oa]   # L1 <- DRAM
    copy 32,32 %bb [0] = %pw [%ob]   # L1 <- DRAM
    load 32,32 %a = %ba [0]          # dst tile <- L1
    load 32,32 %b = %bb [0]          # src tile <- L1
    matmul %acc %a %b                # Dst accumulator += a x b
  endloop                            # the K walk
  store 32,32 %bc [0] = %acc
  %coff = mul %t %tile
  copy 32,32 %pc [%coff] = %bc [0]
endloop                              # this core's output tiles

grid %nx,%ny
```

The caller writes SSA over DRAM parameters, L1 buffers and register values, and names no processor, `Dst` slot, `Src` bank,
lane register, semaphore, unpacker, packer or Tensix word. A shape is a comma-separated list of terms, each a literal
or an `i32` value; a scalar parameter is the shape `0`, and a buffer is two constant dimensions, each `1` or a multiple of 32.
Every `load`, `store` and `copy` names its unit — `32,32` a tile, `1,32` a row, `32,1` a column, `1,1` one
datum — and its index counts those units. There is no implicit dtype conversion: `cast` converts with the C type's rounding,
`bitcast` renames the same bits, and the dtypes are `f32`, `bf16`, `i32` and `bool`. The ops are [zyx's](https://github.com/zk4x/zyx) `UOp` and
`BOp` plus `matmul`, `sum` and `max`; there is no `relu`/`elu`/`sigmoid` - these can be written manually using other
primitive ops and *skamandros automatically optimizes memory allocation around them* (that is automatic **fusion**, no llks,
[you are welcome](https://github.com/geohot/tt-tiny)).

### No implicit casts

There are no implicit conversions, anywhere. Every binary op, `sel`, comparison and `copy` needs both sides to have the same dtype,
and the verifier refuses a mixed pair with `TT_ERROR_NO_IMPLICIT_CAST`; there is no promotion, so an `f32` tile and an `i32` literal
in one `add` is an error, not a widening. A conversion is always written out: `cast` (C rounding) or `bitcast` (the same
bits under another name).

A `bool` is not an index. A comparison produces a `bool`, and an `i32` context — a loop bound, an index, a shape term,
an offset — refuses a `bool` operand with `TT_ERROR_DIMENSION_NOT_INDEX` (or `TT_ERROR_OFFSET_NOT_INDEX`): write
`cast %c to i32`, which is `1` for true and `0` for false. The two forms of a `bool` are:

- a scalar `bool`, used in index arithmetic and evaluated in RISC-V, is `1`/`0`;
- a `bool` lane in a tile, where the comparison runs on the SFPU, is `-1`/`0`, and `cast` to `i32` normalizes it to `1`/`0`.

## Let the compiler do the job

The compiler decides which machine programs each instruction belongs to, where each value lives, which lane registers its body uses,
how a buffer is read, and which core runs what: a reader on RISCV B, the unpacker on T0, the math on T1, the packer on T2, a writer on NC.
Two IRs carry it: the virtual `Op` (one id space — an `OpId` *is* the value) and the machine `MirOp` (one ISA instruction, or a structural pair).

So it's similar to PTX or LLVM (though no phi nodes) in that the compiler handles scheduling, allocation and some small simple
optimizations. This is a fully deterministic compiler. Other ML compilers (e.g. zyx) can then search over different configs using skamandros
as their last step of the lowering.

## Install

The `firmware` feature — on by default — compiles the device's RISC-V images into the library, so two
toolchain pieces come first:

```
rustup target add riscv32im-unknown-none-elf   # the firmware's cores
rustup component add llvm-tools                # objcopy/objdump, for the images
cargo build --release
```

This writes `libskamandros.so` and `skamandros.h` into `target/release`; copy both to your path.
For usage, look at examples and tests.

## Requirements

- Linux, with the card reached through `tt-kmd` (`/dev/tenstorrent/0`).
- A Tenstorrent Blackhole p100a, or Tenstorrent's functional simulator (`ttsim` 1.16.0 or newer) named in
  `$TT_METAL_SIMULATOR`.
- Rust 1.85 or newer to build, with the `riscv32im-unknown-none-elf` target and `llvm-tools` (see Install).

## The C ABI

The build generates `skamandros.h` next to `libskamandros.so`, from the code that declares it:

- `ttAbiVersion` — the ABI version this library implements, `1`. A consumer compares it against the header it was built with.
- `ttCompile` — compiles a program's text form into an opaque `ttModule` handle; `*out` is the handle, or null with the code saying why.
- `ttMemAlloc` — reserves a byte range of DRAM and returns its address, 64-byte aligned. The address is opaque: hand it back to the copies and the launch.
- `ttMemcpyH2D` — copies host bytes into DRAM at an address `ttMemAlloc` returned. A null pointer or a zero length is refused, nothing read.
- `ttMemcpyD2H` — copies DRAM bytes back into host memory, the other direction of the same transfer. Same argument rules as `ttMemcpyH2D`.
- `ttLaunch` — runs a module over its grid, synchronously: every program has finished when it returns. `params` holds one word per kernel parameter in program order, a DRAM address for a tensor and the value itself for a scalar.
- `ttModuleUnload` — drops a module handle. A second unload of the same handle is `TT_ERROR_MODULE`, never a double free; a compiled module is reusable until then.
- `ttInit` — opens the device, idempotently. The target comes from the environment: `$TT_METAL_SIMULATOR` for the simulator, `TT_HARDWARE=1` for the card, and with neither set it refuses rather than guessing.
- `ttRelease` — closes the device and returns the chip to its idle operating point; a later `ttInit` opens a fresh one. Module handles are unaffected.
- `ttFree` — frees an error message this library returned. A null pointer is a no-op, and module handles are not freed here.

Every call but `ttAbiVersion` and `ttFree` returns a `ttStatus`, and on failure writes a message the caller frees with
`ttFree`. The text form is the only program form `ttCompile` reads.

## Building and testing

```
cargo build          # target/debug/libskamandros.so
cargo test           # unit tests, then the end-to-end suite (TT_HARDWARE=1 for the card)
```

The end-to-end suite (`tests/e2e.rs`) `dlopen`s the built library and drives the C ABI exactly as a consumer would;
it builds the `cdylib` itself first. It sets no environment of its own: the transport comes from the environment, as `ttInit`
reads it. A simulator run needs Tenstorrent's functional simulator, which is not part of this repository,
named in `$TT_METAL_SIMULATOR` (a copy in `vendor/`, git-ignored, works well), with the Blackhole descriptor beside it:

```
mkdir -p vendor && curl -L -o vendor/libttsim_bh.so \
  https://github.com/tenstorrent/ttsim/releases/latest/download/libttsim_bh.so
cp $TT_METAL_HOME/tt_metal/soc_descriptors/blackhole_140_arch.yaml vendor/soc_descriptor.yaml
TT_METAL_SIMULATOR=$PWD/vendor/libttsim_bh.so cargo test
```

A card run exports `TT_HARDWARE=1` and leaves `$TT_METAL_SIMULATOR` unset. With neither set, `ttInit` refuses
instead of guessing which target was meant.

`ttsim` 1.16.0 or newer is what this tree is measured on. Unit tests are not the measure; the end-to-end suite is.

## Status

Working end to end through the C ABI:

- copies,
- elementwise arithmetic,
- comparisons,
- `sel`,
- casts and bitcasts,
- bf16 — constants, a bf16 page widening into a 32-bit `Dst` through `SrcA` and `MOVA2D`, bf16 reduces, and the
  transcendentals `log2`, `sin`, `cos`, `reciprocal`, `sqrt`, `div` as lane bodies on the 32-bit lane, so a bf16 kernel
  stays 16-bit,
- both reduces,
- `matmul`,
- `rms_norm` over two tokens and the real hidden size — it is red on the card, green on sim
- a symbolic loop bound,
- a symbolic grid,
- a gather,
- a `gate_proj`-shaped GEMM over the whole grid (240 tiles, every datum checked),
- `Dst` reuse by liveness, so a kernel's *values* may outnumber the bank's slots: `softmax` needs eleven live values
  in eight slots,
- mcast and multi device are not working yet.

## Examples

`examples/` holds three minimal C consumers that `dlopen` the library and drive the C ABI: a DRAM loopback,
an elementwise kernel and a matmul. They are not tests — each one compiles its program, uploads the inputs,
launches and exits.

Build the library, then put both the library and its generated header on the search paths:

```
cargo build --release
export LD_LIBRARY_PATH="$PWD/target/release:$LD_LIBRARY_PATH"   # libskamandros.so, for dlopen
export CPATH="$PWD/target/release:$CPATH"                        # skamandros.h, for gcc
cd examples
gcc dram_loopback.c -o dram_loopback && ./dram_loopback
```

The same for `eltwise.c` and `matmul.c`. `-ldl` is only needed on a glibc older than 2.34, and
`target/debug` works exactly the same way for a debug build. The device still comes from the
environment: `TT_HARDWARE=1` for the card, or `$TT_METAL_SIMULATOR` for the simulator.

## License

Apache-2.0. Copyright (C) 2026 zk4x.

Skamandros was enabled by the amazing work by Knight-Ops <https://github.com/Knight-Ops/metalium-rs> without
whom I wouldn't have dreamed about doing the whole driver myself.
zk4x10
🟧 echo.github ⭐A Tenstorrent Blackhole driver and kernel compiler, packaged as a small library, with a PTX-like assembly and C ABI; the author describes itzk4x——

Interpretation history

Decision trace