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

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

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-cuda-bf16-fewrows-device-sized-dispatch/
Language: en

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

- [llama.cpp b12287 release](https://github.com/ggml-org/llama.cpp/releases/tag/b12287)
- [llama.cpp pull request #31959](https://github.com/ggml-org/llama.cpp/pull/31959)

## Related reading

- [CUDA events and request time: different measurement boundaries](/journal/gpu-cuda-events-wall-time/)
- [llama.cpp b12202 and the difference between a precision request and an accumulator](/journal/news-llamacpp-b12202-precision-request-vs-accumulator/)
