﻿# llama.cpp Vulkan narrow-N tiles: small matrix widths need their own measurements

Vulkan narrow-N matmul tiles in b12396 target a shape regime; validate dispatch and small-batch workloads before generalizing their benefit.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-vulkan-narrow-n-matmul-tiles/
Language: en

The b12396 llama.cpp prerelease includes Vulkan matrix-multiplication tile configurations for narrow N. The PR describes cooperative-matrix paths tuned for N at most 32. This creates a focused performance question around small matrix widths, rather than evidence that every Vulkan inference workload improves by the same amount.

## N is a matrix dimension

The upstream change adds narrow tile choices for coopmat1 and coopmat2. The named N cutoff is a kernel-shape condition, not a promise about a user-facing request count. A serving batch can lead to several different internal matrix shapes, especially when speculative verification or other graph transformations are involved. Before comparing results, identify the matrix dimensions actually reaching the changed implementation and the cooperative-matrix path supported by the device.

## Tile tuning can move a bottleneck

A tile configuration influences how work is divided, what partial results are retained and how much otherwise idle work a narrow output entails. That makes shape-specific tuning reasonable, but it also limits extrapolation from one measurement. The PR discussion explicitly presents a smaller change than a different kernel approach the author explored. Its existence is not evidence that the same configuration is optimal across every vendor or architecture.

## Compare neighbouring shapes

A qualification matrix should include narrow widths near the dispatch boundary and a wider control, while keeping weight format and the other dimensions fixed. Check correctness before timing. Then separate warmup and steady-state operation, documenting whether shader compilation is included. A workload that crosses the cutoff can expose a discontinuity worth understanding, but the cutoff alone does not tell whether an application will notice that discontinuity.

## A useful end-to-end claim

If a model benefits, report the actual prompt, output length, concurrency and device rather than replacing them with a general Vulkan speed claim. A matrix microbenchmark can explain a serving result without being interchangeable with it. Conversely, an unchanged request latency may simply mean that narrow matmul contributes little to that request. This release supplies a specific optimization to investigate; no new benchmark results are asserted here. Include the reduction dimension in saved results, even when the study focuses on narrow N. Two products with the same narrow output width can require very different total work, and pooling their timings would obscure whether the tile choice or the workload size changed.

## Sources

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

## Related reading

- [vLLM or llama.cpp: serving workloads and GGUF workflows](/journal/vllm-vs-llama-cpp/)
- [CUDA events and request time: different measurement boundaries](/journal/gpu-cuda-events-wall-time/)
