TECHNOLOGY

llama.cpp BF16 small projections: device size belongs in the CUDA dispatch rule

In this article
THE QUICK TAKE

The b12287 BF16 dispatch change uses shape and GPU resources; a small projection can prefer different kernels on different device sizes.

llama.cpp b12287 uses MMVF for eligible BF16 matrices with few rows at small batch sizes. Upstream explains that a matrix-matrix route can launch too few blocks to occupy a large GPU. The dispatch rule therefore considers device resources as well as matrix shape, rather than applying one batch threshold everywhere.

Too little parallel work can waste a large GPU

The upstream explanation focuses on few-row BF16 matrices where the existing route creates only a small number of blocks. More computational capacity is not automatically useful if the launch exposes too little independent work. The alternate route distributes work differently. This is why a configuration that benefits a large GPU need not benefit a smaller one, even when both support the same datatype and execute the same mathematical multiplication.

The rule is multidimensional

The PR’s gate includes the inner dimension, activation columns, row count and SM count, with architecture-dependent constants. A benchmark varying only batch size can miss why the route changes. A proposed dispatch study records every relevant matrix dimension and tests cases just inside and outside the gate. Preserve the GPU model with those records, because the same tensor shape can cross a different decision boundary on another device.

Microbenchmarks explain, but do not replace, the request

The PR reports a shape sweep and device-specific measurements. Those support the chosen heuristic in the tested space. To connect it to a serving result, identify how often the model invokes the affected BF16 projections and what fraction of total time they consume. A large ratio on a tiny projection can have a small effect on request latency. Keep prompt and generation phases separate when their internal shapes differ.

Correctness coverage still spans both routes

Changing the dispatch can expose an implementation that the old shape heuristic rarely used. Compare numerical results on both sides of the new gate and retain the former route as a reference where practical. The published change is a targeted selection heuristic, not a new BF16 model format. This article adds no independent speedup claim and does not treat upstream results on one GPU as measurements on another.

Sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles