Ferrotensor
ContentsBenchmarks

Ferrotensor GPU kernel benchmarks

Kernel-level GPU timings for ferrotensor-backend. They are not end-to-end training throughput: model loading, optimizer state, host/device copies and synchronisation are not included.

SetupLink to this section

  • Hardware: Apple M2 (10-core GPU), 8 GB unified memory, MacBook Air
  • OS: macOS 27.2; backend: Metal via wgpu 0.19
  • Toolchain: rustc 1.99.1, --release
  • Command: cargo run -p ferrotensor-benchmarks --release
  • Method: each case is dispatched in batches (about 20 ms per sample, at most 64 calls) followed by one GPU wait; the table shows the median per-call time. "Before" and "after" binaries were run alternately three times each, and the best median of the three is reported, because other processes were using the GPU and single runs varied by up to 2x.
  • FLOP conventions: matmul 2*M*N*K; causal attention forward 2*B*H*S^2*D (half of 4*B*H*S^2*D), backward 2.5x the forward. Row kernels and element-wise ops report bytes read plus written per second.

Before / afterLink to this section

"Before" is the commit "Rewrite the benchmark suite as a library with bin and bench targets": the original matmul, softmax and RMSNorm kernels, and the first correct flash attention kernels. The original flash attention computed wrong results, so it has no meaningful timing. "After" is the commit "Document every public item in ferrotensor-graph", which has every kernel change below.

kernelshapebeforeafterspeed-up
matmul512x512x5122.47 ms (109 GFLOPS)0.65 ms (414 GFLOPS)3.8x
matmul1024x1024x102418.25 ms (118 GFLOPS)3.83 ms (561 GFLOPS)4.8x
matmul2048x2048x2048141.06 ms (122 GFLOPS)28.89 ms (595 GFLOPS)4.9x
matmul4096x4096x40961114.32 ms (123 GFLOPS)225.09 ms (611 GFLOPS)5.0x
matmul512x2048x8192142.88 ms (120 GFLOPS)28.91 ms (594 GFLOPS)4.9x
matmul1000x1000x100018.30 ms (109 GFLOPS)3.83 ms (523 GFLOPS)4.8x
matmul_bt1024x1024x102447.14 ms (46 GFLOPS)3.82 ms (562 GFLOPS)12.3x
matmul_at1024x1024x102415.26 ms (141 GFLOPS)3.82 ms (562 GFLOPS)4.0x
attention_fwdb1 h16 s512 d64 causal31.93 ms (17 GFLOPS)10.68 ms (50 GFLOPS)3.0x
attention_fwdb1 h16 s1024 d64 causal103.34 ms (21 GFLOPS)27.40 ms (78 GFLOPS)3.8x
attention_fwdb1 h16 s2048 d64 causal370.32 ms (23 GFLOPS)92.66 ms (93 GFLOPS)4.0x
attention_fwdb1 h8 s1024 d128 causal132.12 ms (16 GFLOPS)42.55 ms (50 GFLOPS)3.1x
attention_bwdb1 h16 s512 d64 causal161.04 ms (8 GFLOPS)39.69 ms (34 GFLOPS)4.1x
attention_bwdb1 h16 s1024 d64 causal581.93 ms (9 GFLOPS)130.62 ms (41 GFLOPS)4.5x
softmax4096x10242.31 ms (14 GB/s)0.45 ms (74 GB/s)5.1x
rms_norm2048x40963.86 ms (17 GB/s)0.87 ms (77 GB/s)4.5x
add4M0.66 ms (72 GB/s)0.62 ms (78 GB/s)1.1x
silu4M0.45 ms (72 GB/s)0.48 ms (66 GB/s)0.9x

Element-wise ops (add, silu) are memory-bound and unchanged; the differences are noise.

What changedLink to this section

  • matmul / matmul_bt / matmul_at: one register-blocked kernel. Each 16x16 workgroup computes a 64x64 output tile, each thread 4x4 outputs held in vec4 registers, with K staged through workgroup memory in slices of 16. matmul_bt was previously an untiled loop.
  • attention forward: K/V tiles, query and accumulator as vec4, 128 queries per workgroup.
  • attention backward: preprocess fused into the dQ pass; K/V and Q/dO staged as vec4 tiles; key/query ranges outside the causal/window band are skipped per workgroup.
  • softmax / RMSNorm: one 256-thread workgroup per row with a tree reduction instead of one thread per row.

Tried and not keptLink to this section

Under the same best-of-3 timing, these gave no measurable gain:

  • matmul with 8x4, 4x8 or 8x8 outputs per thread (vec4 registers): 550-620 GFLOPS, within noise of 4x4. With plain arrays instead of vec4, 8x8 fell to about 90 GFLOPS (register spills).
  • matmul K slice of 32 instead of 16: slower (about 370 GFLOPS at 4096^3).
  • Coalescing the A/B tile loads along K: no change beyond noise.
  • Attention forward with 256 queries per workgroup: faster at s512 but about 30% slower at s1024 and s2048.

ContextLink to this section

The M2 GPU peaks at about 3.6 TFLOPS FP32, so matmul reaches about 17% of peak. Apple's MPS reaches a much larger fraction; closing that gap needs simdgroup_matrix operations, which WGSL does not expose.

ferrotensor Tensor API: CPU and GPU devicesLink to this section

End-to-end timings through the ferrotensor crate's Tensor API, including the host-side cost of every op (autograd bookkeeping, buffers, bind groups, submission) and a read back to the host at the end, as user code does.

SetupLink to this section

  • Hardware: Apple M2 (10-core GPU), 8 GB unified memory, MacBook Air
  • OS: macOS 27.2; backend: Metal via wgpu 0.19
  • Toolchain: rustc 1.99.1, --release
  • Command: cargo run -p ferrotensor-benchmarks --release --bin tensor-api
  • Method: three warm-up iterations, then at least 10 timed iterations (up to 200 or 2 s); each case reports the median. "Before" and "after" binaries were run alternately three times each; the table shows the best median of the three.
  • "Before" is commit "Add a Tensor API benchmark for CPU and GPU devices" (one submission per op); "after" is commit "Gather embedding rows on the GPU without reading the ids back".
  • The benchmark prints a checksum of each case's output bits. On every case the GPU checksum is the same before and after, so the GPU results are bit for bit unchanged.

Before / afterLink to this section

caseCPUGPU beforeGPU afterGPU speed-up
100 element-wise ops on [64], then to_vec0.046 ms10.63 ms0.82 ms13x
100 element-wise ops on [4096], then to_vec1.38 ms10.73 ms0.84 ms12.8x
MLP 784-256-10, one AdamW step, batch 64, then loss.item()12.45 ms10.80 ms3.98 ms2.7x
matmul 512x512x512, then to_vec10.30 ms5.22 ms2.77 ms1.9x

The CPU column is the best of all six runs; the CPU path did not change.

The examples, timed with /usr/bin/time -p around FERROTENSOR_DEVICE=cpu|gpu cargo run --release -p ferrotensor --example <name> (binaries built once, then run directly). Their weights are not seeded, so the final losses differ from run to run.

exampleCPUGPU beforeGPU after
char_transformer (600 steps, "trained 600 steps in")42.5 s (44.4 s with the before binary)105.0 s31.9 s
mlp_two_moons (60 epochs, wall time, two runs)0.19-0.24 s12.46 s, 16.60 s2.21 s, 1.80 s

What changedLink to this section

  • Batched submission. Ops are recorded and submitted together at the next read back, host write, or every 256 ops, instead of one submit per op (a submit costs about 117 µs of CPU on this machine).
  • One compute pass per batch. On Metal each compute pass costs about 40 µs of GPU time; consecutive dispatches in one pass cost about 13 µs each in a 100-dispatch micro test.
  • Op arguments in one buffer. Uniforms and shape metadata go into one buffer written once per batch, instead of a new buffer per op. Bind group layouts are cached.
  • Buffer pool. Op outputs reuse freed tensor buffers of the same size (up to 128 MiB per device), which also skips wgpu's zero fill of new buffers. This took the 100-op chain on [4096] from 1.77 ms to 0.90 ms and the MLP step from 5.1 ms to 4.0 ms in single runs.
  • Spin-wait for read backs. wgpu 0.19's blocking wait on Metal sleeps in 1 ms steps (wgpu-hal metal/device.rs, Device::wait), so every to_vec/item cost at least about 1.3 ms. Waits now busy-poll for up to 10 ms before blocking; a read back after the GPU is idle takes about 0.18 ms.

Full reductions and argmax on the GPULink to this section

Same machine, toolchain and method as above (best median of three alternating runs of each binary), with cargo run -p ferrotensor-benchmarks --release --bin tensor-api. "Before" is commit "Benchmark full sum and argmax in tensor-api"; "after" is commit "Run argmax and argmin on the GPU without reading the tensor back". Inputs are seeded randn.

caseCPUGPU beforeGPU afterGPU speed-up
sum() of [4096, 4096], then item18.27 ms2169.35 ms1.19 ms1820x
sum() of [1000000], then item0.96 ms129.20 ms0.35 ms374x
argmax_dim(-1) of [1024, 4096], then to_vec5.66 ms8.40 ms0.99 ms8.5x
argmax() of [4096, 4096]17.25 ms27.69 ms1.19 ms23x

The CPU column is the best of all six runs; the CPU path did not change.

  • sum(), max() and min() over a whole tensor used one GPU thread. The reduce_all kernel now spreads the first pass over 256 workgroups of 256 threads (1024 workgroups measured 1.23 ms and 0.39 ms on the two sum() cases in a single run, so 256 stays) and a one-workgroup pass adds the 256 partials.
  • The GPU now adds in a different order from the CPU's left-to-right loop, so the GPU sum() checksums changed; the other cases' checksums are the same before and after, so argmax gives the same indices. Against an f64 sum of 16.7M uniform values in [-2, 2) (printed from full_reductions_match_cpu_on_gpu), the GPU's error is 4.5e-11 of sum(|x|) and the CPU's 5.9e-9.
  • argmax_dim read the whole tensor back to the host; argmax()/argmin() did too. The arg_reduce kernel keeps them on the GPU; argmax() and argmin() read back only the index.

Index backward passes, cat and cross_entropy on the GPULink to this section

Same machine, toolchain and method as above (best median of three alternating runs of each binary), with cargo run -p ferrotensor-benchmarks --release --bin tensor-api. "Before" is commit "Benchmark embedding, index_select, cat and cross_entropy in tensor-api"; "after" is commit "Compute class-id cross_entropy on the GPU". Inputs are seeded randn; each case ends with a read back.

caseCPU beforeCPU afterGPU beforeGPU afterGPU speed-up
Embedding [32000, 256], 4096 ids, forward + backward, read the gradient7.10 ms7.08 ms13.83 ms8.89 ms1.6x
index_select(0, 1024 ids) of [2048, 2048], backward8.75 ms8.74 ms8.68 ms5.04 ms1.7x
index_select(1, 1024 ids) of [2048, 2048], backward27.29 ms26.58 ms14.16 ms7.91 ms1.8x
cat of 8 [512, 512] along dim 00.55 ms0.56 ms5.58 ms1.50 ms3.7x
cat of 8 [512, 512] along dim 10.58 ms0.60 ms5.58 ms1.48 ms3.8x
cross_entropy [4096, 32000], class ids, forward + backward4226.86 ms517.16 ms749.64 ms64.58 ms11.6x
MLP 784-256-10 AdamW step, batch 6412.16 ms12.26 ms3.69 ms2.13 ms1.7x
  • Index backward passes. The new scatter_rows kernel gives each output element a thread that adds its row's incoming gradient rows. It reads them through (row, position) pairs sorted by row, then position, and a table of where each row's pairs start. index_select sorts its indices on the host, where they already are. Embedding keeps its ids on the device and sorts them there with a bitonic sort (sort_ids, one dispatch per compare-and-swap step: 78 for 4096 ids). WGSL has no float atomics; adding with a compare-and-swap loop on u32 bits would make the order of the additions, and so the rounding, change from run to run. The sorted version adds in position order, as the CPU loop does, so the gradients are deterministic and match the CPU bit for bit (same checksums as before, and scatter_backward_matches_cpu_on_gpu compares them with assert_eq!). The Embedding case is still slower on the GPU than on the CPU because it reads back the whole 32.8 MB gradient.
  • cat read every input back and uploaded the result; the copy_block kernel now copies each input into its slice of the output on the device. Same checksums: the values are copied exactly.
  • cross_entropy with class ids read the targets back and built a dense [rows, classes] weight tensor on the host (524 MB here), then took log_softmax, a product and a sum. The cross_entropy_rows kernel now gives each row a workgroup of 256 threads that writes the row's loss (log-sum-exp minus the target logit); cross_entropy_grad writes softmax minus one-hot times the row's incoming gradient. The CPU path uses the same per-row reference, which is why it got faster too. The "before" runs peaked at 3.1 GB resident (/usr/bin/time -l) on this 8 GB machine and their medians varied (CPU 4.2 s to 8.8 s, GPU 0.75 s to 1.17 s across the three runs); the "after" runs peaked at 1.6 GB and varied by under 4%. The loss is now computed in a different order, so the cross_entropy and MLP checksums changed; cross_entropy_matches_cpu_on_gpu checks the GPU against the CPU to 1e-5 relative on the loss and 1e-6 absolute on the gradient, up to [64, 32000].
  • The other cases' checksums are the same before and after, and their times moved by at most 11% (sum() of [4096, 4096] on the GPU, 1.08 to 1.20 ms; that op did not change).

What is still slowLink to this section

  • 100 tiny ops on [64] on the GPU still take about 17x as long as on the CPU (0.82 ms against 0.049 ms in the runs above): most of it is GPU time per dispatch (about 9-13 µs each, serialised within the pass), plus one round trip to read the result. Fusing element-wise chains into one kernel would be the next step.
  • cross_entropy with soft labels uses log_softmax, whose kernel gives each row one thread: slow on wide rows such as a 32000-token vocabulary.
  • The Embedding sort uses one dispatch per bitonic step (78 for 4096 ids, 136 for 65536); sorting blocks of 512 in workgroup memory would cut that to a handful.
  • argmax_dim gives each output row a workgroup of 256 threads, so on a short axis (10 classes) most threads idle.

NVIDIA GPUs through VulkanLink to this section

An NVIDIA A10G (24 GB) and a Tesla T4 (16 GB) on Linux, NVIDIA driver 595.112.07, Vulkan backend (WGPU_BACKEND=vulkan), rustc 1.99.1, commit 165921d. Each machine ran scripts/hardware-report.sh twice, with FERROTENSOR_FUSION=0 and =1, and the GPU test suites first (229 tests passed on each GPU, none skipped). The JSON reports are the source of every number here.

Kernel suiteLink to this section

kernelshapeA10GT4
matmul512x512x5120.077 ms (3501.5 GFLOPS)0.154 ms (1737.9 GFLOPS)
matmul1024x1024x10240.335 ms (6417.9 GFLOPS)1.049 ms (2047.8 GFLOPS)
matmul2048x2048x20481.880 ms (9140.6 GFLOPS)8.353 ms (2056.6 GFLOPS)
matmul4096x4096x409615.057 ms (9127.9 GFLOPS)65.883 ms (2086.1 GFLOPS)
matmul512x2048x81921.957 ms (8778.4 GFLOPS)8.465 ms (2029.6 GFLOPS)
matmul1000x1000x10000.316 ms (6326.7 GFLOPS)1.041 ms (1920.6 GFLOPS)
matmul_bt1024x1024x10240.378 ms (5682.9 GFLOPS)1.257 ms (1709.0 GFLOPS)
matmul_at1024x1024x10240.270 ms (7953.2 GFLOPS)0.865 ms (2483.3 GFLOPS)
attention_fwdb1 h16 s512 d64 causal2.094 ms (256.4 GFLOPS)2.679 ms (200.4 GFLOPS)
attention_fwdb1 h16 s1024 d64 causal5.296 ms (405.5 GFLOPS)10.549 ms (203.6 GFLOPS)
attention_fwdb1 h16 s2048 d64 causal19.974 ms (430.0 GFLOPS)69.027 ms (124.4 GFLOPS)
attention_fwdb1 h8 s1024 d128 causal8.941 ms (240.2 GFLOPS)12.377 ms (173.5 GFLOPS)
attention_bwdb1 h16 s512 d64 causal6.766 ms (198.4 GFLOPS)15.447 ms (86.9 GFLOPS)
attention_bwdb1 h16 s1024 d64 causal29.456 ms (182.3 GFLOPS)86.459 ms (62.1 GFLOPS)
softmax4096x10240.099 ms (338.3 GB/s)0.169 ms (198.1 GB/s)
rms_norm2048x40960.226 ms (297.3 GB/s)0.386 ms (173.8 GB/s)
add4M0.118 ms (405.5 GB/s)0.208 ms (230.3 GB/s)
silu4M0.084 ms (383.0 GB/s)0.151 ms (211.7 GB/s)

Tensor API, fusion off and onLink to this section

GPU medians with op fusion off and on. Checksums are identical with fusion off and on for every case on both GPUs: fusion is bit-exact here too. CPU is the A10G machine's own CPU.

caseCPUA10G offA10G onT4 offT4 on
100 element-wise ops, [64]0.080 ms0.676 ms0.322 ms0.668 ms0.305 ms
100 element-wise ops, [4096]3.303 ms0.677 ms0.315 ms0.669 ms0.301 ms
MLP 784-256-10 AdamW step, batch 6413.441 ms0.855 ms0.673 ms0.929 ms0.752 ms
matmul 512x512x512 + read back16.684 ms0.528 ms0.532 ms0.616 ms0.613 ms
sum() [4096, 4096] + read back100.515 ms0.258 ms0.258 ms0.366 ms0.364 ms
sum() [1000000] + read back3.528 ms0.114 ms0.114 ms0.073 ms0.073 ms
argmax_dim(-1) [1024, 4096] + read back8.031 ms0.147 ms0.146 ms0.146 ms0.145 ms
argmax() [4096, 4096]60.121 ms0.268 ms0.270 ms0.417 ms0.396 ms
Embedding 32000x256 fwd+bwd, 4096 ids62.797 ms11.626 ms11.640 ms13.376 ms13.303 ms
index_select(0) bwd [2048, 2048], 1024 ids19.408 ms5.550 ms5.593 ms5.837 ms5.148 ms
index_select(1) bwd [2048, 2048], 1024 ids62.935 ms5.905 ms5.947 ms6.749 ms5.639 ms
cat 8 x [512, 512] dim 0 + read back2.058 ms2.817 ms2.826 ms2.443 ms2.247 ms
cat 8 x [512, 512] dim 1 + read back2.201 ms2.818 ms2.823 ms2.391 ms2.247 ms
cross_entropy [4096, 32000] class ids fwd+bwd2557.350 ms49.483 ms49.355 ms44.720 ms44.769 ms

Op fusion halves the 100-op chain on both GPUs (0.676 to 0.322 ms on the A10G, 0.668 to 0.305 ms on the T4) and takes 21% off the A10G's MLP step. Ops that are not element-wise chains (matmul, cross_entropy, reductions) are unchanged, as expected. The chain is still about 4x the CPU time here, down from about 8x unfused.

Real hardware run, 16 November 2026Link to this section

One NVIDIA A10G (24 GB), driver 595.112.07, Vulkan backend, rustc 1.100.0, release build of main at commit 8b814c1. Every command below ran once: these are single runs, not medians over repeats, except where a table says "median of 30". Peak GPU memory is the largest nvidia-smi sample, in MiB. Held-out loss is the loss eval reports on the held-out examples. The commands covered are info, plan, finetune, eval, chat, merge, export-gguf, generate, train --profile and pretrain with the byte-level tokenizer, plus the gradient and forward parity tests.

Self-check and parityLink to this section

  • ferrotensor info --check passed.
  • Gradient parity against PyTorch fixtures: 4 tests passed, worst absolute difference 9.239e-7.
  • Forward parity: 10 tests passed.

finetune with no memory flagsLink to this section

30 steps at the default learning rate. "Chosen" is the batch size times the gradient accumulation that the planner picked.

ModelChosen batch × accumulationSequence lengthPeak GPU memoryHeld-out loss before → after
SmolLM2-135M8 × 12566,331 MiB2.4250 → 2.2775
SmolLM2-360M8 × 12569,104 MiB2.0852 → 1.8187
SmolLM2-360M, --batch-size 44 × 22567,220 MiB2.0852 → 1.8187
SmolLM2-1.7B4 × 225615,064 MiB2.6474 → 2.0299
SmolLM2-1.7B, --seq-len 1288 × 112814,196 MiB2.6635 → 2.0389
Qwen2.5-0.5B-Instruct8 × 125611,197 MiB1.3359 → 1.2682

A memory budget of 3,000 MiB on SmolLM2-1.7B is refused with exit code 2.

One command on SmolLM2-1.7B, then use the resultLink to this section

finetune with --lr 5e-4 --warmup-steps 20 for 250 steps. The planner chose batch 4 × accumulation 2 at sequence length 256.

StepResult
finetuneheld-out loss 2.6474 → 1.0612; peak GPU memory 15,128 MiB; peak host memory 1,576 MiB (1,613,876 kB maximum resident set size); 334.6 s of training
eval with the adapter1.0612
mergewrote 96 merged and 122 copied tensors
eval on the merged model1.0605
chatthe adapter and the merged model gave the same three greedy replies
export-ggufwrote 218 tensors (3,424,735,104 bytes)
llama.cpp (commit 9fba51d, CPU build, llama-simple)loaded the file; its greedy completion of "The capital of France is" was " Paris.", the same as Ferrotensor's

The merged model's loss is 0.0007 from the adapter on the base. The merged weights are rounded to the base's f16. The llama.cpp check compares two tokens of one prompt, so it shows that the file loads and starts the same way, not that the two agree on longer text.

Qwen2.5-0.5B-Instruct, a real checkpointLink to this section

The checkpoint loads. Its held-out loss is 1.3359 on 64 held-out examples, the "before" figure in the finetune table above. Greedy generate answered "The capital of France is Paris." The finetune row above is the 30-step run of this model.

4-bit weights: the gap is there before trainingLink to this section

Held-out loss of the untouched base model, with no training:

Modelf32f164-bit
SmolLM2-135M2.42502.42502.6139
SmolLM2-360M2.08522.08522.2575
SmolLM2-1.7B2.64742.64743.7470

The 4-bit loss is already higher before any adapter is trained. 4-bit still fails its quality gate, so it stays experimental.

Where step time goes, train --profileLink to this section

Batch 1 × 8-step accumulation, sequence length 256, per optimizer step (median of 30 steps):

ModelDispatchesStep wall timeOf which waiting for the GPU
SmolLM2-135M22,2641.176 s0.459 s
SmolLM2-1.7B17,8002.219 s1.675 s

The loss and gradient norm at step 30 equal those of the 15 November 2026 run of the same command: 135M 2.5320 and 1.476, 1.7B 1.4793 and 1.665.

Compute passes shared by consecutive dispatchesLink to this section

main at 85b3419 opened one compute pass per kernel dispatch. Builds that encode consecutive dispatches into one pass, with at most 4, 8, 16 or 32 dispatches per pass, were run against it on one NVIDIA A10G. All runs used the same machine, with the builds interleaved, two runs each. Loss and gradient norm were the same in every build. Step wall time per optimizer step, batch 1 × 8-step accumulation, sequence length 256, train --profile:

Modelmainat most 4at most 8at most 16at most 32
SmolLM2-135M1.166 s1.001 s0.989 s0.982 s1.018 s
SmolLM2-360M1.547 s1.353 s1.334 s1.325 s1.393 s
SmolLM2-1.7B2.216 s2.146 s2.169 s2.165 s2.300 s

Compute passes per step at 4 / 8 / 16 / 32: 135M 7,305 / 4,435 / 3,295 / 3,049; 360M 7,733 / 4,695 / 3,491 / 3,243; 1.7B 5,825 / 3,553 / 2,650 / 2,450. main has one pass per dispatch. The host time per step falls as passes are shared. Long passes add GPU time, enough to make 1.7B slower than main at 32. An earlier box measured 2.227 s at 16 against 2.217 s for main on 1.7B, so 16 is at the edge there. main now uses at most 8: 15.2% faster on 135M, 13.8% on 360M and 2.1% on 1.7B in this table.

Other measurements with shared passes, on the same machine:

  • Greedy generate, 120 tokens: 135M 40.6 → 59.5 tokens per second, 1.7B 16.1 → 17.5. The cap made no difference here.
  • The 250-step finetune of 1.7B at batch 4 × 2 (at most 16 per pass): 334.6 s → 327.9 s of training, the same held-out loss 1.0612. The tracked peak rose by 168 MiB on that run (13,893 → 14,061 MiB).

Passes of up to 128 dispatches (20 November 2026)Link to this section

The cap of 8 above was set before the host time per dispatch fell. On one NVIDIA A10G (g5.xlarge) at perf/fused-split 582b813, train without --profile, autotune cache warmed, FERROTENSOR_PASS_DISPATCHES set per run, batch 1 × 8-step accumulation, sequence length 256, median step after the first 10 steps of each run, mean of two runs. SmolLM2-135M:

Dispatches per pass8163264128
Median step, 60 steps137.0 ms127.7 ms124.9 ms123.1 ms120.8 ms

The same setting on SmolLM2-1.7B at batch 1 × 8: 279.2, 276.3, 273.6, 272.5 and 272.4 ms (60 steps, mean of two runs). The default is now 128, the pending-ops cap. Step time at 8 and at 128, six cases, 120 steps, mean of two runs with the builds interleaved:

Case8128
135M, 1 × 8143.6 ms124.6 ms
135M, 8 × 138.8 ms37.8 ms
360M, 1 × 8163.7 ms143.6 ms
360M, 8 × 177.6 ms76.8 ms
1.7B, 1 × 8275.5 ms268.6 ms
1.7B, 8 × 1253.7 ms251.4 ms

The loss after 250 steps of 135M is the same to every printed digit (held-out loss 2.4249938 before and 1.6533391 after) with 8 dispatches per pass and with 128 on the build that also reuses bind groups, which changes no result. Kernel timestamps were off in these runs: --profile turns them on, and its timing is of a different mode than the one measured here.

The corpus is a 1 MB English text file built from the Alpaca training examples.

ModelParametersStepsLoss, first logged step → lastTimePeak GPU memory
Defaults (4 blocks, width 128)1,116,0322,0004.5239 → 1.227151.1 s431 MiB
8 blocks, width 384, 6 heads19,079,8083,0003.5511 → 0.7507385.1 s1,672 MiB

generate --raw from both models produced English-like text. pretrain --resume at the saved step trained 0 steps and exported.

Not measured in this runLink to this section

  • pretrain --tokenizer bpe.
  • The speed of the kept chat cache.
  • Any Apple, AMD or Intel GPU.
  • Any comparison with PyTorch speed or memory.
  • The full GPU test suite. It stopped at the Qwen2 fixture tests, which need FERROTENSOR_QWEN2_FIXTURE (see testing on your GPU), so this run does not show that the whole suite passes on this GPU at this commit.

Second card: NVIDIA Tesla T4 (16 GB)Link to this section

One NVIDIA Tesla T4 (15,360 MiB), release build of main at commit c7a0131, f16 base weights, LoRA rank 8. Peak GPU memory is the largest nvidia-smi sample at 200 ms; "tracked" is measured_peak_mib, the buffers Ferrotensor counts itself.

ModelBatch × accumulationSequence lengthStepsPeak GPU memoryTracked
SmolLM2-135M8 × 1256306,146 MiB4,447 MiB
SmolLM2-360M8 × 1256308,920 MiB7,543 MiB
SmolLM2-360M4 × 2256307,002 MiB5,336 MiB
SmolLM2-1.7B2 × 4256309,541 MiB8,654 MiB
SmolLM2-1.7B2 × 425625011,138 MiB8,879 MiB
SmolLM2-1.7B8 × 11283014,913 MiB16,354 MiB
Qwen2.5-0.5B-Instruct8 × 12563011,012 MiB9,212 MiB
SmolLM2-135M, train --profile1 × 8256301,953 MiB1,319 MiB
SmolLM2-1.7B, train --profile1 × 8256307,520 MiB6,236 MiB
  • The planner chose batch 2 × accumulation 4 for SmolLM2-1.7B on this card. 250 steps took the held-out loss from 2.6474 to 1.0598, with a peak of 11,138 MiB GPU memory and 1,566 MiB host memory. eval gave 1.0598 with the adapter and 1.0596 on the merged model. llama.cpp loaded the exported GGUF file and matched on the same two-token check as above.
  • Qwen2.5-0.5B-Instruct: held-out loss 1.3359; the 30-step fine-tune at batch 8 peaked at 11,012 MiB.
  • The full GPU test suite passed on this card: 58 test binaries, 0 failures, the four Qwen2 fixture tests skipped.
  • train --profile, per optimizer step: SmolLM2-135M 1.215 s, of which 0.420 s waiting for the GPU; SmolLM2-1.7B 3.482 s, of which 2.860 s waiting for the GPU. The loss and gradient norm at step 30 equal those of the A10G run: 135M 2.5320 and 1.476, 1.7B 1.4793 and 1.665.
  • pretrain with the defaults reached loss 1.2271 in 71.2 s (peak 246 MiB), and the 19,079,808-parameter model 0.7507 in 916.7 s (peak 1,487 MiB), the same losses as on the A10G.

Real hardware run, 17 November 2026: generationLink to this section

One NVIDIA A10G (24 GB), Vulkan backend, release builds of main at 612b3f7 and of the branch that adds the decode kernels (a matrix-vector kernel for one-row products, one-query attention and the GPU argmax). Same machine, builds interleaved, three runs each; the runs of one build differ by less than 1.5%. The output text was byte-identical between the two builds on every run (same SHA-256): greedy generate on all three models and a three-turn greedy chat on 1.7B.

generate, 120 new tokens, decode speed in tokens per second:

ModelSamplingmainDecode kernels
SmolLM2-135Mgreedy58.4110.1
SmolLM2-360Mgreedy39.896.7
SmolLM2-1.7Bgreedy18.956.9
SmolLM2-135M--temperature 0.7 --seed 752.691.5
SmolLM2-1.7B--temperature 0.7 --seed 718.351.2

Three-turn greedy chat on SmolLM2-1.7B with the kept KV cache, tokens per second per turn: main 18.9 / 17.1 / 15.7, decode kernels 56.7 / 55.0 / 53.4.

Sampled generation still reads the logits row back each step and samples on the host; greedy decoding reads back only the token id.

Real hardware run, 17 November 2026: thin matrix products in trainingLink to this section

One NVIDIA A10G (24 GB), Vulkan backend, release builds of main at dab3301 and of the branch that adds the thin matmul kernel (matmul_thin, matmul_thin_h: products whose output has at most 64 rows, or with f32 b at most 64 columns). Same machine, builds interleaved, three runs each; the runs of one build differ by less than 0.3%.

train --profile, sequence length 256, seconds per optimizer step:

ModelBatch x accumulationmainThin kernel
SmolLM2-135M1 x 81.1930.961
SmolLM2-360M1 x 81.5711.203
SmolLM2-1.7B1 x 82.2331.697
SmolLM2-1.7B4 x 21.3481.261

The training loss at step 30 is the same on both builds: 2.5320 on SmolLM2-135M, 1.8838 on 360M and 1.4793 on 1.7B, also 1.4793 at batch 4 x 2. The gradient norm at step 30 printed the same on both builds too.

A 250-step finetune of SmolLM2-1.7B with the planner's setting (batch 4 x accumulation 2) took 328.0 s on main and 320.0 s on the branch. The held-out loss was 1.0612 on main and 1.0607 on the branch; the two differ because the thin kernel adds in a different order. The tracked peak was 14,061 MiB on both.

Greedy generation is unchanged, since one-row products already run the matrix-vector kernel: 108.9 and 110.9 tokens per second on SmolLM2-135M, 57.0 and 57.2 on 1.7B.