`grain_drag_bench` (lightcraft-gpu example): GPU draft renders of a 2.5 MP
preview while Amount or Size is dragged, ms per frame. It doesn't depend on
the grain model, so it runs unchanged on other branches. docs/grain.md gets
its results on the Ryzen 5 7545U / Radeon 740M for main, #1060 and this
model, and the whole-render grain cost of main and #1060 there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part 4 of 5 of #2167. The text detector's DETR encoder runs on the GPU
device of the image encoder: the same matrix products (ReLU as a third
epilogue), attention for 8 heads of 32 with separate q / k / v buffers and
the prompt's key-padding bias. Its weights (~120 MB) load on the first text
prompt. A failure leaves the encoder to candle for the rest of the session;
the backbone and the necks stay on the GPU. The mask decoder is still in
candle. The parity test prints the largest difference of every query's mask.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part 3 of 5 of #2167. Both necks (3 levels each) run on the GPU device of
the image encoder: the 2 x 2 stride-2 transposed convolutions as per-pixel
products (weights re-laid on upload), the 3 x 3 convolutions as an implicit
GEMM (the matrix kernel with an A-tile loader that reads the neighbourhood
straight from the image, so the 764 MB im2col at 288^2 never exists). Built
on first use, ~250 MB. A failing neck is left to candle on its own; the
backbone stays on the GPU. The bench reports a failing neck and goes on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part 2 of 5 of #2167. lightcraft-gpu gets a `sam` feature with `sam3`: a
device of its own (like denoise and faces, with the same switches, the crash
sentinel and the shutdown gate), the shared kernels (tiled matrix products
with bias / GELU / residual in the epilogue, flash-style attention, layer
norm, RoPE, im2col, the final reorder) and the image encoder built from them.
The engine now uses it as the GPU backbone where candle has no GPU (not
macOS); the necks and the text detector's heads stay in candle.
An adapter without the needed limits (98 MB storage buffers, 16 KB
workgroup memory) or whose device can't be created gets no device; the
backbone then runs in candle on the CPU and Settings shows why
(sam3::tests::an_adapter_short_of_the_limits_is_refused_with_what_it_lacks).
A pass that doesn't finish names its stage in the reason the device is
given up with. The parity test prints the largest mask difference to the
CPU next to the IoU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part 5 of 5 of #2167. The text detector's mask decoder runs on the GPU
device of the image encoder: the prompt cross-attention of the memory (the
DETR attention), the pixel decoder up to 288^2 (the necks' implicit-GEMM 3 x 3
convolution, a two-pass GroupNorm, ReLU), then the mask products. The
instance projection is folded into the 200 mask embeddings on the CPU, and
the semantic projection (#1963) is one more row, so the GPU returns the
per-query masks and the semantic mask in one product. Its weights load on
the first text prompt. The parity test checks the semantic mask too.
docs/gpu-pipeline.md and docs/ai-masks.md describe every part, with the
measured timings and accuracy, and what happens on an adapter that lacks
the limits or whose device can't be created.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>