Projects / active

Weft mark: an amber thread crossing vertical strands.

Weft

A compiler that plans a chunk of a model or media pipeline for one specific machine, and checks every output bit for bit against a slow reference.

Status
active
Languages
C#
Weft’s README banner: a row of taut vertical grey strands with one bright amber thread woven across them, and the word “weft” in warm light on black.
Flowchart, top to bottom. A C# fluent frontend builds a Graph through GraphBuilder, which becomes the semantic IR in Weft.Ir. Weft.Analysis computes value ranges, effects and access structure; Weft.Optimizer runs elementwise fusion, region merge and evidence-gated device placement. The result is a Physical Plan, .weftplan.json, which feeds pluggable renderers: IL, C# source, Metal, and a CUDA C artifact. Those reach a thin runtime that binds parameters and runs, a developer doing inspect and A/B, or a remote GPU built off-machine.

I started Weft in late August on a bet: that the speed is less inside any one kernel than in how a group of them gets laid out, fused and scheduled for the machine in front of you. The first result looked like I'd lost. Its kernels were 5% slower than the ones I'd written by hand, and the pipeline built from them was faster anyway.

It isn't allowed to assume much. Every output has to match a slow scalar reference bit for bit or the plan doesn't compile, and it chooses between options from measurements taken on the actual machine. Where it has no measurement, it says Unknown. It's written in C# on .NET 10, which is not where people usually go for this.

What keeps surprising me is how often a good decision on one machine is a bad one on the next. The fused attention I wrote on a Zen+ box lost on a Broadwell Xeon and again on an M4. That's why Weft now prices every fusion instead of matching shapes, and why it emits its own x64 and arm64 where RyuJIT can't reach the instruction it needs.

It's what I work on most days. It's private and unreleased.

  • SAM 3 on x64: from 3.75× behind ggml to about 2× ahead, and level with it under Strict floating point.
  • On an Apple M4, not fusing attention was 1.46× faster than fusing it.
  • The planner reached 96.5% of my best hand-made schedule for SAM 3's vision tower, from measurements alone.
  • Generated CUDA is still up to 39× behind cuBLAS.